Permalink
Browse files

update plugin management

  • Loading branch information...
1 parent 8051a85 commit 08e439c4f06ed3818d68961afd40e695a0d5fae9 @erichs erichs committed May 13, 2012
View
@@ -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,57 +47,88 @@ 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'
- 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'
@@ -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)
@@ -1,37 +1,37 @@
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)
@@ -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,72 +69,72 @@ 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
}
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}
@@ -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=''
Oops, something went wrong.

0 comments on commit 08e439c

Please sign in to comment.