Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Enable/Disable for aliases and completions #139

Merged
merged 9 commits into from

2 participants

@nwinkler
Owner

Refactored the enable/disable and summarize functionality to work for aliases and completions as well.

Fixed a minor issue with disable-plugin, when specifying an invalid plugin - the check didn't work.

Added a sample description using about-plugin in the general.aliases.bash file.

@erichs

What about making this 'about-alias', or 'about-aliases'?

Owner

Sure, good idea. Line 76 in lib/helpers.bash will need to be changed in that case as well. I'll make the change and push...

Owner

Done, added in the latest commit: SHA f71be20

@erichs
Owner

Good stuff!

You may also be interested in my speculative work here:

tswicegood#1

I'd be interested in your thoughts on that.

Your approach here is fairly DRY, which I like. It still proliferates {en,dis}able-{x..z}() functions, but keeps the copy/pasted code to a minimum.

+1 this gets my vote.

@erichs
Owner

Thanks!

Owner

lib/helpers.bash, line 58: 'summarizes available bash-it {insert better term here}'

_bash_it_describe() is a 'plumbing' function, as opposed to a 'porcelain' function, like bash-it-plugins(). Porcelain should use the standard metadata keywords, so those functions get picked up by glossary() and reference(). I'm thinking though, that Plumbing should avoid using the porcelain 'apidoc' metadata for the same reasons.

I think there's value in adding metadata to plumbing, but we might think about cite()ing a different set of keywords.

I like the underscore prefix, maybe we could run with that:

cite _about _param _example
_about 'summarizes available bash-it components'
_param '1: file type'
_param '2: preposition'
_param '3: command_suffix'
_param '4: column_header'
_example '$ _bash-it-describe "plugins" "a" "plugin" "Plugin"'

Owner

Agreed, makes sense. I have updated and pushed. At the same time, I have also cleaned up some of the parameters to make them consistent.

@nwinkler
Owner

Merged in @erichs changes from nwinkler2#1

@erichs
Owner

Good deal! Thanks, @nwinkler!

@erichs
Owner

@nwinkler, let me know what you think of the following: nwinkler2#2

@nwinkler
Owner

Merged your changes, @erichs, thanks!

@erichs
Owner

These commits extend the previous plugin metadata functionality to aliases and completions. They also introduce a git-like convention of separating 'plumbing' and 'porcelain' functionality.

We're proposing here that plumbing functions and metadata be prefixed with an underscore, like:

_plumbing_function ()
{ 
    _about 'for use with bash-it internals'
    _param '1: some parameter'
    :  # do something here
}

Using this convention means that bash-it internals will not get picked up by the bash-it help functions, which are 'porcelain'.

These commits also redefine bash-it() as a porcelain command that interfaces with @nwinkler's _describe() functions, the _enable/_disable() functions, and the _help() functions.

Usage is documented in the README.

@erichs
Owner

@tswicegood, any thoughts on this? Thanks in advance!

@nwinkler
Owner

@tswicegood - any updates on this? Do you think this is ready for inclusion?

@erichs erichs merged commit 98fbc29 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 21, 2012
  1. @nwinkler

    Extended enable/disable and describe functionality to work for aliase…

    nwinkler authored
    …s and completions as well.
  2. @nwinkler

    Changed meta info resolution to look for data based on the type, e.g.…

    nwinkler authored
    … about-plugin, about-alias, about-completion.
Commits on May 22, 2012
  1. @nwinkler
  2. @erichs @nwinkler

    add alias metadata, remove help()

    erichs authored nwinkler committed
  3. @erichs @nwinkler

    alias-help()

    erichs authored nwinkler committed
Commits on May 23, 2012
  1. @nwinkler

    Updated help

    nwinkler authored
  2. @nwinkler
Commits on May 24, 2012
  1. @erichs

    update README

    erichs authored
  2. @nwinkler
This page is out of date. Refresh to see the latest.
View
17 README.md
@@ -1,6 +1,6 @@
# Bash it
-**Bash it** is a mash up of my own bash commands and scripts, other bash stuff I have found.
+**Bash it** is a mash up of my own bash commands and scripts, other bash stuff I have found.
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh). :)
@@ -13,18 +13,19 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces
3. Edit your `~/.bash_profile` file in order to customize bash-it.
**NOTE:**
-The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll).
+The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll).
This is to set up the `.jekyllconfig` file, which stores info necessary to use the Jekyll plugin.
## 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
@@ -45,7 +46,7 @@ There are a few bash it themes. If you've created your own custom prompts, I'd
I think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, bash it is a framework for easily customizing your bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!**
-Send me a pull request and I'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when I merge your changes in.
+Send me a pull request and I'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when I merge your changes in.
Thanks, and happing bashing!
View
26 aliases/available/bundler.aliases.bash
@@ -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'
View
5 aliases/available/emacs.aliases.bash
@@ -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
View
39 aliases/available/general.aliases.bash
@@ -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'
View
36 aliases/available/git.aliases.bash
@@ -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
-}
View
26 aliases/available/heroku.aliases.bash
@@ -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
-}
View
12 aliases/available/hg.aliases.bash
@@ -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
-}
View
31 aliases/available/homebrew.aliases.bash
@@ -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'
View
31 aliases/available/maven.aliases.bash
@@ -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'
View
3  aliases/available/osx.aliases.bash
@@ -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'"
View
24 aliases/available/rails.aliases.bash
@@ -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
-}
-
View
3  aliases/available/textmate.aliases.bash
@@ -1,4 +1,5 @@
-#!/usr/bin/env bash
+cite 'about-alias'
+about-alias 'textmate abbreviations'
case $OSTYPE in
darwin*)
View
15 aliases/available/todo.txt-cli.aliases.bash
@@ -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
-}
View
3  aliases/available/vim.aliases.bash
@@ -1,3 +1,4 @@
-#!/usr/bin/env bash
+cite 'about-alias'
+about-alias 'vim abbreviations'
alias v='mvim --remote-tab'
View
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
-}
View
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'
+
+ _disable-thing "plugins" "plugin" $1
+}
- if [ -z "$1" ]; then
- reference disable-plugin
+_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'
+
+ _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
+}
- if [ -z "$1" ]; then
- reference enable-plugin
+_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...'
Something went wrong with that request. Please try again.