update plugin management

pull/134/head
Erich Smith 2012-05-13 08:37:31 -04:00
parent 8051a8520e
commit 08e439c4f0
18 changed files with 198 additions and 167 deletions

View File

@ -29,10 +29,10 @@ function reload_plugins() {
_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
@ -47,18 +47,66 @@ show_plugins ()
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'
if [ -z "$1" ]; then
reference disable_plugin
return
fi
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
printf '%s\n' "$1 disabled."
}
enable-plugin ()
{
about 'enables bash_it plugin'
param '1: plugin name'
example '$ enable_plugin rvm'
group 'lib'
if [ -z "$1" ]; then
reference enable_plugin
return
fi
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.'
@ -72,32 +120,15 @@ enable_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.'
}
disable_plugin ()
{
about disables bash_it plugin
param 1: plugin name
example '$ disable_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.'
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."
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'
@ -112,8 +143,8 @@ plugins-help ()
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)

View File

@ -1,26 +1,26 @@
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}"
}
@ -28,10 +28,10 @@ myip ()
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)
@ -41,12 +41,12 @@ pickfrom ()
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"
@ -55,10 +55,10 @@ 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
@ -69,62 +69,62 @@ pmdown ()
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
@ -132,9 +132,9 @@ banish-cookies ()
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
@ -153,10 +153,10 @@ usage ()
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
@ -166,19 +166,19 @@ t ()
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}

View File

@ -1,9 +1,9 @@
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
@ -69,8 +69,8 @@ battery_percentage(){
}
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='▸'

View File

@ -4,10 +4,10 @@ cite about-plugin
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
@ -27,7 +27,7 @@ function browser() {
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
@ -64,7 +64,7 @@ EOT`
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

View File

@ -6,7 +6,7 @@
# 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"
@ -32,8 +32,8 @@ alias pu="pushd"
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
@ -68,17 +68,17 @@ fi
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;
@ -87,8 +87,8 @@ S () { # SAVE a BOOKMARK
}
R () { # remove a BOOKMARK
about remove a bookmark
group dirs
about 'remove a bookmark'
group 'dirs'
sed "/$@/d" ~/.dirs > ~/.dirs1;
\mv ~/.dirs1 ~/.dirs;

View File

@ -1,5 +1,5 @@
cite about-plugin
about-plugin one command to extract them all...
about-plugin 'one command to extract them all...'
extract () {
if [ $# -ne 1 ]
then

View File

@ -585,7 +585,7 @@ fasd --init env
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

View File

@ -1,17 +1,17 @@
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
@ -19,23 +19,23 @@ function git_first_push {
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
@ -71,8 +71,8 @@ function git_info() {
}
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

View File

@ -1,9 +1,9 @@
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 "!" }' \
@ -12,14 +12,14 @@ hg_dirty() {
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
}

View File

@ -1,21 +1,21 @@
# 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
@ -28,7 +28,7 @@ function jquery_install {
function jquery_ui_install {
about 'download jquery_us.js into public/javascripts'
group javascripts
group 'javascripts'
if [ -z "$1" ]
then

View File

@ -1,10 +1,10 @@
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" ]
@ -55,9 +55,9 @@ editpost() {
}
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" ]
@ -266,9 +266,9 @@ newpost() {
}
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" ]
@ -298,9 +298,9 @@ function testsite() {
}
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" ]
@ -332,8 +332,8 @@ function buildsite() {
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" ]

View File

@ -1,5 +1,5 @@
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

View File

@ -1,9 +1,9 @@
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
@ -17,8 +17,8 @@ function nginx_reload() {
}
function nginx_stop() {
about stop nginx
group nginx
about 'stop nginx'
group 'nginx'
FILE="${NGINX_PATH}/logs/nginx.pid"
if [ -e $FILE ]; then
@ -32,8 +32,8 @@ function nginx_stop() {
}
function nginx_start() {
about start nginx
group nginx
about 'start nginx'
group 'nginx'
FILE="${NGINX_PATH}/sbin/nginx"
if [ -e $FILE ]; then
@ -45,8 +45,8 @@ function nginx_start() {
}
function nginx_restart() {
about restart nginx
group nginx
about 'restart nginx'
group 'nginx'
FILE="${NGINX_PATH}/logs/nginx.pid"
if [ -e $FILE ]; then

View File

@ -80,7 +80,7 @@ nvm()
{
about 'Node Version Manager'
param '1: command, see nvm help'
group nvm
group 'nvm'
if [ $# -lt 1 ]; then
nvm help

View File

@ -3,7 +3,7 @@ about-plugin 'osx-specific functions'
function tab() {
about 'opens a new terminal tab'
group osx
group 'osx'
osascript 2>/dev/null <<EOF
tell application "System Events"
@ -22,7 +22,7 @@ function dock-switch() {
about 'switch dock between 2d and 3d'
param '1: "2d" or "3d"'
example '$ dock-switch 2d'
group osx
group 'osx'
if [ $(uname) = "Darwin" ]; then

View File

@ -1,5 +1,5 @@
cite about-plugin
about-plugin '"alias "http" to SimpleHTTPServer'
about-plugin 'alias "http" to SimpleHTTPServer'
if [ $(uname) = "Linux" ]
then

View File

@ -4,7 +4,7 @@ about-plugin 'adds "remove_gem" function'
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
}

View File

@ -8,7 +8,7 @@ about-plugin 'virtualenvwrapper helper functions'
function mkvenv {
about 'create a new virtualenv for this directory'
group virtualenv
group 'virtualenv'
cwd=`basename \`pwd\``
mkvirtualenv --no-site-packages --distribute $cwd
@ -17,14 +17,14 @@ function mkvenv {
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)"
}