From bbd6c02cb58ff9415a7016d39da0f3a074225dc2 Mon Sep 17 00:00:00 2001 From: Rich Manalang Date: Thu, 7 Oct 2010 17:21:05 -0700 Subject: [PATCH 01/40] added alias for python's SimpleHTTPServer --- plugins/python.plugin.bash | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/python.plugin.bash diff --git a/plugins/python.plugin.bash b/plugins/python.plugin.bash new file mode 100644 index 00000000..92f50e02 --- /dev/null +++ b/plugins/python.plugin.bash @@ -0,0 +1,4 @@ +#!/bin/bash + +alias http='python -m SimpleHTTPServer' + From 6e7f4239832abe6b8694695af4f312bb8a02badc Mon Sep 17 00:00:00 2001 From: John Schulz Date: Thu, 11 Nov 2010 11:57:47 -0500 Subject: [PATCH 02/40] =?UTF-8?q?Allow=20theming=20to=20be=20disabled=20(e?= =?UTF-8?q?g=20for=20old=20terminals)=20=20*=20Only=20load=20a=20theme=20f?= =?UTF-8?q?ile=20if=20`bobby`=20has=20been=20set=20=20*=20Only=20alter=20`?= =?UTF-8?q?PS1`=20if=20`\[=1B[1;34m\]\[$(scm=5Fchar)\]\[=1B[0;32m\]\[$(scm?= =?UTF-8?q?=5Fprompt=5Finfo)\]\[=1B[0;34m\]\[$(rvm=5Fversion=5Fprompt)\]?= =?UTF-8?q?=20\[=1B[33;40m\]\h=20\[=1B[39m\]in=20\[=1B[0;32m\]\w=20\[=1B[3?= =?UTF-8?q?9m\]\[\n\[=1B[0;32m\]=E2=86=92\[=1B[39m\]=20`=20has=20a=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_it.sh | 5 +++-- lib/appearance.bash | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index f0c850c2..60bef802 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -47,8 +47,9 @@ done unset config_file -export PS1=$PROMPT - +if [[ $PROMPT ]]; then + export PS1=$PROMPT +fi # Adding Support for other OSes PREVIEW="less" diff --git a/lib/appearance.bash b/lib/appearance.bash index 4b1f568e..f7235118 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -8,4 +8,6 @@ export GREP_COLOR='1;33' export LSCOLORS='Gxfxcxdxdxegedabagacad' # Load the theme -source "$BASH/themes/$BASH_THEME/$BASH_THEME.theme.bash" \ No newline at end of file +if [[ $BASH_THEME ]]; then + source "$BASH/themes/$BASH_THEME/$BASH_THEME.theme.bash" +fi \ No newline at end of file From 760cc8be63180ab102af5e81684af74fd74cfe10 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Thu, 11 Nov 2010 12:45:32 -0500 Subject: [PATCH 03/40] Add `gmu` (git merge upstream) alias * Pull in `origin` & `upstream` and merge them into `upstream/master` from http://www.gitready.com/intermediate/2009/02/12/easily-fetching-upstream-changes.html --- aliases/git.aliases.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aliases/git.aliases.bash b/aliases/git.aliases.bash index 40d87802..0ac25486 100644 --- a/aliases/git.aliases.bash +++ b/aliases/git.aliases.bash @@ -23,6 +23,7 @@ alias gcp='git cherry-pick' alias gco='git checkout' alias gexport='git archive --format zip --output' alias gdel='git branch -D' +alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' case $OSTYPE in linux*) @@ -61,7 +62,8 @@ function git-help() { 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 " gdel = git branch -D" + echo " gpo = git push origin" + echo " gmu = git fetch origin -v; git fetch upstream -v; git merge upstream/master" echo } From 62295973ca3bce1990a859b1f085b62cf9fd4d55 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 20 Nov 2010 16:27:47 -0600 Subject: [PATCH 04/40] Added quiet function to run command in background. --- plugins/base.plugin.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/base.plugin.bash b/plugins/base.plugin.bash index 9eceaf94..9c8cb922 100644 --- a/plugins/base.plugin.bash +++ b/plugins/base.plugin.bash @@ -30,6 +30,10 @@ pri() { ri -T "${1}" | open -f -a $PREVIEW } +quiet() { + $* &> /dev/null & +} + banish-cookies() { rm -r ~/.macromedia ~/.adobe ln -s /dev/null ~/.adobe From 8c6197717a9ed9e318951bcae37cfe522491c3db Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Mon, 22 Nov 2010 11:44:28 +0100 Subject: [PATCH 05/40] fixed debian dirty prompt bug --- themes/base.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 9ae5d0e8..e77d1d23 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -50,7 +50,7 @@ function prompt_char { } function git_prompt_info { - if [[ -n $(git status -s 2> /dev/null) ]]; then + if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} @@ -81,4 +81,4 @@ function rvm_version_prompt { rvm=$(rvm tools identifier) || return echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" fi -} \ No newline at end of file +} From aaa107161bd7dd12517c30aa3f59b07878090e7f Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Mon, 22 Nov 2010 13:07:08 +0100 Subject: [PATCH 06/40] added git_info function to git plugin --- plugins/git.plugins.bash | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/plugins/git.plugins.bash b/plugins/git.plugins.bash index ad21591d..5f4cc51e 100644 --- a/plugins/git.plugins.bash +++ b/plugins/git.plugins.bash @@ -17,4 +17,40 @@ function git_remove_missing_files() { # Adds files to git's exclude file (same as .gitignore) function local-ignore() { echo "$1" >> .git/info/exclude -} \ No newline at end of file +} + +# get a quick overview for your git repo +function git_info() { + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + # print informations + echo "git repo overview" + echo "-----------------" + echo + + # print all remotes and thier details + for remote in $(git remote show); do + echo $remote: + git remote show $remote + echo + done + + # print status of working repo + echo "status:" + if [ -n "$(git status -s 2> /dev/null)" ]; then + git status -s + else + echo "working directory is clean" + fi + + # print at least 5 last log entries + echo + echo "log:" + git log -5 --oneline + echo + + else + echo "you're currently not in a git repository" + + fi +} + From 92b8d6d9cfade500e4d514163b5c18a1df71113d Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Wed, 24 Nov 2010 16:22:05 +0100 Subject: [PATCH 07/40] added n0qorg theme --- themes/n0qorg/n0qorg.theme.bash | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 themes/n0qorg/n0qorg.theme.bash diff --git a/themes/n0qorg/n0qorg.theme.bash b/themes/n0qorg/n0qorg.theme.bash new file mode 100644 index 00000000..fcaca43f --- /dev/null +++ b/themes/n0qorg/n0qorg.theme.bash @@ -0,0 +1,22 @@ +#!/bin/bash +# n0qorg theme by Florian Baumann + +## look-a-like +# host directory (branch*)» +# for example: +# ananas ~/Code/bash-it/themes (master*)» +PROMPT="${bold_blue}\[\$(hostname)\]${normal} \w${normal} ${bold_white}\[\$(git_prompt_info)\]${normal}» " + +## git-theme +# feel free to change git chars. +GIT_THEME_PROMPT_DIRTY="${bold_blue}*${bold_white}" +GIT_THEME_PROMPT_CLEAN="" +GIT_THEME_PROMPT_PREFIX="${bold_blue}(${bold_white}" +GIT_THEME_PROMPT_SUFFIX="${bold_blue})" + +## alternate chars +# +SCM_THEME_PROMPT_DIRTY="*" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_PREFIX="(" +SCM_THEME_PROMPT_SUFFIX=")" From 6cf9a4b03c5ddfa9bb74508242cd9610836c7f09 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 27 Nov 2010 21:00:50 -0600 Subject: [PATCH 08/40] Added link to oh-my-zsh in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 742daf1e..8b8994ef 100644 --- a/README.md +++ b/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 and a shameless ripoff of oh-my-zsh. :) +'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). :) Includes some autocompletion tools, theming support, aliases, custom functions, a few stolen pieces from Steve Losh, and more. From 835bcabf04f405dc97b7082f7d49d7f5cc87e5cd Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 28 Nov 2010 12:37:31 -0600 Subject: [PATCH 09/40] Added Link post type. --- plugins/jekyll.plugins.bash | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 9b0d5c1e..3ad9d0da 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -12,7 +12,7 @@ newpost() { # If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr. - OPTIONS="Text Quote Image Audio Video" + OPTIONS="Text Quote Image Audio Video Link" if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ] then @@ -47,6 +47,12 @@ newpost() { POST_TYPE="Video" break fi + + if [[ $OPTION = "Link" ]] + then + POST_TYPE="Link" + break + fi done fi @@ -122,6 +128,15 @@ newpost() { then echo "" >> $FNAME fi + + if [[ $POST_TYPE = "Link" ]] + then + echo "[link][1]" >> $FNAME + echo >> $FNAME + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "[1]: url" >> $FNAME + fi fi if [[ $JEKYLL_FORMATTING = "textile" ]] @@ -152,6 +167,13 @@ newpost() { then echo "" >> $FNAME fi + + if [[ $POST_TYPE = "Link" ]] + then + echo "\"Site\":url" >> $FNAME + echo >> $FNAME + echo "bq. Quote" >> $FNAME + fi fi # Open the file in your favorite editor From aa228fb0c37da5525482194f322541ddafd6a2df Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 30 Nov 2010 16:33:10 +0100 Subject: [PATCH 10/40] added handmade commandline history tool --- plugins/hcht.plugin.bash | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 plugins/hcht.plugin.bash diff --git a/plugins/hcht.plugin.bash b/plugins/hcht.plugin.bash new file mode 100644 index 00000000..c83f6b43 --- /dev/null +++ b/plugins/hcht.plugin.bash @@ -0,0 +1,121 @@ +#!/bin/bash +# hch.plugin.bash: the handmade commandline history tool +# Copyright: (C) 2010 Florian Baumann +# License: GPL-3 +# Date: Dienstag 2010-11-30 + +### readme +# basiclly the handmade commandline history tool was made for storing +# informations. yeah, you're right. sounds a bit boring. many other +# applications can do this much better. but storing things from commandline? +# +# hcht was fitted to work at your terminal. +# your daily stuff like notices, todos, commands or output from a +# all these things will be stored without complex syntax. +# +# once you defined your storing-directory you will be able to easily +# save all the stuff listed above. +# + +### create a file +# the basic feature. open a file, do stuff and save. +# *.hch trailor is required. +# +# $ hcht evilcommand.hch +# +# this will create a new file or edit a existing one. +# paste your command or notice in your favorite editor + +### show all stored informations +# to get an overview of your storedir: +# +# $ hcht + +### todo with a whole sentence +# you can give hcht a bunch of parameters +# +# $ hcht this is a long reminder about a anything + +### save last executed command +# lets say you did a great hack at your system and you +# want to save it without complicated use of coping: +# +# $ hcht !! +# +# the "!!" will repeat the _last_ command you executed at +# your terminal. after asking you about a name the hch file +# will be saved. + +### read from stdin +# hcht is also able to read anything from stdin. +# +# $ cat any_important_logfile | hcht anylog +# +# "anylog" will be the name of the saved file. + +### configure store dir +# like /home/user/.hcht/ or something +hchtstoredir="" + +hcht() { + # configured? + if [ -z $hchtstoredir ]; then + echo "ERROR: handmade commandline history tool isn't configured." + return 1 + else + hchtstoredir=$(echo $hchtstoredir | sed -e 's/\/$//') + fi + + # dir available? + if [ ! -d $hchtstoredir ]; then + echo "ERROR: No such directory: $hchtstoredir" + return 1 + fi + + # get favorite editor + if [ -z $EDITOR ]; then + EDITOR=$(which vim || which nano) + fi + + # check if stdin-data is present and save content + if [ "$(tty)" = "not a tty" ]; then + hchname=$(echo $1 | sed -e 's/\ //g') + if [ -z $hchname ]; then + cat < /dev/stdin >> $hchtstoredir/$(date +%Y%m%d%H%M%S).hch + else + cat < /dev/stdin >> $hchtstoredir/$hchname.hch + fi + return 0 + fi + + # list all hch files if no parameter is given + if [ $# -eq 0 ]; then + for file in $(ls $hchtstoredir); do + echo $file + done + return 0 + fi + + # if a *.hch file is given start editing or creating it + if [ "$#" -eq "1" ]; then + if echo "$1" | grep -q -e ".*.hch$" ; then + $EDITOR ${hchtstoredir}/${1} + return 0 + else + $EDITOR ${hchtstoredir}/${1}.hch + return 0 + fi + fi + + # autocreate a new hch + if [ "$#" -gt "1" ]; then + echo -n "define a name: " ; read hchname + hchname=$(echo $hchname | sed -e 's/\ /_/g') + if [ -z "$hchname" ]; then + echo "$*" > $hchtstoredir/${1}-$(date +%Y%m%d%H%M%S).hch + else + echo "$*" > ${hchtstoredir}/${hchname}.hch + fi + return 0 + fi +} From d25288fdd3a6dbf2553a703321b40c80f25c9b68 Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 30 Nov 2010 16:41:41 +0100 Subject: [PATCH 11/40] fixed readme --- plugins/hcht.plugin.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/hcht.plugin.bash b/plugins/hcht.plugin.bash index c83f6b43..d9f99d5f 100644 --- a/plugins/hcht.plugin.bash +++ b/plugins/hcht.plugin.bash @@ -10,7 +10,7 @@ # applications can do this much better. but storing things from commandline? # # hcht was fitted to work at your terminal. -# your daily stuff like notices, todos, commands or output from a +# your daily stuff like notices, todos, commands or output from a command. # all these things will be stored without complex syntax. # # once you defined your storing-directory you will be able to easily @@ -19,7 +19,6 @@ ### create a file # the basic feature. open a file, do stuff and save. -# *.hch trailor is required. # # $ hcht evilcommand.hch # From c00bde6bbdf3762d6d1574b0dfc87ad165d856bd Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Wed, 1 Dec 2010 06:45:42 +0100 Subject: [PATCH 12/40] moved config of hcht to bash_profile template --- plugins/hcht.plugin.bash | 6 +----- template/bash_profile.template.bash | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/hcht.plugin.bash b/plugins/hcht.plugin.bash index d9f99d5f..cdab44fb 100644 --- a/plugins/hcht.plugin.bash +++ b/plugins/hcht.plugin.bash @@ -1,5 +1,5 @@ #!/bin/bash -# hch.plugin.bash: the handmade commandline history tool +# hcht.plugin.bash: the handmade commandline history tool # Copyright: (C) 2010 Florian Baumann # License: GPL-3 # Date: Dienstag 2010-11-30 @@ -52,10 +52,6 @@ # # "anylog" will be the name of the saved file. -### configure store dir -# like /home/user/.hcht/ or something -hchtstoredir="" - hcht() { # configured? if [ -z $hchtstoredir ]; then diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index a98e65c8..17853b1a 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -47,5 +47,8 @@ export IRC_CLIENT='irssi' export TODO="t" +# Set store directory for handmade commandline history tool +export hchtstoredir="$HOME/.hcht" + # Load Bash It source $BASH/bash_it.sh From e0d8582c0b3ba1f551ff7c60d4363a2fe2f6b428 Mon Sep 17 00:00:00 2001 From: Andy Shen Date: Sat, 4 Dec 2010 11:03:33 +1100 Subject: [PATCH 13/40] ssh completion using .ssh/config --- completion/ssh.completion.bash | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 completion/ssh.completion.bash diff --git a/completion/ssh.completion.bash b/completion/ssh.completion.bash new file mode 100644 index 00000000..76913330 --- /dev/null +++ b/completion/ssh.completion.bash @@ -0,0 +1,13 @@ +#!/bin/bash +# Bash completion support for ssh. + +export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} + +_sshcomplete() { + if [ -f $HOME/.ssh/config ]; then + COMPREPLY=($(compgen -W "`ruby -e"puts open('${HOME}/.ssh/config', 'r') { |f| f.readlines }.find_all { |l| l =~ /^Host/ }.inject([]) { |hosts, line| hosts << line[5..-1].split }.flatten.sort.uniq"`" -- ${COMP_WORDS[COMP_CWORD]})) + return 0 + fi +} + +complete -o default -o nospace -F _sshcomplete ssh From 57fc307e11137021a537088854a915e093ae15d4 Mon Sep 17 00:00:00 2001 From: Andy Shen Date: Sat, 4 Dec 2010 11:06:40 +1100 Subject: [PATCH 14/40] update credit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8b8994ef..e305eb8d 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ If you are submitting a pull request, please add your name to the list. * [Simon H. Eskildsen][sirupsen] * [Mark Szymanski][mrman208] * [Florian Baumann][noqqe] +* [Andy Shen][shenie] [revans]: http://github.com/revans [zerobearing2]: http://github.com/zerobearing2 @@ -62,4 +63,5 @@ If you are submitting a pull request, please add your name to the list. [sirupsen]: http://github.com/sirupsen [mrman208]: http://github.com/mrman208 [noqqe]: http://github.com/noqqe +[shenie]: http://github.com/shenie From 4476156eb82ef1ec746bc7789f7aab47f5593828 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 4 Dec 2010 12:22:32 -0600 Subject: [PATCH 15/40] Added test to see if in vim's shell (via the :sh command) --- themes/minimal/minimal.theme.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/minimal/minimal.theme.bash b/themes/minimal/minimal.theme.bash index 2f9b926e..a94c4536 100644 --- a/themes/minimal/minimal.theme.bash +++ b/themes/minimal/minimal.theme.bash @@ -1,8 +1,18 @@ prompt_setter() { if [[ $? -eq 0 ]]; then - PS1="\W " + if [ ! $VIMRUNTIME = "" ] + then + PS1="{vim} \W " + else + PS1="\W " + fi else - PS1="${bold_red}\W ${normal}" + if [ ! $VIMRUNTIME = "" ] + then + PS1="{vim} ${bold_red}\W ${normal}" + else + PS1="${bold_red}\W ${normal}" + fi fi } From 8a3d525460da73b57fb9edfb82f32e35af767047 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 15:40:46 -0600 Subject: [PATCH 16/40] Added modern theme --- themes/modern/modern.theme.bash | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 themes/modern/modern.theme.bash diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash new file mode 100644 index 00000000..85bcfe09 --- /dev/null +++ b/themes/modern/modern.theme.bash @@ -0,0 +1,27 @@ +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +modern_scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)][$(scm_prompt_info)]" + fi +} + +prompt() { + if [ $? -ne 0 ] + then + PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[\W] +${bold_red}└─▪${normal} " + else + PS1="┌─$(modern_scm_prompt)[\W] +└─▪ " + fi +} + + + +PROMPT_COMMAND=prompt From e5536385777f1f18960a8d89868214521ceaef83 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 15:49:51 -0600 Subject: [PATCH 17/40] Added colors to 'modern' theme --- themes/modern/modern.theme.bash | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 85bcfe09..8ba87156 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -1,6 +1,12 @@ SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" +SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}' +SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}' +SCM_GIT_CHAR='${bold_green}±${normal}' +SCM_SVN_CHAR='${bold_cyan}⑆${normal}' +SCM_HG_CHAR='${bold_red}☿${normal}' + modern_scm_prompt() { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] From 0a67e549cbdc5877c5f0ca39b7cde1e7f1f5447e Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 16:03:33 -0600 Subject: [PATCH 18/40] Added more colors to 'modern' theme --- themes/modern/modern.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 8ba87156..2d0948ff 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -20,10 +20,10 @@ modern_scm_prompt() { prompt() { if [ $? -ne 0 ] then - PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[\W] + PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}] ${bold_red}└─▪${normal} " else - PS1="┌─$(modern_scm_prompt)[\W] + PS1="┌─$(modern_scm_prompt)[${cyan}\W${normal}] └─▪ " fi } From ad996f0a9313ba58014840eda3d4c8b74ae47f90 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 16:49:45 -0600 Subject: [PATCH 19/40] Added 'ref' plugin --- plugins/ref.plugin.bash | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 plugins/ref.plugin.bash diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash new file mode 100644 index 00000000..0c93d706 --- /dev/null +++ b/plugins/ref.plugin.bash @@ -0,0 +1,36 @@ +ref() { + if [ ! -d "$REF_DIR" ] + then + mkdir -p "$REF_DIR" + fi + + REF_DIR=${REF_DIR%/} + + if [ "$1" = 'ls' ] + then + if [ "$2" = '' ] + then + builtin cd "$REF_DIR" + ls -G + builtin cd - > /dev/null + return + else + builtin cd "$REF_DIR"/"$2" + ls -G + builtin cd - > /dev/null + return + fi + fi + + DIR="${1}/${2}" + + builtin cd "$REF_DIR"/"$DIR" + + if [ $(uname) = "Darwin" ] + then + open index.html + elif [ $(uname) = "Linux" ] + then + gnome-open index.html + fi +} From 9448e355cabf4bbcc4d7aca4f54dfb76b3bf915a Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 16:49:58 -0600 Subject: [PATCH 20/40] Added REF_DIR variable for the ref plugin --- template/bash_profile.template.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 17853b1a..441e06ba 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -50,5 +50,8 @@ export TODO="t" # Set store directory for handmade commandline history tool export hchtstoredir="$HOME/.hcht" +# Set this to the directory to use for the ref plugin +export REF_DIR="$HOME/.ref/" + # Load Bash It source $BASH/bash_it.sh From 493bdb9456bd4ee375e5c9ce6bbd7317ed1a319d Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 17:01:19 -0600 Subject: [PATCH 21/40] Added documentation for ref plugin --- plugins/ref.plugin.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash index 0c93d706..d5888db8 100644 --- a/plugins/ref.plugin.bash +++ b/plugins/ref.plugin.bash @@ -1,3 +1,27 @@ +##################################################################################################################################################################### +# README # +# ------ # +# # +# ref is a plugin for storing HTML formatted references, mainly suited for programming. # +# Your $REF_DIR variable is the directory for storing these references in. If it does not exist, it will be created automatically. # +# Here is an example of what my $REF_DIR looks like, because this will be of use when I explain how your $REF_DIR has to be structured: # +# # +# ~/.ref/ # +# ruby/ # +# general/ # +# index.html # +# bash/ # +# array/ # +# index.html # +# select/ # +# index.html # +# # +# This is what the basic structure of your $REF_DIR should look like: Subdirectories for each subject, and then another set of subdirectories for the part of the # +# subject you want to reference. And in the second subdirectory, an index.html file. # +# # +# I hope that you like this plugin and if you have any questions about it, send me (mrman208) a message on GitHub or email me at mrman208@me.com # +##################################################################################################################################################################### + ref() { if [ ! -d "$REF_DIR" ] then From 862c6438f4659c3755c0a4d64f17e0e15d129cae Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 17:06:04 -0600 Subject: [PATCH 22/40] Improved ref documentation --- plugins/ref.plugin.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash index d5888db8..34f744c0 100644 --- a/plugins/ref.plugin.bash +++ b/plugins/ref.plugin.bash @@ -18,6 +18,29 @@ # # # This is what the basic structure of your $REF_DIR should look like: Subdirectories for each subject, and then another set of subdirectories for the part of the # # subject you want to reference. And in the second subdirectory, an index.html file. # +# +# To use ref, you do the ref command followed by the sugject and the sub-subject as arguments. For instance: +# +# ref bash array +# +# Would open the bash/array/index.html file. +# +# To list your references, you would do the ref ls command, optionally followed by a subject. For instance: +# +# ref ls +# +# Would give me: +# +# ruby bash +# +# And: +# +# ref ls bash +# +# would output: +# +# array +# select # # # I hope that you like this plugin and if you have any questions about it, send me (mrman208) a message on GitHub or email me at mrman208@me.com # ##################################################################################################################################################################### From db8d567b14fff4670727573cf7ce7d658bd179a0 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 17:08:33 -0600 Subject: [PATCH 23/40] Formatting fixes --- plugins/ref.plugin.bash | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash index 34f744c0..4f9ce26c 100644 --- a/plugins/ref.plugin.bash +++ b/plugins/ref.plugin.bash @@ -1,23 +1,23 @@ ##################################################################################################################################################################### -# README # -# ------ # -# # -# ref is a plugin for storing HTML formatted references, mainly suited for programming. # -# Your $REF_DIR variable is the directory for storing these references in. If it does not exist, it will be created automatically. # -# Here is an example of what my $REF_DIR looks like, because this will be of use when I explain how your $REF_DIR has to be structured: # -# # -# ~/.ref/ # -# ruby/ # -# general/ # -# index.html # -# bash/ # -# array/ # -# index.html # -# select/ # -# index.html # -# # -# This is what the basic structure of your $REF_DIR should look like: Subdirectories for each subject, and then another set of subdirectories for the part of the # -# subject you want to reference. And in the second subdirectory, an index.html file. # +# README +# ------ +# +# ref is a plugin for storing HTML formatted references, mainly suited for programming. +# Your $REF_DIR variable is the directory for storing these references in. If it does not exist, it will be created automatically. +# Here is an example of what my $REF_DIR looks like, because this will be of use when I explain how your $REF_DIR has to be structured: +# +# ~/.ref/ +# ruby/ +# general/ +# index.html +# bash/ +# array/ +# index.html +# select/ +# index.html +# +# This is what the basic structure of your $REF_DIR should look like: Subdirectories for each subject, and then another set of subdirectories for the part of the +# subject you want to reference. And in the second subdirectory, an index.html file. # # To use ref, you do the ref command followed by the sugject and the sub-subject as arguments. For instance: # @@ -41,8 +41,8 @@ # # array # select -# # -# I hope that you like this plugin and if you have any questions about it, send me (mrman208) a message on GitHub or email me at mrman208@me.com # +# +# I hope that you like this plugin and if you have any questions about it, send me (mrman208) a message on GitHub or email me at mrman208@me.com ##################################################################################################################################################################### ref() { From 145886305cd24fc61f32a8e4ea583eddf8cbbdac Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 20:50:57 -0600 Subject: [PATCH 24/40] Added 'new' command for ref. --- plugins/ref.plugin.bash | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash index 4f9ce26c..ed6329a2 100644 --- a/plugins/ref.plugin.bash +++ b/plugins/ref.plugin.bash @@ -41,8 +41,6 @@ # # array # select -# -# I hope that you like this plugin and if you have any questions about it, send me (mrman208) a message on GitHub or email me at mrman208@me.com ##################################################################################################################################################################### ref() { @@ -53,20 +51,26 @@ ref() { REF_DIR=${REF_DIR%/} + builtin cd $REF_DIR + if [ "$1" = 'ls' ] then if [ "$2" = '' ] then - builtin cd "$REF_DIR" ls -G builtin cd - > /dev/null return else - builtin cd "$REF_DIR"/"$2" ls -G builtin cd - > /dev/null return fi + elif [ "$1" = 'new' ] + then + mkdir -p "$2"/"$3" + echo You can now put the index.html file into "$REF_DIR"/"$2"/"$3" + builtin cd - > /dev/null + return fi DIR="${1}/${2}" From c82285539b031516cef21b1c01722a223e475524 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 21:12:45 -0600 Subject: [PATCH 25/40] Added better documentation for ref --- bash_it.sh | 1 + plugins/ref.plugin.bash | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/bash_it.sh b/bash_it.sh index f0c850c2..fef85847 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -69,5 +69,6 @@ function bash-it() { echo " todo-help This will list out all the aliases you can use with todo.txt-cli" echo " aliases-help Generic list of aliases." echo " plugins-help This will list out all the plugins and functions you can use with bash-it" + echo " ref-help Get help for the ref plugin." echo } diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash index ed6329a2..1c4deb0b 100644 --- a/plugins/ref.plugin.bash +++ b/plugins/ref.plugin.bash @@ -85,3 +85,25 @@ ref() { gnome-open index.html fi } + +ref-help() { + echo + echo "Help for the ref plugin" + echo "-----------------------" + echo + echo "Setting up: " + echo + echo "First, set the REF_DIR variable in you ~/.bash_profile to the directory you want to store your references in." + echo "You don't even have to create this directory if you don't want to, ref will make it for you if it doesn't exist." + echo + echo "Then, you can start adding some refs. You can do so with this command: " + echo " ref new topic subtopic" + echo "Where topic is the general topic, such as ruby. And subtopic is a more exact topic, like array." + echo "This will create a directory for the topic, and a subdirectory for the subtopic. You can then move a file of your desired format into the subtopic's directory." + echo + echo "To access your ref, you would do the following command: " + echo " ref topic subtopic" + echo "Where topic and subtopic are the same as before, but ref will open the file under your topic/subtopic directory. Unless it is a full website." + echo + echo "You can also download full websites as a ref, as long as it has an index.html file, it will work." +} From 668f8e68c068e92035476c2052ff9fe9431c3336 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 5 Dec 2010 21:15:30 -0600 Subject: [PATCH 26/40] Added PS2 to modern theme --- themes/modern/modern.theme.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 2d0948ff..f0dbccce 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -28,6 +28,8 @@ ${bold_red}└─▪${normal} " fi } +PS2="└─▪ " + PROMPT_COMMAND=prompt From 13edf326c450548e14673c82f75c717425d19a8b Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Mon, 6 Dec 2010 16:01:06 +0100 Subject: [PATCH 27/40] added advanced ssh completion --- completion/ssh.completion.bash | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/completion/ssh.completion.bash b/completion/ssh.completion.bash index 76913330..30fd65d6 100644 --- a/completion/ssh.completion.bash +++ b/completion/ssh.completion.bash @@ -4,10 +4,20 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} _sshcomplete() { - if [ -f $HOME/.ssh/config ]; then - COMPREPLY=($(compgen -W "`ruby -e"puts open('${HOME}/.ssh/config', 'r') { |f| f.readlines }.find_all { |l| l =~ /^Host/ }.inject([]) { |hosts, line| hosts << line[5..-1].split }.flatten.sort.uniq"`" -- ${COMP_WORDS[COMP_CWORD]})) - return 0 + + # parse all defined hosts from .ssh/config + if [ -r $HOME/.ssh/config ]; then + COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" -- ${COMP_WORDS[COMP_CWORD]})) fi + + # parse all hosts found in .ssh/known_hosts + if [ -r $HOME/.ssh/known_hosts ]; then + if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then + COMPREPLY=( $COMPREPLY $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" -- ${COMP_WORDS[COMP_CWORD]} )) + fi + fi + + return 0 } complete -o default -o nospace -F _sshcomplete ssh From afafe316b59fbf69f0feccb029f4d375d5e58d4e Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 6 Dec 2010 16:10:56 -0600 Subject: [PATCH 28/40] Removed all traces of ref because I am going to be making it into a separate project. --- bash_it.sh | 1 - plugins/ref.plugin.bash | 109 ---------------------------------------- 2 files changed, 110 deletions(-) delete mode 100644 plugins/ref.plugin.bash diff --git a/bash_it.sh b/bash_it.sh index fef85847..f0c850c2 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -69,6 +69,5 @@ function bash-it() { echo " todo-help This will list out all the aliases you can use with todo.txt-cli" echo " aliases-help Generic list of aliases." echo " plugins-help This will list out all the plugins and functions you can use with bash-it" - echo " ref-help Get help for the ref plugin." echo } diff --git a/plugins/ref.plugin.bash b/plugins/ref.plugin.bash deleted file mode 100644 index 1c4deb0b..00000000 --- a/plugins/ref.plugin.bash +++ /dev/null @@ -1,109 +0,0 @@ -##################################################################################################################################################################### -# README -# ------ -# -# ref is a plugin for storing HTML formatted references, mainly suited for programming. -# Your $REF_DIR variable is the directory for storing these references in. If it does not exist, it will be created automatically. -# Here is an example of what my $REF_DIR looks like, because this will be of use when I explain how your $REF_DIR has to be structured: -# -# ~/.ref/ -# ruby/ -# general/ -# index.html -# bash/ -# array/ -# index.html -# select/ -# index.html -# -# This is what the basic structure of your $REF_DIR should look like: Subdirectories for each subject, and then another set of subdirectories for the part of the -# subject you want to reference. And in the second subdirectory, an index.html file. -# -# To use ref, you do the ref command followed by the sugject and the sub-subject as arguments. For instance: -# -# ref bash array -# -# Would open the bash/array/index.html file. -# -# To list your references, you would do the ref ls command, optionally followed by a subject. For instance: -# -# ref ls -# -# Would give me: -# -# ruby bash -# -# And: -# -# ref ls bash -# -# would output: -# -# array -# select -##################################################################################################################################################################### - -ref() { - if [ ! -d "$REF_DIR" ] - then - mkdir -p "$REF_DIR" - fi - - REF_DIR=${REF_DIR%/} - - builtin cd $REF_DIR - - if [ "$1" = 'ls' ] - then - if [ "$2" = '' ] - then - ls -G - builtin cd - > /dev/null - return - else - ls -G - builtin cd - > /dev/null - return - fi - elif [ "$1" = 'new' ] - then - mkdir -p "$2"/"$3" - echo You can now put the index.html file into "$REF_DIR"/"$2"/"$3" - builtin cd - > /dev/null - return - fi - - DIR="${1}/${2}" - - builtin cd "$REF_DIR"/"$DIR" - - if [ $(uname) = "Darwin" ] - then - open index.html - elif [ $(uname) = "Linux" ] - then - gnome-open index.html - fi -} - -ref-help() { - echo - echo "Help for the ref plugin" - echo "-----------------------" - echo - echo "Setting up: " - echo - echo "First, set the REF_DIR variable in you ~/.bash_profile to the directory you want to store your references in." - echo "You don't even have to create this directory if you don't want to, ref will make it for you if it doesn't exist." - echo - echo "Then, you can start adding some refs. You can do so with this command: " - echo " ref new topic subtopic" - echo "Where topic is the general topic, such as ruby. And subtopic is a more exact topic, like array." - echo "This will create a directory for the topic, and a subdirectory for the subtopic. You can then move a file of your desired format into the subtopic's directory." - echo - echo "To access your ref, you would do the following command: " - echo " ref topic subtopic" - echo "Where topic and subtopic are the same as before, but ref will open the file under your topic/subtopic directory. Unless it is a full website." - echo - echo "You can also download full websites as a ref, as long as it has an index.html file, it will work." -} From 8d3cd22c541ade83e47c5b5d62606f5a7ffd5e4b Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 6 Dec 2010 16:20:36 -0600 Subject: [PATCH 29/40] Removed REF_DIR variable from .bash_profile template. --- template/bash_profile.template.bash | 3 --- 1 file changed, 3 deletions(-) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 441e06ba..17853b1a 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -50,8 +50,5 @@ export TODO="t" # Set store directory for handmade commandline history tool export hchtstoredir="$HOME/.hcht" -# Set this to the directory to use for the ref plugin -export REF_DIR="$HOME/.ref/" - # Load Bash It source $BASH/bash_it.sh From 0d55346e9b19a9ccf87a3ba317e68054c6fc7391 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Mon, 6 Dec 2010 22:08:32 -0500 Subject: [PATCH 30/40] Didn't see the instructions to add myself to `README.md`. My pull request (#23) was accepted in 6c975853292f6d897c871c51149a63ec62abd0b6 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e305eb8d..e7537243 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ If you are submitting a pull request, please add your name to the list. * [Mark Szymanski][mrman208] * [Florian Baumann][noqqe] * [Andy Shen][shenie] +* [John Schulz][jfsiii] [revans]: http://github.com/revans [zerobearing2]: http://github.com/zerobearing2 @@ -64,4 +65,5 @@ If you are submitting a pull request, please add your name to the list. [mrman208]: http://github.com/mrman208 [noqqe]: http://github.com/noqqe [shenie]: http://github.com/shenie +[jfsiii]: http://github.com/jfsiii From 2ce12674f643329ee1cec9ba7bc7fd009f06d9ef Mon Sep 17 00:00:00 2001 From: Rich Manalang Date: Mon, 13 Dec 2010 13:39:41 -0800 Subject: [PATCH 31/40] added https://github.com/rupa/z as a plugin --- plugins/z.bash | 148 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 plugins/z.bash diff --git a/plugins/z.bash b/plugins/z.bash new file mode 100644 index 00000000..d8c3cd6b --- /dev/null +++ b/plugins/z.bash @@ -0,0 +1,148 @@ +#!/bin/bash + +# maintains a jump-list of the directories you actually use +# +# INSTALL: +# * put something like this in your .bashrc: +# . /path/to/z.sh +# * cd around for a while to build up the db +# * PROFIT!! +# +# USE: +# * z foo # goes to most frecent dir matching foo +# * z foo bar # goes to most frecent dir matching foo and bar +# * z -r foo # goes to highest ranked dir matching foo +# * z -t foo # goes to most recently accessed dir matching foo +# * z -l foo # list all dirs matching foo (by frecency) + +z() { + local datafile="$HOME/.z" + if [ "$1" = "--add" ]; then + # add + shift + # $HOME isn't worth matching + [ "$*" = "$HOME" ] && return + awk -v p="$*" -v t="$(date +%s)" -F"|" ' + BEGIN { rank[p] = 1; time[p] = t } + $2 >= 1 { + if( $1 == p ) { + rank[$1] = $2 + 1 + time[$1] = t + } else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if( count > 1000 ) { + for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging + } else for( i in rank ) print i "|" rank[i] "|" time[i] + } + ' "$datafile" 2>/dev/null > "$datafile.tmp" + mv -f "$datafile.tmp" "$datafile" + elif [ "$1" = "--complete" ]; then + # tab completion + awk -v q="$2" -F"|" ' + BEGIN { + if( q == tolower(q) ) nocase = 1 + split(substr(q,3),fnd," ") + } + { + if( system("test -d \"" $1 "\"") ) next + if( nocase ) { + for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = "" + if( $1 ) print $1 + } else { + for( i in fnd ) $1 !~ fnd[i] && $1 = "" + if( $1 ) print $1 + } + } + ' "$datafile" 2>/dev/null + else + # list/go + while [ "$1" ]; do case "$1" in + -h) echo "z [-h][-l][-r][-t] args" >&2; return;; + -l) local list=1;; + -r) local typ="rank";; + -t) local typ="recent";; + --) while [ "$1" ]; do shift; local fnd="$fnd $1";done;; + *) local fnd="$fnd $1";; + esac; local last=$1; shift; done + [ "$fnd" ] || local list=1 + # if we hit enter on a completion just go there + [ -d "$last" ] && cd "$last" && return + [ -f "$datafile" ] || return + local cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$datafile.tmp" -F"|" ' + function frecent(rank, time) { + dx = t-time + if( dx < 3600 ) return rank*4 + if( dx < 86400 ) return rank*2 + if( dx < 604800 ) return rank/2 + return rank/4 + } + function output(files, toopen, override) { + if( list ) { + if( typ == "recent" ) { + cmd = "sort -nr >&2" + } else cmd = "sort -n >&2" + for( i in files ) if( files[i] ) printf "%-10s %s\n", files[i], i | cmd + if( override ) printf "%-10s %s\n", "common:", override > "/dev/stderr" + } else { + if( override ) toopen = override + print toopen + } + } + function common(matches, fnd, nc) { + for( i in matches ) { + if( matches[i] && (!short || length(i) < length(short)) ) short = i + } + if( short == "/" ) return + for( i in matches ) if( matches[i] && i !~ short ) x = 1 + if( x ) return + if( nc ) { + for( i in fnd ) if( tolower(short) !~ tolower(fnd[i]) ) x = 1 + } else for( i in fnd ) if( short !~ fnd[i] ) x = 1 + if( !x ) return short + } + BEGIN { split(q, a, " ") } + { + if( system("test -d \"" $1 "\"") ) next + print $0 >> tmpfl + if( typ == "rank" ) { + f = $2 + } else if( typ == "recent" ) { + f = t-$3 + } else f = frecent($2, $3) + wcase[$1] = nocase[$1] = f + for( i in a ) { + if( $1 !~ a[i] ) delete wcase[$1] + if( tolower($1) !~ tolower(a[i]) ) delete nocase[$1] + } + if( wcase[$1] > oldf ) { + cx = $1 + oldf = wcase[$1] + } else if( nocase[$1] > noldf ) { + ncx = $1 + noldf = nocase[$1] + } + } + END { + if( cx ) { + output(wcase, cx, common(wcase, a, 0)) + } else if( ncx ) output(nocase, ncx, common(nocase, a, 1)) + } + ' "$datafile")" + if [ $? -gt 0 ]; then + rm -f "$datafile.tmp" + else + mv -f "$datafile.tmp" "$datafile" + [ "$cd" ] && cd "$cd" + fi + fi +} +# tab completion +complete -C 'z --complete "$COMP_LINE"' z +# populate directory list. avoid clobbering other PROMPT_COMMANDs. +echo $PROMPT_COMMAND | grep -q "z --add" +[ $? -gt 0 ] && PROMPT_COMMAND='z --add "$(pwd -P)";'"$PROMPT_COMMAND" From ab44572ba4f3cedfb27c6e26b60ca75bfdc4ecdf Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 14 Dec 2010 14:33:16 +0100 Subject: [PATCH 32/40] added minimal config backup function buf() --- plugins/base.plugin.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/base.plugin.bash b/plugins/base.plugin.bash index 9c8cb922..02c0104b 100644 --- a/plugins/base.plugin.bash +++ b/plugins/base.plugin.bash @@ -87,4 +87,10 @@ function plugins-help() { | grep -v "COMPREPLY=()" | sed -e "s/()//" } - +# back up file with timestamp +# useful for administrators and configs +buf () { + filename=$1 + filetime=$(date +%Y%m%d_%H%M%S) + cp ${filename} ${filename}_${filetime} +} From f3d19db472cba4ca529de917f9ed2779a1f3dc22 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Tue, 14 Dec 2010 18:36:44 -0600 Subject: [PATCH 33/40] Added $PS3 customization for 'modern' theme. --- themes/modern/modern.theme.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index f0dbccce..6a58eef5 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -7,6 +7,8 @@ SCM_GIT_CHAR='${bold_green}±${normal}' SCM_SVN_CHAR='${bold_cyan}⑆${normal}' SCM_HG_CHAR='${bold_red}☿${normal}' +PS3=">> " + modern_scm_prompt() { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] From 7c13d46bb1a788aa823eb4c2cfb6c7982d96d897 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 17 Dec 2010 17:56:43 -0600 Subject: [PATCH 34/40] Added comment to 'modern' theme --- themes/modern/modern.theme.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 6a58eef5..0365276d 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -22,6 +22,9 @@ modern_scm_prompt() { prompt() { if [ $? -ne 0 ] then + # Yes, the indenting on these is weird, but it has to be like + # this otherwise it won't display properly. + PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}] ${bold_red}└─▪${normal} " else From 56d016aed1632cdf6561a759feb610ac4d542620 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 19 Dec 2010 09:40:52 -0600 Subject: [PATCH 35/40] Added feature to 'modern' theme to show if you are in vim's shell (achieved by the :sh command) --- themes/modern/modern.theme.bash | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 0365276d..8688f366 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -9,6 +9,13 @@ SCM_HG_CHAR='${bold_red}☿${normal}' PS3=">> " +is_vim_shell() { + if [ ! -z "$VIMRUNTIME" ] + then + echo "[${cyan}vim shell${normal}]" + fi +} + modern_scm_prompt() { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] @@ -25,10 +32,10 @@ prompt() { # Yes, the indenting on these is weird, but it has to be like # this otherwise it won't display properly. - PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}] + PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) ${bold_red}└─▪${normal} " else - PS1="┌─$(modern_scm_prompt)[${cyan}\W${normal}] + PS1="┌─$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) └─▪ " fi } From 3c0ea6784e26abc27d21781b0fdd3518e2576598 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 20 Dec 2010 10:02:54 -0600 Subject: [PATCH 36/40] Added 'editpost' function for jekyll plugins --- plugins/jekyll.plugins.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 3ad9d0da..546bb63e 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -1,5 +1,31 @@ #!/bin/bash +editpost() { + builtin cd "$JEKYLL_LOCAL_ROOT/_posts" + + COUNTER=1 + NUMBER="$RANDOM" + + for POST in * + do + DATE=`echo $POST | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"` + TITLE=`cat $POST | grep -oE "title: (.+)"` + TITLE=`echo $TITLE | sed 's/title: //'` + TMPFILE="/tmp/editpost-$NUMBER" + echo "$COUNTER) $DATE | $TITLE" >> "$TMPFILE" + POSTS[$COUNTER]=$POST + COUNTER=`expr $COUNTER + 1` + done + less $TMPFILE + read -p "Number of post to edit: " POST_TO_EDIT + if [ -z "$EDITOR" ] + then + nano "${POSTS[$POST_TO_EDIT]}" + else + "$EDITOR" "${POSTS[$POST_TO_EDIT]}" + fi +} + newpost() { # 'builtin cd' into the local jekyll root From f3a4d44619786fc548132121c7cfb29c515d9c90 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 20 Dec 2010 10:07:33 -0600 Subject: [PATCH 37/40] Moved variable and fixed formatting for 'editpost' --- plugins/jekyll.plugins.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 546bb63e..e87b82db 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -5,14 +5,14 @@ editpost() { COUNTER=1 NUMBER="$RANDOM" + TMPFILE="/tmp/editpost-$NUMBER" for POST in * do DATE=`echo $POST | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"` TITLE=`cat $POST | grep -oE "title: (.+)"` TITLE=`echo $TITLE | sed 's/title: //'` - TMPFILE="/tmp/editpost-$NUMBER" - echo "$COUNTER) $DATE | $TITLE" >> "$TMPFILE" + echo "$COUNTER) $DATE $TITLE" >> "$TMPFILE" POSTS[$COUNTER]=$POST COUNTER=`expr $COUNTER + 1` done From 6ffba72087045dc46e5369ab31c5dcabcf6e95b9 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 20 Dec 2010 18:08:01 -0600 Subject: [PATCH 38/40] Added aliases for ruby (rb) and git commit --interactive (gci) --- aliases/general.aliases.bash | 2 ++ aliases/git.aliases.bash | 2 ++ 2 files changed, 4 insertions(+) diff --git a/aliases/general.aliases.bash b/aliases/general.aliases.bash index 1cb470f1..0e05eb02 100644 --- a/aliases/general.aliases.bash +++ b/aliases/general.aliases.bash @@ -23,6 +23,8 @@ alias q="exit" alias irc="$IRC_CLIENT" +alias rb="ruby" + # Pianobar can be found here: http://github.com/PromyLOPh/pianobar/ alias piano="pianobar" diff --git a/aliases/git.aliases.bash b/aliases/git.aliases.bash index 0ac25486..cec846f4 100644 --- a/aliases/git.aliases.bash +++ b/aliases/git.aliases.bash @@ -16,6 +16,7 @@ alias gpo='git push origin' alias gdv='git diff -w "$@" | vim -R -' alias gc='git commit -v' alias gca='git commit -v -a' +alias gci='git commit --interactive' alias gb='git branch' alias gba='git branch -a' alias gcount='git shortlog -sn' @@ -56,6 +57,7 @@ function git-help() { 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" From 36438fe68024b1918142e9cd4b01e6af38144697 Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 28 Dec 2010 13:00:44 +0100 Subject: [PATCH 39/40] added awesome graphical git log alias --- aliases/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/git.aliases.bash b/aliases/git.aliases.bash index cec846f4..4cd1be07 100644 --- a/aliases/git.aliases.bash +++ b/aliases/git.aliases.bash @@ -25,6 +25,7 @@ alias gco='git checkout' alias gexport='git archive --format zip --output' alias gdel='git branch -D' alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' +alias gll='git log --graph --pretty=oneline --abbrev-commit' case $OSTYPE in linux*) From c505dcfbbdf4c71366c935d1deb3a7ab08faea87 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Tue, 28 Dec 2010 10:39:04 -0600 Subject: [PATCH 40/40] Added documentation for 'gll' git alias. --- aliases/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/git.aliases.bash b/aliases/git.aliases.bash index 4cd1be07..45d7d05f 100644 --- a/aliases/git.aliases.bash +++ b/aliases/git.aliases.bash @@ -68,5 +68,6 @@ function git-help() { 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 }