Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

consider pulling these into your PR #139 #1

Closed
wants to merge 5 commits into from

3 participants

@erichs

alias-help treats the bash 'alias' keyword as metadata, and extracts help documentation from the alias files themselves.

alias files now have about-alias metadata.

@erichs

sorry about the commit noise, I based my changes off of revans/master, which was silly. You might want to cherry-pick those commits instead.

@nwinkler nwinkler was assigned
@nwinkler
Collaborator

Merged in your changes, @erichs, thanks!

@nwinkler nwinkler closed this
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

    Added Java plugin.

    nwinkler authored
  2. @tswicegood

    Merge pull request #138 from nwinkler/java-plugin

    tswicegood authored
    Java plugin
Commits on May 22, 2012
  1. @erichs
  2. @erichs
  3. @erichs

    alias-help()

    erichs authored
This page is out of date. Refresh to see the latest.
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
174 lib/helpers.bash
@@ -29,27 +29,56 @@ function reload_plugins() {
_load_bash_it_files "plugins"
}
+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 plugins'
+ group 'lib'
+
+ file_type="$1"
+ preposition="$2"
+ command_suffix="$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/$file_type/available/*.bash
do
- if [ -e $BASH_IT/plugins/enabled/$(basename $f) ]; then
+ if [ -e $BASH_IT/$file_type/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-$command_suffix)"
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 $command_suffix, do:"
+ printf '%s\n' "$ enable-$command_suffix <$command_suffix name> -or- $ enable-$command_suffix all"
+ printf '\n%s\n' "to disable $preposition $command_suffix, do:"
+ printf '%s\n' "$ disable-$command_suffix <$command_suffix name> -or- $ disable-$command_suffix all"
}
disable-plugin ()
@@ -59,30 +88,59 @@ disable-plugin ()
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 ()
+{
+ file_type="$1"
+ command_suffix="$2"
+ file_entity="$3"
+
+ if [ -z "$file_entity" ]; then
+ reference "disable-$command_suffix"
return
fi
- if [ "$1" = "all" ]; then
- typeset f plugin
- for f in $BASH_IT/plugins/available/*.bash
+ if [ "$file_entity" = "all" ]; then
+ typeset f $command_suffix
+ for f in $BASH_IT/$file_type/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/$file_type/enabled/$plugin ]; then
+ rm $BASH_IT/$file_type/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/$file_type/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 $command_suffix."
return
fi
- rm $BASH_IT/plugins/enabled/$(basename $plugin)
+ rm $BASH_IT/$file_type/enabled/$(basename $plugin)
fi
- printf '%s\n' "$1 disabled."
+ printf '%s\n' "$file_entity disabled."
}
enable-plugin ()
@@ -92,37 +150,87 @@ enable-plugin ()
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 ()
+{
+ file_type="$1"
+ command_suffix="$2"
+ file_entity="$3"
+
+ if [ -z "$file_entity" ]; then
+ reference "enable-$command_suffix"
return
fi
- if [ "$1" = "all" ]; then
- typeset f plugin
- for f in $BASH_IT/plugins/available/*.bash
+ if [ "$file_entity" = "all" ]; then
+ typeset f $command_suffix
+ for f in $BASH_IT/$file_type/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/$file_type/enabled/$plugin ]; then
+ ln -s $BASH_IT/$file_type/available/$plugin $BASH_IT/$file_type/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/$file_type/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 $command_suffix."
return
fi
plugin=$(basename $plugin)
- if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
- printf '%s\n' "$1 is already enabled."
+ if [ -e $BASH_IT/$file_type/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/$file_type/available/$plugin $BASH_IT/$file_type/enabled/$plugin
fi
- printf '%s\n' "$1 enabled."
+ 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 ()
View
11 plugins/available/java.plugin.bash
@@ -0,0 +1,11 @@
+cite about-plugin
+about-plugin 'Java and JAR helper functions'
+
+function jar_manifest {
+ about "extracts the specified JAR file's MANIFEST file and prints it to stdout"
+ group 'java'
+ param '1: JAR file to extract the MANIFEST from'
+ example 'jar_manifest lib/foo.jar'
+
+ unzip -c $1 META-INF/MANIFEST.MF
+}
Something went wrong with that request. Please try again.