Merge pull request #139 from nwinkler/enable-disable-aliases-completions
Enable/Disable for aliases and completionspull/129/merge
commit
98fbc2933b
11
README.md
11
README.md
|
|
@ -20,11 +20,12 @@ This is to set up the `.jekyllconfig` file, which stores info necessary to use t
|
|||
## Help Screens
|
||||
|
||||
```
|
||||
bash-it (will show all the help commands)
|
||||
aliases-help
|
||||
rails-help
|
||||
git-help
|
||||
plugins-help
|
||||
bash-it show aliases # shows installed and available aliases
|
||||
bash-it show completions # shows installed and available completions
|
||||
bash-it show plugins # shows installed and available plugins
|
||||
bash-it help aliases # shows help for installed aliases
|
||||
bash-it help completions # shows help for installed completions
|
||||
bash-it help plugins # shows help for installed plugins
|
||||
```
|
||||
|
||||
## Your Custom scripts, aliases, and functions
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'ruby bundler'
|
||||
|
||||
# Bundler Commands
|
||||
alias be="bundle exec"
|
||||
alias bi="bundle install"
|
||||
alias bl="bundle list"
|
||||
alias bu="bundle update"
|
||||
alias bp="bundle package"
|
||||
|
||||
|
||||
function bundler-help() {
|
||||
echo "Bundler Aliases Usage"
|
||||
echo
|
||||
echo " be = bundle exec"
|
||||
echo " bi = bundle install"
|
||||
echo " bl = bundle list"
|
||||
echo " bu = bundle update"
|
||||
echo " bp = bundle package"
|
||||
echo
|
||||
}
|
||||
|
||||
alias be='bundle exec'
|
||||
alias bi='bundle install'
|
||||
alias bl='bundle list'
|
||||
alias bu='bundle update'
|
||||
alias bp='bundle package'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'emacs editor'
|
||||
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
|
|
@ -6,6 +7,6 @@ case $OSTYPE in
|
|||
alias e='emacsclient -n'
|
||||
;;
|
||||
darwin*)
|
||||
alias em="open -a emacs"
|
||||
alias em='open -a emacs'
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite about-alias
|
||||
about-alias 'general aliases'
|
||||
|
||||
# List directory contents
|
||||
alias sl=ls
|
||||
|
|
@ -27,20 +28,20 @@ alias cls='clear'
|
|||
alias edit="$EDITOR"
|
||||
alias pager="$PAGER"
|
||||
|
||||
alias q="exit"
|
||||
alias q='exit'
|
||||
|
||||
alias irc="$IRC_CLIENT"
|
||||
|
||||
alias rb="ruby"
|
||||
alias rb='ruby'
|
||||
|
||||
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
||||
|
||||
alias piano="pianobar"
|
||||
alias piano='pianobar'
|
||||
|
||||
alias ..='cd ..' # Go up one directory
|
||||
alias ...='cd ../..' # Go up two directories
|
||||
alias ....='cd ../../..' # Go up two directories
|
||||
alias -- -="cd -" # Go back
|
||||
alias -- -='cd -' # Go back
|
||||
|
||||
# Shell History
|
||||
alias h='history'
|
||||
|
|
@ -53,30 +54,4 @@ fi
|
|||
|
||||
# Directory
|
||||
alias md='mkdir -p'
|
||||
alias rd=rmdir
|
||||
|
||||
function aliases-help() {
|
||||
echo "Generic Alias Usage"
|
||||
echo
|
||||
echo " sl = ls"
|
||||
echo " ls = ls -G"
|
||||
echo " la = ls -AF"
|
||||
echo " ll = ls -al"
|
||||
echo " l = ls -a"
|
||||
echo " c/k/cls = clear"
|
||||
echo " .. = cd .."
|
||||
echo " ... = cd ../.."
|
||||
echo " - = cd -"
|
||||
echo " h = history"
|
||||
echo " md = mkdir -p"
|
||||
echo " rd = rmdir"
|
||||
echo " editor = $EDITOR"
|
||||
echo " pager = $PAGER"
|
||||
echo " piano = pianobar"
|
||||
echo " q = exit"
|
||||
echo " irc = $IRC_CLIENT"
|
||||
echo " md = mkdir -p"
|
||||
echo " rd = rmdir"
|
||||
echo " rb = ruby"
|
||||
echo
|
||||
}
|
||||
alias rd='rmdir'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'common git abbreviations'
|
||||
|
||||
# Aliases
|
||||
alias gcl='git clone'
|
||||
|
|
@ -38,36 +39,3 @@ case $OSTYPE in
|
|||
alias gd='git diff'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
function git-help() {
|
||||
echo "Git Custom Aliases Usage"
|
||||
echo
|
||||
echo " gcl = git clone"
|
||||
echo " g = git"
|
||||
echo " get = git"
|
||||
echo " ga = git add"
|
||||
echo " gall = git add ."
|
||||
echo " gst/gs = git status"
|
||||
echo " gss = git status -s"
|
||||
echo " gl = git pull"
|
||||
echo " gup = git fetch && git rebase"
|
||||
echo " gp = git push"
|
||||
echo " gd = git diff | mate"
|
||||
echo " gdv = git diff -w \"$@\" | vim -R -"
|
||||
echo " gc = git commit -v"
|
||||
echo " gca = git commit -v -a"
|
||||
echo " gci = git commit --interactive"
|
||||
echo " gb = git branch"
|
||||
echo " gba = git branch -a"
|
||||
echo " gcount = git shortlog -sn"
|
||||
echo " gcp = git cherry-pick"
|
||||
echo " gco = git checkout"
|
||||
echo " gexport = git git archive --format zip --output"
|
||||
echo " gdel = git branch -D"
|
||||
echo " gpo = git push origin"
|
||||
echo " gmu = git fetch origin -v; git fetch upstream -v; git merge upstream/master"
|
||||
echo " gll = git log --graph --pretty=oneline --abbrev-commit"
|
||||
echo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'heroku task abbreviations'
|
||||
|
||||
# heroku
|
||||
alias h='heroku'
|
||||
|
|
@ -31,26 +32,3 @@ alias hc='heroku config'
|
|||
alias hca='heroku config:add'
|
||||
alias hcr='heroku config:remove'
|
||||
alias hcc='heroku config:clear'
|
||||
|
||||
function heroku-help() {
|
||||
echo "Heroku Aliases Usage"
|
||||
echo
|
||||
echo " h = heroku"
|
||||
echo " hl = heroku list"
|
||||
echo " hi = heroku info"
|
||||
echo " ho = heroku open"
|
||||
echo " hd = heroku dynos"
|
||||
echo " hw = heroku workers"
|
||||
echo " hr = heroku rake"
|
||||
echo " hcon = heroku console"
|
||||
echo " hnew = heroku create"
|
||||
echo " hrestart = heroku restart"
|
||||
echo " hlog = heroku logs"
|
||||
echo " hon = heroku maintenance:on"
|
||||
echo " hoff = heroku maintenance:off"
|
||||
echo " hc = heroku config"
|
||||
echo " hca = heroku config:add"
|
||||
echo " hcr = heroku config:remove"
|
||||
echo " hcc = heroku config:clear"
|
||||
echo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'mercurial abbreviations'
|
||||
|
||||
alias hs='hg status'
|
||||
alias hsum='hg summary'
|
||||
alias hcm='hg commit -m'
|
||||
|
||||
function hg-help() {
|
||||
echo "Mercurial Alias Help"
|
||||
echo
|
||||
echo " hs = hg status"
|
||||
echo " hsum = hg summary"
|
||||
echo " hcm = hg commit -m"
|
||||
echo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,13 @@
|
|||
# Some aliases for Homebrew
|
||||
|
||||
alias bup="brew update && brew upgrade"
|
||||
alias bout="brew outdated"
|
||||
alias bin="brew install"
|
||||
alias brm="brew uninstall"
|
||||
alias bls="brew list"
|
||||
alias bsr="brew search"
|
||||
alias binf="brew info"
|
||||
alias bdr="brew doctor"
|
||||
cite 'about-alias'
|
||||
about-alias 'homebrew abbreviations'
|
||||
|
||||
function brew-help() {
|
||||
echo "Homebrew Alias Usage"
|
||||
echo
|
||||
echo "bup = brew update && brew upgrade"
|
||||
echo "bout = brew outdated"
|
||||
echo "bin = brew install"
|
||||
echo "brm = brew uninstall"
|
||||
echo "bls = brew list"
|
||||
echo "bsr = brew search"
|
||||
echo "binf = brew info"
|
||||
echo "bdr = brew doctor"
|
||||
echo
|
||||
}
|
||||
alias bup='brew update && brew upgrade'
|
||||
alias bout='brew outdated'
|
||||
alias bin='brew install'
|
||||
alias brm='brew uninstall'
|
||||
alias bls='brew list'
|
||||
alias bsr='brew search'
|
||||
alias binf='brew info'
|
||||
alias bdr='brew doctor'
|
||||
|
|
|
|||
|
|
@ -1,22 +1,11 @@
|
|||
alias mci="mvn clean install"
|
||||
alias mi="mvn install"
|
||||
alias mrprep="mvn release:prepare"
|
||||
alias mrperf="mvn release:perform"
|
||||
alias mrrb="mvn release:rollback"
|
||||
alias mdep="mvn dependency:tree"
|
||||
alias mpom="mvn help:effective-pom"
|
||||
alias mcisk="mci -Dmaven.test.skip=true"
|
||||
cite 'about-alias'
|
||||
about-alias 'maven abbreviations'
|
||||
|
||||
function maven-help() {
|
||||
echo "Maven Custom Aliases Usage"
|
||||
echo
|
||||
echo " mci = mvn clean install"
|
||||
echo " mi = mvn install"
|
||||
echo " mrprep = mvn release:prepare"
|
||||
echo " mrperf = mvn release:perform"
|
||||
echo " mrrb = mvn release:rollback"
|
||||
echo " mdep = mvn dependency:tree"
|
||||
echo " mpom = mvn help:effective-pom"
|
||||
echo " mcisk = mvn clean install -Dmaven.test.skip=true"
|
||||
echo
|
||||
}
|
||||
alias mci='mvn clean install'
|
||||
alias mi='mvn install'
|
||||
alias mrprep='mvn release:prepare'
|
||||
alias mrperf='mvn release:perform'
|
||||
alias mrrb='mvn release:rollback'
|
||||
alias mdep='mvn dependency:tree'
|
||||
alias mpom='mvn help:effective-pom'
|
||||
alias mcisk='mci -Dmaven.test.skip=true'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'osx-specific aliases'
|
||||
|
||||
# Desktop Programs
|
||||
alias fireworks="open -a '/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app'"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'rails abbreviations'
|
||||
|
||||
# Rails Commands
|
||||
alias r='rails'
|
||||
|
|
@ -19,24 +20,3 @@ alias restartapp='touch tmp/restart.txt'
|
|||
alias restart='touch tmp/restart.txt' # restart passenger
|
||||
alias devlog='tail -f log/development.log'
|
||||
alias taild='tail -f log/development.log' # tail dev log
|
||||
|
||||
function rails-help() {
|
||||
echo "Rails Aliases Usage"
|
||||
echo
|
||||
echo " r = rails"
|
||||
echo " rg = rails generate"
|
||||
echo " rs/ss = rails server"
|
||||
echo " ts = thin server"
|
||||
echo " rc/sc = rails console"
|
||||
echo " rn = rails new"
|
||||
echo " rd = rails dbconsole"
|
||||
echo " rp = rails plugin"
|
||||
echo " ra = rails application"
|
||||
echo " rd = rails destroy"
|
||||
echo " restartapp = touch tmp/restart.txt"
|
||||
echo " restart = touch tmp/restart.txt"
|
||||
echo " devlog = tail -f log/development.log"
|
||||
echo " taild = tail -f log/development.log"
|
||||
echo
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'textmate abbreviations'
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'todo.txt-cli abbreviations'
|
||||
|
||||
alias tls="$TODO ls"
|
||||
alias ta="$TODO a"
|
||||
alias trm="$TODO rm"
|
||||
alias tdo="$TODO do"
|
||||
alias tpri="$TODO pri"
|
||||
|
||||
todo-help() {
|
||||
echo
|
||||
echo "todo.txt-cli Custom Aliases Usage"
|
||||
echo
|
||||
echo " tls = $TODO ls"
|
||||
echo " ta = $TODO add"
|
||||
echo " trm = $TODO rm"
|
||||
echo " tdo = $TODO do"
|
||||
echo " tpri = $TODO pri"
|
||||
echo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
cite 'about-alias'
|
||||
about-alias 'vim abbreviations'
|
||||
|
||||
alias v='mvim --remote-tab'
|
||||
|
|
|
|||
23
bash_it.sh
23
bash_it.sh
|
|
@ -24,6 +24,9 @@ fi
|
|||
# Load composure first, so we support function metadata
|
||||
source "${BASH_IT}/lib/composure.sh"
|
||||
|
||||
# support 'plumbing' metadata
|
||||
cite _about _param _example _group _author _version
|
||||
|
||||
# Load colors first so they can be use in base theme
|
||||
source "${BASH_IT}/themes/colors.theme.bash"
|
||||
source "${BASH_IT}/themes/base.theme.bash"
|
||||
|
|
@ -72,23 +75,3 @@ if [ -e $HOME/.jekyllconfig ]
|
|||
then
|
||||
. $HOME/.jekyllconfig
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Custom Help
|
||||
|
||||
function bash-it() {
|
||||
echo "Welcome to Bash It!"
|
||||
echo
|
||||
echo "Here is a list of commands you can use to get help screens for specific pieces of Bash it:"
|
||||
echo
|
||||
echo " rails-help list out all aliases you can use with rails."
|
||||
echo " git-help list out all aliases you can use with git."
|
||||
echo " todo-help list out all aliases you can use with todo.txt-cli"
|
||||
echo " brew-help list out all aliases you can use with Homebrew"
|
||||
echo " aliases-help generic list of aliases."
|
||||
echo " plugins-help list out all functions you have installed with bash-it"
|
||||
echo " bash-it-plugins summarize bash-it plugins, and their installation status"
|
||||
echo " reference <function name> detailed help for a specific function"
|
||||
echo
|
||||
}
|
||||
|
|
|
|||
283
lib/helpers.bash
283
lib/helpers.bash
|
|
@ -1,11 +1,11 @@
|
|||
# Helper function loading various enable-able files
|
||||
function _load_bash_it_files() {
|
||||
file_type="$1"
|
||||
if [ ! -d "${BASH_IT}/${file_type}/enabled" ]
|
||||
subdirectory="$1"
|
||||
if [ ! -d "${BASH_IT}/${subdirectory}/enabled" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
FILES="${BASH_IT}/${file_type}/enabled/*.bash"
|
||||
FILES="${BASH_IT}/${subdirectory}/enabled/*.bash"
|
||||
for config_file in $FILES
|
||||
do
|
||||
if [ -e "${config_file}" ]; then
|
||||
|
|
@ -29,106 +29,285 @@ function reload_plugins() {
|
|||
_load_bash_it_files "plugins"
|
||||
}
|
||||
|
||||
bash-it-plugins ()
|
||||
bash-it ()
|
||||
{
|
||||
about 'summarizes available bash_it plugins'
|
||||
group 'lib'
|
||||
about 'bash-it help and maintenance'
|
||||
param '1: verb [one of: help | show | enable | disable ]'
|
||||
param '2: component type [one of: alias(es) | completion(s) | plugin(s) ]'
|
||||
param '3: specific component [optional]'
|
||||
example '$ bash-it show plugins'
|
||||
example '$ bash-it help aliases'
|
||||
example '$ bash-it enable plugin git'
|
||||
example '$ bash-it disable alias hg'
|
||||
typeset verb=${1:-}
|
||||
shift
|
||||
typeset component=${1:-}
|
||||
shift
|
||||
typeset func
|
||||
case $verb in
|
||||
show)
|
||||
func=_bash-it-$component;;
|
||||
enable)
|
||||
func=_enable-$component;;
|
||||
disable)
|
||||
func=_disable-$component;;
|
||||
help)
|
||||
func=_help-$component;;
|
||||
*)
|
||||
reference bash-it
|
||||
return;;
|
||||
esac
|
||||
|
||||
# pluralize component if necessary
|
||||
if ! _is_function $func; then
|
||||
if _is_function ${func}s; then
|
||||
func=${func}s
|
||||
else
|
||||
if _is_function ${func}es; then
|
||||
func=${func}es
|
||||
else
|
||||
echo "oops! $component is not a valid option!"
|
||||
reference bash-it
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
$func $*
|
||||
}
|
||||
|
||||
_is_function ()
|
||||
{
|
||||
_about 'sets $? to true if parameter is the name of a function'
|
||||
_param '1: name of alleged function'
|
||||
_group 'lib'
|
||||
[ -n "$(type -a $1 2>/dev/null | grep 'is a function')" ]
|
||||
}
|
||||
|
||||
_bash-it-aliases ()
|
||||
{
|
||||
_about 'summarizes available bash_it aliases'
|
||||
_group 'lib'
|
||||
|
||||
_bash-it-describe "aliases" "an" "alias" "Alias"
|
||||
}
|
||||
|
||||
_bash-it-completions ()
|
||||
{
|
||||
_about 'summarizes available bash_it completions'
|
||||
_group 'lib'
|
||||
|
||||
_bash-it-describe "completion" "a" "completion" "Completion"
|
||||
}
|
||||
|
||||
_bash-it-plugins ()
|
||||
{
|
||||
_about 'summarizes available bash_it plugins'
|
||||
_group 'lib'
|
||||
|
||||
_bash-it-describe "plugins" "a" "plugin" "Plugin"
|
||||
}
|
||||
|
||||
_bash-it-describe ()
|
||||
{
|
||||
_about 'summarizes available bash_it components'
|
||||
_param '1: subdirectory'
|
||||
_param '2: preposition'
|
||||
_param '3: file_type'
|
||||
_param '4: column_header'
|
||||
_example '$ _bash-it-describe "plugins" "a" "plugin" "Plugin"'
|
||||
|
||||
subdirectory="$1"
|
||||
preposition="$2"
|
||||
file_type="$3"
|
||||
column_header="$4"
|
||||
|
||||
typeset f
|
||||
typeset enabled
|
||||
printf "%-20s%-10s%s\n" 'Plugin' 'Enabled?' 'Description'
|
||||
for f in $BASH_IT/plugins/available/*.bash
|
||||
printf "%-20s%-10s%s\n" "$column_header" 'Enabled?' 'Description'
|
||||
for f in $BASH_IT/$subdirectory/available/*.bash
|
||||
do
|
||||
if [ -e $BASH_IT/plugins/enabled/$(basename $f) ]; then
|
||||
if [ -e $BASH_IT/$subdirectory/enabled/$(basename $f) ]; then
|
||||
enabled='x'
|
||||
else
|
||||
enabled=' '
|
||||
fi
|
||||
printf "%-20s%-10s%s\n" "$(basename $f | cut -d'.' -f1)" " [$enabled]" "$(cat $f | metafor about-plugin)"
|
||||
printf "%-20s%-10s%s\n" "$(basename $f | cut -d'.' -f1)" " [$enabled]" "$(cat $f | metafor about-$file_type)"
|
||||
done
|
||||
printf '\n%s\n' 'to enable a plugin, do:'
|
||||
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> -or- $ disable-plugin all'
|
||||
printf '\n%s\n' "to enable $preposition $file_type, do:"
|
||||
printf '%s\n' "$ bash-it enable $file_type <$file_type name> -or- $ bash-it enable $file_type all"
|
||||
printf '\n%s\n' "to disable $preposition $file_type, do:"
|
||||
printf '%s\n' "$ bash-it disable $file_type <$file_type name> -or- $ bash-it disable $file_type all"
|
||||
}
|
||||
|
||||
disable-plugin ()
|
||||
_disable-plugin ()
|
||||
{
|
||||
about 'disables bash_it plugin'
|
||||
param '1: plugin name'
|
||||
example '$ disable-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
|
||||
_disable-thing "plugins" "plugin" $1
|
||||
}
|
||||
|
||||
_disable-alias ()
|
||||
{
|
||||
_about 'disables bash_it alias'
|
||||
_param '1: alias name'
|
||||
_example '$ disable-alias git'
|
||||
_group 'lib'
|
||||
|
||||
_disable-thing "aliases" "alias" $1
|
||||
}
|
||||
|
||||
_disable-completion ()
|
||||
{
|
||||
_about 'disables bash_it completion'
|
||||
_param '1: completion name'
|
||||
_example '$ disable-completion git'
|
||||
_group 'lib'
|
||||
|
||||
_disable-thing "completion" "completion" $1
|
||||
}
|
||||
|
||||
_disable-thing ()
|
||||
{
|
||||
_about 'disables a bash_it component'
|
||||
_param '1: subdirectory'
|
||||
_param '2: file_type'
|
||||
_param '3: file_entity'
|
||||
_example '$ _disable-thing "plugins" "plugin" "ssh"'
|
||||
|
||||
subdirectory="$1"
|
||||
file_type="$2"
|
||||
file_entity="$3"
|
||||
|
||||
if [ -z "$file_entity" ]; then
|
||||
reference "disable-$file_type"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$1" = "all" ]; then
|
||||
typeset f plugin
|
||||
for f in $BASH_IT/plugins/available/*.bash
|
||||
if [ "$file_entity" = "all" ]; then
|
||||
typeset f $file_type
|
||||
for f in $BASH_IT/$subdirectory/available/*.bash
|
||||
do
|
||||
plugin=$(basename $f)
|
||||
if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
|
||||
rm $BASH_IT/plugins/enabled/$(basename $plugin)
|
||||
if [ -e $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
||||
rm $BASH_IT/$subdirectory/enabled/$(basename $plugin)
|
||||
fi
|
||||
done
|
||||
else
|
||||
typeset plugin=$(command 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.'
|
||||
typeset plugin=$(command ls $BASH_IT/$subdirectory/enabled/$file_entity.*bash 2>/dev/null | head -1)
|
||||
if [ -z "$plugin" ]; then
|
||||
printf '%s\n' "sorry, that does not appear to be an enabled $file_type."
|
||||
return
|
||||
fi
|
||||
rm $BASH_IT/plugins/enabled/$(basename $plugin)
|
||||
rm $BASH_IT/$subdirectory/enabled/$(basename $plugin)
|
||||
fi
|
||||
|
||||
printf '%s\n' "$1 disabled."
|
||||
printf '%s\n' "$file_entity disabled."
|
||||
}
|
||||
|
||||
enable-plugin ()
|
||||
_enable-plugin ()
|
||||
{
|
||||
about 'enables bash_it plugin'
|
||||
param '1: plugin name'
|
||||
example '$ enable-plugin rvm'
|
||||
group 'lib'
|
||||
_about 'enables bash_it plugin'
|
||||
_param '1: plugin name'
|
||||
_example '$ enable-plugin rvm'
|
||||
_group 'lib'
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
reference enable-plugin
|
||||
_enable-thing "plugins" "plugin" $1
|
||||
}
|
||||
|
||||
_enable-alias ()
|
||||
{
|
||||
_about 'enables bash_it alias'
|
||||
_param '1: alias name'
|
||||
_example '$ enable-alias git'
|
||||
_group 'lib'
|
||||
|
||||
_enable-thing "aliases" "alias" $1
|
||||
}
|
||||
|
||||
_enable-completion ()
|
||||
{
|
||||
_about 'enables bash_it completion'
|
||||
_param '1: completion name'
|
||||
_example '$ enable-completion git'
|
||||
_group 'lib'
|
||||
|
||||
_enable-thing "completion" "completion" $1
|
||||
}
|
||||
|
||||
_enable-thing ()
|
||||
{
|
||||
cite _about _param _example
|
||||
_about 'enables a bash_it component'
|
||||
_param '1: subdirectory'
|
||||
_param '2: file_type'
|
||||
_param '3: file_entity'
|
||||
_example '$ _enable-thing "plugins" "plugin" "ssh"'
|
||||
|
||||
subdirectory="$1"
|
||||
file_type="$2"
|
||||
file_entity="$3"
|
||||
|
||||
if [ -z "$file_entity" ]; then
|
||||
reference "enable-$file_type"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$1" = "all" ]; then
|
||||
typeset f plugin
|
||||
for f in $BASH_IT/plugins/available/*.bash
|
||||
if [ "$file_entity" = "all" ]; then
|
||||
typeset f $file_type
|
||||
for f in $BASH_IT/$subdirectory/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
|
||||
if [ ! -h $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
||||
ln -s $BASH_IT/$subdirectory/available/$plugin $BASH_IT/$subdirectory/enabled/$plugin
|
||||
fi
|
||||
done
|
||||
else
|
||||
typeset plugin=$(command ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)
|
||||
typeset plugin=$(command ls $BASH_IT/$subdirectory/available/$file_entity.*bash 2>/dev/null | head -1)
|
||||
if [ -z "$plugin" ]; then
|
||||
printf '%s\n' 'sorry, that does not appear to be an available plugin.'
|
||||
printf '%s\n' "sorry, that does not appear to be an available $file_type."
|
||||
return
|
||||
fi
|
||||
|
||||
plugin=$(basename $plugin)
|
||||
if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
|
||||
printf '%s\n' "$1 is already enabled."
|
||||
if [ -e $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
||||
printf '%s\n' "$file_entity is already enabled."
|
||||
return
|
||||
fi
|
||||
|
||||
ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin
|
||||
ln -s $BASH_IT/$subdirectory/available/$plugin $BASH_IT/$subdirectory/enabled/$plugin
|
||||
fi
|
||||
|
||||
printf '%s\n' "$1 enabled."
|
||||
printf '%s\n' "$file_entity enabled."
|
||||
}
|
||||
|
||||
plugins-help ()
|
||||
_help-aliases()
|
||||
{
|
||||
about 'summarize all functions defined by enabled bash-it plugins'
|
||||
group 'lib'
|
||||
_about 'shows help for all aliases, or a specific alias group'
|
||||
_param '1: optional alias group'
|
||||
_example '$ alias-help'
|
||||
_example '$ alias-help git'
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
cat $BASH_IT/aliases/available/$1.aliases.bash | metafor alias | sed "s/$/'/"
|
||||
else
|
||||
typeset f
|
||||
for f in $BASH_IT/aliases/enabled/*
|
||||
do
|
||||
typeset file=$(basename $f)
|
||||
printf '\n\n%s:\n' "${file%%.*}"
|
||||
# metafor() strips trailing quotes, restore them with sed..
|
||||
cat $f | metafor alias | sed "s/$/'/"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
_help-plugins()
|
||||
{
|
||||
_about 'summarize all functions defined by enabled bash-it plugins'
|
||||
_group 'lib'
|
||||
|
||||
# display a brief progress message...
|
||||
printf '%s' 'please wait, building help...'
|
||||
|
|
|
|||
Loading…
Reference in New Issue