Skip to content

Commit

Permalink
alias-help()
Browse files Browse the repository at this point in the history
  • Loading branch information
erichs authored and nwinkler committed May 22, 2012
1 parent 17aaa9c commit 961c914
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions lib/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ 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 ()
{
cite _about _param _example
cite _about _param _example
_about 'summarizes available bash_it components'
_param '1: subdirectory'
_param '2: preposition'
Expand Down Expand Up @@ -92,7 +92,7 @@ disable-plugin ()
param '1: plugin name'
example '$ disable-plugin rvm'
group 'lib'

_disable-thing "plugins" "plugin" $1
}

Expand All @@ -102,7 +102,7 @@ disable-alias ()
param '1: alias name'
example '$ disable-alias git'
group 'lib'

_disable-thing "aliases" "alias" $1
}

Expand All @@ -112,23 +112,23 @@ disable-completion ()
param '1: completion name'
example '$ disable-completion git'
group 'lib'

_disable-thing "completion" "completion" $1
}

_disable-thing ()
{
cite _about _param _example
cite _about _param _example
_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"
subdirectory="$1"
file_type="$2"
file_entity="$3"

if [ -z "$file_entity" ]; then
reference "disable-$file_type"
return
Expand Down Expand Up @@ -161,7 +161,7 @@ enable-plugin ()
param '1: plugin name'
example '$ enable-plugin rvm'
group 'lib'

_enable-thing "plugins" "plugin" $1
}

Expand All @@ -171,7 +171,7 @@ enable-alias ()
param '1: alias name'
example '$ enable-alias git'
group 'lib'

_enable-thing "aliases" "alias" $1
}

Expand All @@ -181,23 +181,23 @@ enable-completion ()
param '1: completion name'
example '$ enable-completion git'
group 'lib'

_enable-thing "completion" "completion" $1
}

_enable-thing ()
{
cite _about _param _example
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"
subdirectory="$1"
file_type="$2"
file_entity="$3"

if [ -z "$file_entity" ]; then
reference "enable-$file_type"
return
Expand Down Expand Up @@ -231,6 +231,27 @@ _enable-thing ()
printf '%s\n' "$file_entity enabled."
}

alias-help ()
{
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/enabled/$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
}

plugins-help ()
{
about 'summarize all functions defined by enabled bash-it plugins'
Expand Down

0 comments on commit 961c914

Please sign in to comment.