_load_bash_it_files "plugins"
}
-show_plugins ()
+bash-it-plugins ()
{
- about summarizes available bash_it plugins
- group lib
+ about 'summarizes available bash_it plugins'
+ group 'lib'
typeset f
typeset enabled
printf "%-20s%-10s%s\n" "$(basename $f | cut -d'.' -f1)" " [$enabled]" "$(cat $f | metafor about-plugin)"
done
printf '\n%s\n' 'to enable a plugin, do:'
- printf '%s\n' '$ enable_plugin <plugin name>'
+ printf '%s\n' '$ enable-plugin <plugin name> -or- $ enable-plugin all'
printf '\n%s\n' 'to disable a plugin, do:'
- printf '%s\n' '$ disable_plugin <plugin name>'
+ printf '%s\n' '$ disable-plugin <plugin name> -or- $ disable-plugin all'
}
-enable_plugin ()
+disable-plugin ()
{
- about enables bash_it plugin
- param 1: plugin name
- example '$ enable_plugin rvm'
- group lib
+ about 'disables bash_it plugin'
+ param '1: plugin name'
+ example '$ disable_plugin rvm'
+ group 'lib'
- typeset plugin=$(ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)
- if [ -z "$plugin" ]; then
- printf '%s\n' 'sorry, that does not appear to be an available plugin.'
+ if [ -z "$1" ]; then
+ reference disable_plugin
return
fi
- plugin=$(basename $plugin)
- if [ -h $BASH_IT/plugins/enabled/$plugin ]; then
- printf '%s\n' "$1 is already enabled."
- return
+ if [ "$1" = "all" ]; then
+ typeset f plugin
+ for f in $BASH_IT/plugins/available/*.bash
+ do
+ plugin=$(basename $f)
+ if [ -h $BASH_IT/plugins/enabled/$plugin ]; then
+ rm $BASH_IT/plugins/enabled/$(basename $plugin)
+ fi
+ done
+ else
+ typeset plugin=$(ls $BASH_IT/plugins/enabled/$1.*bash 2>/dev/null | head -1)
+ if [ ! -h $plugin ]; then
+ printf '%s\n' 'sorry, that does not appear to be an enabled plugin.'
+ return
+ fi
+ rm $BASH_IT/plugins/enabled/$(basename $plugin)
fi
- ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin
- printf '%s\n' "$1 is enabled."
-
- reload_plugins
- printf '%s\n' 'plugins reloaded.'
+ printf '%s\n' "$1 disabled."
}
-disable_plugin ()
+enable-plugin ()
{
- about disables bash_it plugin
- param 1: plugin name
- example '$ disable_plugin rvm'
- group lib
+ about 'enables bash_it plugin'
+ param '1: plugin name'
+ example '$ enable_plugin rvm'
+ group 'lib'
- typeset plugin=$(ls $BASH_IT/plugins/enabled/$1.*bash 2>/dev/null | head -1)
- if [ -z "$plugin" ]; then
- printf '%s\n' 'sorry, that does not appear to be an enabled plugin.'
+ if [ -z "$1" ]; then
+ reference enable_plugin
return
fi
- rm $BASH_IT/plugins/enabled/$(basename $plugin)
- printf '%s\n' "$1 is disabled, and will be unavailable when you open a new terminal."
+
+ if [ "$1" = "all" ]; then
+ typeset f plugin
+ for f in $BASH_IT/plugins/available/*.bash
+ do
+ plugin=$(basename $f)
+ if [ ! -h $BASH_IT/plugins/enabled/$plugin ]; then
+ ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin
+ fi
+ done
+ else
+ typeset plugin=$(ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)
+ if [ -z "$plugin" ]; then
+ printf '%s\n' 'sorry, that does not appear to be an available plugin.'
+ return
+ fi
+
+ plugin=$(basename $plugin)
+ if [ -h $BASH_IT/plugins/enabled/$plugin ]; then
+ printf '%s\n' "$1 is already enabled."
+ return
+ fi
+
+ ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin
+ fi
+
+ printf '%s\n' "$1 enabled."
}
plugins-help ()
{
- about list all plugins and functions defined by bash-it
- group lib
+ about 'list all plugins and functions defined by bash-it'
+ group 'lib'
printf '%s\n' "bash-it plugins help"
printf '\n'
all_groups ()
{
- about displays all unique metadata groups
- group lib
+ about 'displays all unique metadata groups'
+ group 'lib'
typeset func
typeset file=$(mktemp /tmp/composure.XXXX)
cite about-plugin
-about-plugin miscellaneous tools
+about-plugin 'miscellaneous tools'
ips ()
{
- about display all ip addresses for this host
- group base
+ about 'display all ip addresses for this host'
+ group 'base'
ifconfig | grep "inet " | awk '{ print $2 }'
}
down4me ()
{
- about checks whether a website is down for you, or everybody
- param 1: website url
+ about 'checks whether a website is down for you, or everybody'
+ param '1: website url'
example '$ down4me http://www.google.com'
- group base
+ group 'base'
curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
}
myip ()
{
- about displays your ip address, as seen by the Internet
- group base
+ about 'displays your ip address, as seen by the Internet'
+ group 'base'
res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+')
echo -e "Your public IP is: ${echo_bold_green} $res ${echo_normal}"
}
pickfrom ()
{
- about picks random line from file
- param 1: filename
+ about 'picks random line from file'
+ param '1: filename'
example '$ pickfrom /usr/share/dict/words'
- group base
+ group 'base'
local file=$1
[ -z "$file" ] && reference $FUNCNAME && return
length=$(cat $file | wc -l)
pass ()
{
- about generates random password from dictionary words
- param optional integer length
- param if unset, defaults to 4
+ about 'generates random password from dictionary words'
+ param 'optional integer length'
+ param 'if unset, defaults to 4'
example '$ pass'
example '$ pass 6'
- group base
+ group 'base'
local i pass length=${1:-4}
pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done))
echo "With spaces (easier to memorize): $pass"
pmdown ()
{
- about preview markdown file in a browser
- param 1: markdown file
+ about 'preview markdown file in a browser'
+ param '1: markdown file'
example '$ pmdown README.md'
- group base
+ group 'base'
if command -v markdown &>/dev/null
then
markdown $1 | browser
mkcd ()
{
- about make a directory and cd into it
- param path to create
+ about 'make a directory and cd into it'
+ param 'path to create'
example '$ mkcd foo'
example '$ mkcd /tmp/img/photos/large'
- group base
+ group 'base'
mkdir -p "$*"
cd "$*"
}
lsgrep ()
{
- about search through directory contents with grep
- group base
+ about 'search through directory contents with grep'
+ group 'base'
ls | grep "$*"
}
pman ()
{
- about view man documentation in Preview
- param 1: man page to view
+ about 'view man documentation in Preview'
+ param '1: man page to view'
example '$ pman bash'
- group base
+ group 'base'
man -t "${1}" | open -f -a $PREVIEW
}
pcurl ()
{
- about download file and Preview it
- param 1: download URL
+ about 'download file and Preview it'
+ param '1: download URL'
example '$ pcurl http://www.irs.gov/pub/irs-pdf/fw4.pdf'
- group base
+ group 'base'
curl "${1}" | open -f -a $PREVIEW
}
pri ()
{
- about display information about Ruby classes, modules, or methods, in Preview
- param 1: Ruby method, module, or class
+ about 'display information about Ruby classes, modules, or methods, in Preview'
+ param '1: Ruby method, module, or class'
example '$ pri Array'
- group base
+ group 'base'
ri -T "${1}" | open -f -a $PREVIEW
}
quiet ()
{
about 'what *does* this do?'
- group base
+ group 'base'
$* &> /dev/null &
}
banish-cookies ()
{
- about redirect .adobe and .macromedia files to /dev/null
- group base
+ about 'redirect .adobe and .macromedia files to /dev/null'
+ group 'base'
rm -r ~/.macromedia ~/.adobe
ln -s /dev/null ~/.adobe
ln -s /dev/null ~/.macromedia
usage ()
{
- about disk usage per directory, in Mac OS X and Linux
- param 1: directory name
- group base
+ about 'disk usage per directory, in Mac OS X and Linux'
+ param '1: directory name'
+ group 'base'
if [ $(uname) = "Darwin" ]; then
if [ -n $1 ]; then
du -hd $1
t ()
{
- about one thing todo
- param if not set, display todo item
- param 1: todo text
- group base
+ about 'one thing todo'
+ param 'if not set, display todo item'
+ param '1: todo text'
+ group 'base'
if [[ "$*" == "" ]] ; then
cat ~/.t
else
command_exists ()
{
- about checks for existence of a command
- param 1: command to check
+ about 'checks for existence of a command'
+ param '1: command to check'
example '$ command_exists ls && echo exists'
- group base
+ group 'base'
type "$1" &> /dev/null ;
}
# useful for administrators and configs
buf ()
{
- about back up file with timestamp
- param filename
- group base
+ about 'back up file with timestamp'
+ param 'filename'
+ group 'base'
local filename=$1
local filetime=$(date +%Y%m%d_%H%M%S)
cp ${filename} ${filename}_${filetime}
cite about-plugin
-about-plugin display info about your battery charge level
+about-plugin 'display info about your battery charge level'
battery_percentage(){
about 'displays battery charge as a percentage of full (100%)'
- group battery
+ group 'battery'
if command_exists acpi;
then
}
battery_charge(){
- about graphical display of your battery charge
- group battery
+ about 'graphical display of your battery charge'
+ group 'battery'
# Full char
local F_C='â–¸'
about-plugin 'render commandline output in your browser'
function browser() {
- about pipe html to a browser
+ about 'pipe html to a browser'
example '$ echo "<h1>hi mom!</h1>" | browser'
example '$ ron -5 man/rip.5.ron | browser'
- group browser
+ group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
function wmate() {
about 'pipe hot spicy interwebs into textmate and cleanup!'
example '$ wmate google.com'
- group browser
+ group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
function raw() {
about 'write wget into a temp file and pump it into your browser'
example '$ raw google.com'
- group browser
+ group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
# Jump to location by number.
cite about-plugin
-about-plugin directory stack navigation
+about-plugin 'directory stack navigation'
# Show directory stack
alias d="dirs -v -l"
alias po="popd"
function dirs-help() {
- about directory navigation alias usage
- group dirs
+ about 'directory navigation alias usage'
+ group 'dirs'
echo "Directory Navigation Alias Usage"
echo
alias L='cat ~/.dirs'
G () { # goes to distination dir otherwise , stay in the dir
- about goes to destination dir
- param 1: directory
+ about 'goes to destination dir'
+ param '1: directory'
example '$ G ..'
- group dirs
+ group 'dirs'
cd ${1:-$(pwd)} ;
}
S () { # SAVE a BOOKMARK
- about save a bookmark
- group dirs
+ about 'save a bookmark'
+ group 'dirs'
sed "/$@/d" ~/.dirs > ~/.dirs1;
\mv ~/.dirs1 ~/.dirs;
}
R () { # remove a BOOKMARK
- about remove a bookmark
- group dirs
+ about 'remove a bookmark'
+ group 'dirs'
sed "/$@/d" ~/.dirs > ~/.dirs1;
\mv ~/.dirs1 ~/.dirs;
cite about-plugin
-about-plugin one command to extract them all...
+about-plugin 'one command to extract them all...'
extract () {
if [ $# -ne 1 ]
then
case $- in
*i*) cite about-plugin
- about-plugin navigate 'frecently' used files and directories
+ about-plugin 'navigate "frecently" used files and directories'
eval "$(fasd --init auto)"
;;
*) # assume being executed as an executable
cite about-plugin
-about-plugin git helper functions
+about-plugin 'git helper functions'
function git_remote {
about 'adds remote $GIT_HOSTING:$1 to current repo'
- group git
+ group 'git'
echo "Running: git remote add origin ${GIT_HOSTING}:$1.git"
git remote add origin $GIT_HOSTING:$1.git
}
function git_first_push {
- about push into origin refs/heads/master
- group git
+ about 'push into origin refs/heads/master'
+ group 'git'
echo "Running: git push origin master:refs/heads/master"
git push origin master:refs/heads/master
function git_remove_missing_files() {
about "git rm's missing files"
- group git
+ group 'git'
git ls-files -d -z | xargs -0 git update-index --remove
}
# Adds files to git's exclude file (same as .gitignore)
function local-ignore() {
- about adds file or path to git exclude file
- param 1: file or path fragment to ignore
- group git
+ about 'adds file or path to git exclude file'
+ param '1: file or path fragment to ignore'
+ group 'git'
echo "$1" >> .git/info/exclude
}
# get a quick overview for your git repo
function git_info() {
- about overview for your git repo
- group git
+ about 'overview for your git repo'
+ group 'git'
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
# print informations
}
function git_stats {
- about display stats per author
- group git
+ about 'display stats per author'
+ group 'git'
# awesome work from https://github.com/esc/git-stats
# including some modifications
cite about-plugin
-about-plugin hg helper functions
+about-plugin 'hg helper functions'
hg_dirty() {
- about displays dirty status of hg repository
- group hg
+ about 'displays dirty status of hg repository'
+ group 'hg'
hg status --no-color 2> /dev/null \
| awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
hg_in_repo() {
about 'determine if pwd is an hg repo'
- group hg
+ group 'hg'
[[ `hg branch 2> /dev/null` ]] && echo 'on '
}
hg_branch() {
- about display current hg branch
- group hg
+ about 'display current hg branch'
+ group 'hg'
hg branch 2> /dev/null
}
# The install directory is hard-coded. TODO: allow the directory to be specified on the command line.
cite about-plugin
-about-plugin download jquery files into current project
+about-plugin 'download jquery files into current project'
[[ -z "$JQUERY_VERSION_NUMBER" ]] && JQUERY_VERSION_NUMBER="1.6.1"
[[ -z "$JQUERY_UI_VERSION_NUMBER" ]] && JQUERY_UI_VERSION_NUMBER="1.8.13"
function rails_jquery {
about 'download rails.js into public/javascripts'
- group javascript
+ group 'javascript'
curl -o public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js
}
function jquery_install {
about 'download jquery.js into public/javascripts'
- group javascripts
+ group 'javascripts'
if [ -z "$1" ]
then
function jquery_ui_install {
about 'download jquery_us.js into public/javascripts'
- group javascripts
+ group 'javascripts'
if [ -z "$1" ]
then
cite about-plugin
-about-plugin manage your jekyll site
+about-plugin 'manage your jekyll site'
editpost() {
- about edit a post
- param 1: site directory
- group jekyll
+ about 'edit a post'
+ param '1: site directory'
+ group 'jekyll'
unset SITE
if [ -z "$1" ]
}
newpost() {
- about create a new post
- param 1: site directory
- group jekyll
+ about 'create a new post'
+ param '1: site directory'
+ group 'jekyll'
unset SITE
if [ -z "$1" ]
}
function testsite() {
- about launches local jekyll server
- param 1: site directory
- group jekyll
+ about 'launches local jekyll server'
+ param '1: site directory'
+ group 'jekyll'
unset SITE
if [ -z "$1" ]
}
function buildsite() {
- about builds site
- param 1: site directory
- group jekyll
+ about 'builds site'
+ param '1: site directory'
+ group 'jekyll'
unset SITE
if [ -z "$1" ]
function deploysite() {
about 'rsyncs site to remote host'
- param 1: site directory
- group jekyll
+ param '1: site directory'
+ group 'jekyll'
unset SITE
if [ -z "$1" ]
cite about-plugin
-about-plugin use mactex
+about-plugin 'use mactex'
# add mactex to the path if its present
MACTEX_PATH=/usr/local/texlive/2009/bin/universal-darwin
cite about-plugin
-about-plugin manage your nginx service
+about-plugin 'manage your nginx service'
function nginx_reload() {
- about reload your nginx config
- group nginx
+ about 'reload your nginx config'
+ group 'nginx'
FILE="${NGINX_PATH}/logs/nginx.pid"
if [ -e $FILE ]; then
}
function nginx_stop() {
- about stop nginx
- group nginx
+ about 'stop nginx'
+ group 'nginx'
FILE="${NGINX_PATH}/logs/nginx.pid"
if [ -e $FILE ]; then
}
function nginx_start() {
- about start nginx
- group nginx
+ about 'start nginx'
+ group 'nginx'
FILE="${NGINX_PATH}/sbin/nginx"
if [ -e $FILE ]; then
}
function nginx_restart() {
- about restart nginx
- group nginx
+ about 'restart nginx'
+ group 'nginx'
FILE="${NGINX_PATH}/logs/nginx.pid"
if [ -e $FILE ]; then
{
about 'Node Version Manager'
param '1: command, see nvm help'
- group nvm
+ group 'nvm'
if [ $# -lt 1 ]; then
nvm help
function tab() {
about 'opens a new terminal tab'
- group osx
+ group 'osx'
osascript 2>/dev/null <<EOF
tell application "System Events"
about 'switch dock between 2d and 3d'
param '1: "2d" or "3d"'
example '$ dock-switch 2d'
- group osx
+ group 'osx'
if [ $(uname) = "Darwin" ]; then
cite about-plugin
-about-plugin '"alias "http" to SimpleHTTPServer'
+about-plugin 'alias "http" to SimpleHTTPServer'
if [ $(uname) = "Linux" ]
then
function remove_gem {
about 'removes installed gem'
param '1: installed gem name'
- group ruby
+ group 'ruby'
gem list | grep $1 | awk '{ print $1; }' | xargs sudo gem uninstall
}
function mkvenv {
about 'create a new virtualenv for this directory'
- group virtualenv
+ group 'virtualenv'
cwd=`basename \`pwd\``
mkvirtualenv --no-site-packages --distribute $cwd
function mkvbranch {
about 'create a new virtualenv for the current branch'
- group virtualenv
+ group 'virtualenv'
mkvirtualenv --no-site-packages --distribute "$(basename `pwd`)@$(git_prompt_info)"
}
function wovbranch {
about 'sets workon branch'
- group virtualenv
+ group 'virtualenv'
workon "$(basename `pwd`)@$(git_prompt_info)"
}