From 55e77deac19ce82831a7d873d8459b0bfb59391e Mon Sep 17 00:00:00 2001 From: Erich Smith Date: Fri, 11 May 2012 23:27:03 -0400 Subject: [PATCH] standardize plugins, update metadata add about-plugin metadata chmod -x plugins cleanup filenames to standardize on x.plugin.bash format only plugin files intended to be executable from the command line should contain a shebang line, and should be a+x. --- ..._xterm.plugins.bash => _xterm.plugin.bash} | 0 plugins/available/base.plugin.bash | 4 +-- plugins/available/battery.plugin.bash | 4 +-- .../{dirs.plugins.bash => dirs.plugin.bash} | 19 ++++++++++-- plugins/available/extract.plugin.bash | 2 ++ .../available/{fasd.bash => fasd.plugin.bash} | 3 +- .../{git.plugins.bash => git.plugin.bash} | 27 ++++++++++++++--- .../{hg.plugins.bash => hg.plugin.bash} | 13 ++++++++- ...pt.plugins.bash => javascript.plugin.bash} | 17 ++++++++--- ...jekyll.plugins.bash => jekyll.plugin.bash} | 29 ++++++++++++++++--- plugins/available/latex.plugin.bash | 3 +- .../{nginx.plugins.bash => nginx.plugin.bash} | 15 +++++++++- plugins/available/nvm.plugin.bash | 7 +++++ plugins/available/osx.plugin.bash | 14 ++++++++- plugins/available/python.plugin.bash | 3 +- plugins/available/rbenv.plugin.bash | 8 +++-- plugins/available/ruby.plugin.bash | 8 ++++- plugins/available/rvm.plugin.bash | 6 ++-- plugins/available/ssh.plugin.bash | 19 ++++++++++++ plugins/available/ssh.plugins.bash | 9 ------ plugins/available/subversion.plugin.bash | 17 +++++++++-- plugins/available/tmux.plugin.bash | 4 +++ plugins/available/tmuxinator.plugin.bash | 3 +- ...grant.plugins.bash => vagrant.plugin.bash} | 4 ++- plugins/available/virtualenv.plugin.bash | 19 +++++++++--- plugins/available/{z.bash => z.plugin.bash} | 6 ++-- ...env.plugins.bash => z_autoenv.plugin.bash} | 4 ++- 27 files changed, 214 insertions(+), 53 deletions(-) rename plugins/available/{_xterm.plugins.bash => _xterm.plugin.bash} (100%) mode change 100755 => 100644 plugins/available/base.plugin.bash mode change 100755 => 100644 plugins/available/battery.plugin.bash rename plugins/available/{dirs.plugins.bash => dirs.plugin.bash} (86%) mode change 100755 => 100644 rename plugins/available/{fasd.bash => fasd.plugin.bash} (99%) rename plugins/available/{git.plugins.bash => git.plugin.bash} (84%) rename plugins/available/{hg.plugins.bash => hg.plugin.bash} (53%) rename plugins/available/{javascript.plugins.bash => javascript.plugin.bash} (68%) rename plugins/available/{jekyll.plugins.bash => jekyll.plugin.bash} (92%) rename plugins/available/{nginx.plugins.bash => nginx.plugin.bash} (82%) create mode 100644 plugins/available/ssh.plugin.bash delete mode 100644 plugins/available/ssh.plugins.bash rename plugins/available/{vagrant.plugins.bash => vagrant.plugin.bash} (94%) rename plugins/available/{z.bash => z.plugin.bash} (96%) rename plugins/available/{z_autoenv.plugins.bash => z_autoenv.plugin.bash} (88%) diff --git a/plugins/available/_xterm.plugins.bash b/plugins/available/_xterm.plugin.bash similarity index 100% rename from plugins/available/_xterm.plugins.bash rename to plugins/available/_xterm.plugin.bash diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash old mode 100755 new mode 100644 index 85f15ad..8c5f24f --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -1,7 +1,5 @@ -#!/usr/bin/env bash - cite about-plugin -about-plugin generic and miscellaneous tools +about-plugin miscellaneous tools ips () { diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash old mode 100755 new mode 100644 index 4c0e380..1bfba2c --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -1,7 +1,5 @@ -#!/usr/bin/env bash - cite about-plugin -about-plugin query and 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%)' diff --git a/plugins/available/dirs.plugins.bash b/plugins/available/dirs.plugin.bash old mode 100755 new mode 100644 similarity index 86% rename from plugins/available/dirs.plugins.bash rename to plugins/available/dirs.plugin.bash index e03ccf5..d80b354 --- a/plugins/available/dirs.plugins.bash +++ b/plugins/available/dirs.plugin.bash @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # Directory stack navigation: # # Add to stack with: pu /path/to/directory @@ -7,6 +5,9 @@ # Show stack with: d # Jump to location by number. +cite about-plugin +about-plugin directory stack navigation + # Show directory stack alias d="dirs -v -l" @@ -31,6 +32,9 @@ alias pu="pushd" alias po="popd" function dirs-help() { + about directory navigation alias usage + group dirs + echo "Directory Navigation Alias Usage" echo echo "Use the power of directory stacking to move" @@ -64,10 +68,18 @@ fi alias L='cat ~/.dirs' G () { # goes to distination dir otherwise , stay in the dir + about goes to destination dir + param 1: directory + example '$ G ..' + group dirs + cd ${1:-$(pwd)} ; } S () { # SAVE a BOOKMARK + about save a bookmark + group dirs + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; @@ -75,6 +87,9 @@ S () { # SAVE a BOOKMARK } R () { # remove a BOOKMARK + about remove a bookmark + group dirs + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; } diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index 1c3e9b1..fbd969c 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -1,3 +1,5 @@ +cite about-plugin +about-plugin one command to extract them all... extract () { if [ $# -ne 1 ] then diff --git a/plugins/available/fasd.bash b/plugins/available/fasd.plugin.bash similarity index 99% rename from plugins/available/fasd.bash rename to plugins/available/fasd.plugin.bash index 984f630..220460c 100755 --- a/plugins/available/fasd.bash +++ b/plugins/available/fasd.plugin.bash @@ -584,7 +584,8 @@ fasd [-A|-D] [paths ...] fasd --init env case $- in - *i*) alias fasd=$BASH_IT'/plugins/enabled/fasd.bash' + *i*) cite about-plugin + about-plugin navigate 'frecently' used files and directories eval "$(fasd --init auto)" ;; *) # assume being executed as an executable diff --git a/plugins/available/git.plugins.bash b/plugins/available/git.plugin.bash similarity index 84% rename from plugins/available/git.plugins.bash rename to plugins/available/git.plugin.bash index 41b031f..15876de 100644 --- a/plugins/available/git.plugins.bash +++ b/plugins/available/git.plugin.bash @@ -1,26 +1,42 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin git helper functions function git_remote { + about 'adds remote $GIT_HOSTING:$1 to current repo' + 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 + 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 + 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 echo "$1" >> .git/info/exclude } # get a quick overview for your git repo function git_info() { + about overview for your git repo + group git + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then # print informations echo "git repo overview" @@ -29,7 +45,7 @@ function git_info() { # print all remotes and thier details for remote in $(git remote show); do - echo $remote: + echo $remote: git remote show $remote echo done @@ -43,10 +59,10 @@ function git_info() { fi # print at least 5 last log entries - echo + echo echo "log:" git log -5 --oneline - echo + echo else echo "you're currently not in a git repository" @@ -55,6 +71,9 @@ function git_info() { } function git_stats { + about display stats per author + group git + # awesome work from https://github.com/esc/git-stats # including some modifications diff --git a/plugins/available/hg.plugins.bash b/plugins/available/hg.plugin.bash similarity index 53% rename from plugins/available/hg.plugins.bash rename to plugins/available/hg.plugin.bash index 33c81d3..97182fb 100644 --- a/plugins/available/hg.plugins.bash +++ b/plugins/available/hg.plugin.bash @@ -1,14 +1,25 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin hg helper functions + hg_dirty() { + about displays dirty status of hg repository + group hg + hg status --no-color 2> /dev/null \ | awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \ | sort | uniq | head -c1 } hg_in_repo() { + about 'determine if pwd is an hg repo' + group hg + [[ `hg branch 2> /dev/null` ]] && echo 'on ' } hg_branch() { + about display current hg branch + group hg + hg branch 2> /dev/null } diff --git a/plugins/available/javascript.plugins.bash b/plugins/available/javascript.plugin.bash similarity index 68% rename from plugins/available/javascript.plugins.bash rename to plugins/available/javascript.plugin.bash index 76a7e13..40ee20e 100644 --- a/plugins/available/javascript.plugins.bash +++ b/plugins/available/javascript.plugin.bash @@ -1,16 +1,22 @@ -#!/usr/bin/env bash -# -# The install directory is hard-coded. TOOD: allow the directory to be specified on the command line. -# +# 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 [[ -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 + 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 + if [ -z "$1" ] then version=$JQUERY_VERSION_NUMBER @@ -21,6 +27,9 @@ function jquery_install { } function jquery_ui_install { + about 'download jquery_us.js into public/javascripts' + group javascripts + if [ -z "$1" ] then version=$JQUERY_UI_VERSION_NUMBER diff --git a/plugins/available/jekyll.plugins.bash b/plugins/available/jekyll.plugin.bash similarity index 92% rename from plugins/available/jekyll.plugins.bash rename to plugins/available/jekyll.plugin.bash index 74e3cb1..2edd79e 100644 --- a/plugins/available/jekyll.plugins.bash +++ b/plugins/available/jekyll.plugin.bash @@ -1,6 +1,11 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin manage your jekyll site editpost() { + about edit a post + param 1: site directory + group jekyll + unset SITE if [ -z "$1" ] then @@ -35,11 +40,11 @@ editpost() { DATE=`echo $POST | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"` TITLE=`cat $POST | grep -oE "title: (.+)"` TITLE=`echo $TITLE | sed 's/title: //'` - echo "$COUNTER) $DATE $TITLE" >> "$TMPFILE" + echo "$COUNTER) $DATE $TITLE" >> "$TMPFILE" POSTS[$COUNTER]=$POST COUNTER=`expr $COUNTER + 1` done - less $TMPFILE + less $TMPFILE read -p "Number of post to edit: " POST_TO_EDIT if [ -z "$JEKYLL_EDITOR" ] then @@ -50,6 +55,10 @@ editpost() { } newpost() { + about create a new post + param 1: site directory + group jekyll + unset SITE if [ -z "$1" ] then @@ -93,7 +102,7 @@ newpost() { then select OPTION in $OPTIONS do - if [[ $OPTION = "Text" ]] + if [[ $OPTION = "Text" ]] then POST_TYPE="Text" break @@ -257,6 +266,10 @@ newpost() { } function testsite() { + about launches local jekyll server + param 1: site directory + group jekyll + unset SITE if [ -z "$1" ] then @@ -285,6 +298,10 @@ function testsite() { } function buildsite() { + about builds site + param 1: site directory + group jekyll + unset SITE if [ -z "$1" ] then @@ -314,6 +331,10 @@ function buildsite() { } function deploysite() { + about 'rsyncs site to remote host' + param 1: site directory + group jekyll + unset SITE if [ -z "$1" ] then diff --git a/plugins/available/latex.plugin.bash b/plugins/available/latex.plugin.bash index c2ce9dd..ff9316a 100644 --- a/plugins/available/latex.plugin.bash +++ b/plugins/available/latex.plugin.bash @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin use mactex # add mactex to the path if its present MACTEX_PATH=/usr/local/texlive/2009/bin/universal-darwin diff --git a/plugins/available/nginx.plugins.bash b/plugins/available/nginx.plugin.bash similarity index 82% rename from plugins/available/nginx.plugins.bash rename to plugins/available/nginx.plugin.bash index 6dd86dd..bdee127 100644 --- a/plugins/available/nginx.plugins.bash +++ b/plugins/available/nginx.plugin.bash @@ -1,6 +1,10 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin manage your nginx service function nginx_reload() { + about reload your nginx config + group nginx + FILE="${NGINX_PATH}/logs/nginx.pid" if [ -e $FILE ]; then echo "Reloading NGINX..." @@ -13,6 +17,9 @@ function nginx_reload() { } function nginx_stop() { + about stop nginx + group nginx + FILE="${NGINX_PATH}/logs/nginx.pid" if [ -e $FILE ]; then echo "Stopping NGINX..." @@ -25,6 +32,9 @@ function nginx_stop() { } function nginx_start() { + about start nginx + group nginx + FILE="${NGINX_PATH}/sbin/nginx" if [ -e $FILE ]; then echo "Starting NGINX..." @@ -35,6 +45,9 @@ function nginx_start() { } function nginx_restart() { + about restart nginx + group nginx + FILE="${NGINX_PATH}/logs/nginx.pid" if [ -e $FILE ]; then echo "Stopping NGINX..." diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index 3f489dd..0e51e0a 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -5,6 +5,9 @@ # Implemented by Tim Caswell # with much bash help from Matthew Ranney +cite about-plugin +about-plugin 'node version manager, as a bash function' + export NVM_DIR=$HOME/.nvm if [ ! -d "$NVM_DIR" ]; then @@ -75,6 +78,10 @@ print_versions() nvm() { + about 'Node Version Manager' + param '1: command, see nvm help' + group nvm + if [ $# -lt 1 ]; then nvm help return diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 7d3d077..ade109a 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -1,6 +1,10 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'osx-specific functions' function tab() { + about 'opens a new terminal tab' + group osx + osascript 2>/dev/null <> ~/.ssh/config +} + +function sshlist() { + about 'list hosts defined in ssh config' + group 'ssh' + + awk '$1 ~ /Host$/ { print $2 }' ~/.ssh/config +} diff --git a/plugins/available/ssh.plugins.bash b/plugins/available/ssh.plugins.bash deleted file mode 100644 index 39718fb..0000000 --- a/plugins/available/ssh.plugins.bash +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -function add_ssh() { - echo -en "\n\nHost $1\n HostName $2\n User $3\n ServerAliveInterval 30\n ServerAliveCountMax 120" >> ~/.ssh/config -} - -function sshlist() { - awk '$1 ~ /Host$/ { print $2 }' ~/.ssh/config -} diff --git a/plugins/available/subversion.plugin.bash b/plugins/available/subversion.plugin.bash index a7fe941..bdb3edf 100644 --- a/plugins/available/subversion.plugin.bash +++ b/plugins/available/subversion.plugin.bash @@ -1,8 +1,21 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'svn helper functions' + rm_svn(){ + about 'remove ".svn" files from directory' + param '1: directory to search for files' + group 'svn' + + if [ -z "$1" ]; then + reference rm_svn + return + fi find $1 -name .svn -print0 | xargs -0 rm -rf } svn_add(){ - svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add + about 'add to svn repo' + group 'svn' + + svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add } diff --git a/plugins/available/tmux.plugin.bash b/plugins/available/tmux.plugin.bash index ff35336..f7ee337 100644 --- a/plugins/available/tmux.plugin.bash +++ b/plugins/available/tmux.plugin.bash @@ -1,2 +1,6 @@ # make sure that tmux is launched in 256 color mode + +cite about-plugin +about-plugin 'make sure that tmux is launched in 256 color mode' + alias tmux="TERM=xterm-256color tmux" diff --git a/plugins/available/tmuxinator.plugin.bash b/plugins/available/tmuxinator.plugin.bash index cf5500d..a011435 100644 --- a/plugins/available/tmuxinator.plugin.bash +++ b/plugins/available/tmuxinator.plugin.bash @@ -1,3 +1,4 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'sources tmuxinator script if available' [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && . $HOME/.tmuxinator/scripts/tmuxinator diff --git a/plugins/available/vagrant.plugins.bash b/plugins/available/vagrant.plugin.bash similarity index 94% rename from plugins/available/vagrant.plugins.bash rename to plugins/available/vagrant.plugin.bash index 3131744..aa223e7 100644 --- a/plugins/available/vagrant.plugins.bash +++ b/plugins/available/vagrant.plugin.bash @@ -1,4 +1,6 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'set up vagrant autocompletion' + _vagrant() { cur="${COMP_WORDS[COMP_CWORD]}" diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index ba27c76..b8c4609 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -1,19 +1,30 @@ -#!/usr/bin/env bash - # make sure virtualenvwrapper is enabled if available + +cite about-plugin +about-plugin 'virtualenvwrapper helper functions' + [[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh -# create a new virtualenv for this directory + function mkvenv { + about 'create a new virtualenv for this directory' + group virtualenv + cwd=`basename \`pwd\`` mkvirtualenv --no-site-packages --distribute $cwd } -# create a new virtualenv for the branch you're currently in + function mkvbranch { + about 'create a new virtualenv for the current branch' + group virtualenv + mkvirtualenv --no-site-packages --distribute "$(basename `pwd`)@$(git_prompt_info)" } function wovbranch { + about 'sets workon branch' + group virtualenv + workon "$(basename `pwd`)@$(git_prompt_info)" } diff --git a/plugins/available/z.bash b/plugins/available/z.plugin.bash similarity index 96% rename from plugins/available/z.bash rename to plugins/available/z.plugin.bash index ef3e3d9..7ffe8fb 100644 --- a/plugins/available/z.bash +++ b/plugins/available/z.plugin.bash @@ -1,7 +1,7 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'maintains a jump-list of the directories you actually use' +about-plugin ' z is DEPRECATED, use fasd instead' -# maintains a jump-list of the directories you actually use -# # INSTALL: # * put something like this in your .bashrc: # . /path/to/z.sh diff --git a/plugins/available/z_autoenv.plugins.bash b/plugins/available/z_autoenv.plugin.bash similarity index 88% rename from plugins/available/z_autoenv.plugins.bash rename to plugins/available/z_autoenv.plugin.bash index 04efa85..dd1aec1 100644 --- a/plugins/available/z_autoenv.plugins.bash +++ b/plugins/available/z_autoenv.plugin.bash @@ -1,4 +1,6 @@ -#!/usr/bin/env bash +cite about-plugin +about-plugin 'source into environment when cding to directories' + if [[ -n "${ZSH_VERSION}" ]] then __array_offset=0 else __array_offset=1 -- 2.17.1