From d5645e74a0eacf0c7cf743c09a5dad1ff990db8a Mon Sep 17 00:00:00 2001 From: John Schulz Date: Tue, 9 Nov 2010 23:21:19 -0500 Subject: [PATCH 01/14] Theme changes * Load colors before base theme so they can be used by base theme * Change git-specific variables to SCM-agnostic ones --- bash_it.sh | 9 +-- themes/base.theme.bash | 85 ++++++++++++++++++++++++----- themes/bobby/bobby.theme.bash | 7 ++- themes/candy/candy.theme.bash | 2 +- themes/clean/clean.theme.bash | 2 +- themes/pete/pete.theme.bash | 10 ++-- themes/simple/simple.theme.bash | 17 ++---- themes/standard/standard.theme.bash | 10 ++-- themes/zitron/zitron.theme.bash | 2 +- 9 files changed, 98 insertions(+), 46 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 5736f893..0d42fcc9 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -6,12 +6,9 @@ alias reload='source ~/.bash_profile' # Load the framework -# Themes -THEMES="${BASH}/themes/*.bash" -for config_file in $THEMES -do - source $config_file -done +# Load colors first so they can be use in base theme +source "${BASH}/themes/colors.theme.bash" +source "${BASH}/themes/base.theme.bash" # Library LIB="${BASH}/lib/*.bash" diff --git a/themes/base.theme.bash b/themes/base.theme.bash index f898875b..9ae5d0e8 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -1,27 +1,82 @@ #!/bin/bash -# Stolen from Steve Losh -function prompt_char { - git branch >/dev/null 2>/dev/null && echo -e '±' && return - hg root >/dev/null 2>/dev/null && echo -e '☿' && return - echo -e '○' -} +SCM_THEME_PROMPT_DIRTY=' ✗' +SCM_THEME_PROMPT_CLEAN=' ✓' +SCM_THEME_PROMPT_PREFIX=' |' +SCM_THEME_PROMPT_SUFFIX='|' -function parse_git_dirty { - if [[ -n $(git status -s 2> /dev/null) ]]; then - echo -e "$GIT_THEME_PROMPT_DIRTY" - else - echo -e "$GIT_THEME_PROMPT_CLEAN" +GIT='git' +SCM_GIT_CHAR='±' + +HG='hg' +SCM_HG_CHAR='☿' + +SVN='svn' +SCM_SVN_CHAR='⑆' + +SCM_NONE_CHAR='○' + +RVM_THEME_PROMPT_PREFIX=' |' +RVM_THEME_PROMPT_SUFFIX='|' + +function scm { + if [[ -d .git ]]; then SCM=$GIT + elif [[ -d .hg ]]; then SCM=$HG + elif [[ -d .svn ]]; then SCM=$SVN + else SCM='NONE' fi } -function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo -e "$GIT_THEME_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$GIT_THEME_PROMPT_SUFFIX" +function scm_char { + if [[ -z $SCM ]]; then scm; fi + [[ $SCM == $GIT ]] && echo $SCM_GIT_CHAR && return + [[ $SCM == $HG ]] && echo $SCM_HG_CHAR && return + [[ $SCM == $SVN ]] && echo $SCM_SVN_CHAR && return + echo $SCM_NONE_CHAR } +function scm_prompt_info { + if [[ -z $SCM ]]; then scm; fi + [[ $SCM == $GIT ]] && git_prompt_info && return + [[ $SCM == $HG ]] && hg_prompt_info && return + [[ $SCM == $SVN ]] && svn_prompt_info && return +} -function rvm_version_prompt() { +# Stolen from Steve Losh +# left in for backwards-compatibility +function prompt_char { + char=$(scm_char); + echo -e "$char" +} + +function git_prompt_info { + if [[ -n $(git status -s 2> /dev/null) ]]; then + state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + + echo -e "$prefix${ref#refs/heads/}$state$suffix" +} + +function svn_prompt_info { + if [[ -n $(svn status 2> /dev/null) ]]; then + state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return + + [[ -z $ref ]] && return + echo -e "$prefix$ref$state$suffix" +} + +function rvm_version_prompt { if which rvm &> /dev/null; then rvm=$(rvm tools identifier) || return echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 8eb50c54..f0f84476 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -1,6 +1,10 @@ #!/bin/bash +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_PREFIX=" |" +SCM_THEME_PROMPT_SUFFIX="${green}|" -PROMPT="\[${bold_blue}\]\[\$(prompt_char)\]\[\$(git_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt) \]\[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[→ " +PROMPT="${bold_blue}\[\$(scm_char)\]${green}\$(scm_prompt_info)${blue}\$(rvm_version_prompt) ${orange}\h ${reset_color}in ${green}\w ${reset_color}\]\[→ " # git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" @@ -10,3 +14,4 @@ GIT_THEME_PROMPT_SUFFIX="${green}|" RVM_THEME_PROMPT_PREFIX=" |" RVM_THEME_PROMPT_SUFFIX="|" + diff --git a/themes/candy/candy.theme.bash b/themes/candy/candy.theme.bash index 7158a9e7..ef0ba262 100644 --- a/themes/candy/candy.theme.bash +++ b/themes/candy/candy.theme.bash @@ -1,2 +1,2 @@ #!/bin/bash -PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(git_prompt_info)\]${blue} →${bold_blue} \$${reset_color} " \ No newline at end of file +PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(scm_prompt_info)\]${blue} →${bold_blue} \$${reset_color} " \ No newline at end of file diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 88949fd0..2fc418f8 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -1,6 +1,6 @@ if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi -PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(git_prompt_info)\]$ " +PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " RPROMPT='[\t]' diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index 1f9b4fc9..95f243af 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -5,16 +5,16 @@ prompt_setter() { history -a history -c history -r - PS1="(\t) $(prompt_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(git_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " + PS1="(\t) $(scm_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(scm_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " PS2='> ' PS4='+ ' } PROMPT_COMMAND=prompt_setter -GIT_THEME_PROMPT_DIRTY=" ✗" -GIT_THEME_PROMPT_CLEAN=" ✓" -GIT_THEME_PROMPT_PREFIX=" (" -GIT_THEME_PROMPT_SUFFIX=")" +SCM_THEME_PROMPT_DIRTY=" ✗" +SCM_THEME_PROMPT_CLEAN=" ✓" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/simple/simple.theme.bash b/themes/simple/simple.theme.bash index 5a8d5d91..2dcd7e7c 100644 --- a/themes/simple/simple.theme.bash +++ b/themes/simple/simple.theme.bash @@ -11,16 +11,11 @@ case $TERM in TITLEBAR="" ;; esac -PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(git_prompt_info)\]${reset_color} " +PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${reset_color} " -# git themeing -# GIT_THEME_PROMPT_DIRTY=" ${red}✗" -# GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" -# GIT_THEME_PROMPT_PREFIX=" ${green}|" -# GIT_THEME_PROMPT_SUFFIX="${green}|" - -GIT_THEME_PROMPT_DIRTY=" ✗" -GIT_THEME_PROMPT_CLEAN=" ✓" -GIT_THEME_PROMPT_PREFIX="(" -GIT_THEME_PROMPT_SUFFIX=")" +# scm themeing +SCM_THEME_PROMPT_DIRTY=" ✗" +SCM_THEME_PROMPT_CLEAN=" ✓" +SCM_THEME_PROMPT_PREFIX="(" +SCM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/standard/standard.theme.bash b/themes/standard/standard.theme.bash index 61a9cbc3..5ba288c1 100644 --- a/themes/standard/standard.theme.bash +++ b/themes/standard/standard.theme.bash @@ -2,11 +2,11 @@ PROMPT='\[${green}\]\u\[${normal}\]@\[${green}\]\h\[${normal}\]:\[${blue}\]\w\[$ -# git themeing -GIT_THEME_PROMPT_DIRTY="×" -GIT_THEME_PROMPT_CLEAN="✓" -GIT_THEME_PROMPT_PREFIX="" -GIT_THEME_PROMPT_SUFFIX="" +# scm themeing +SCM_THEME_PROMPT_DIRTY="×" +SCM_THEME_PROMPT_CLEAN="✓" +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" # TODO: need a check for OS before adding this to the prompt # ${debian_chroot:+($debian_chroot)} diff --git a/themes/zitron/zitron.theme.bash b/themes/zitron/zitron.theme.bash index 980b19a1..c0726865 100644 --- a/themes/zitron/zitron.theme.bash +++ b/themes/zitron/zitron.theme.bash @@ -17,4 +17,4 @@ GIT_THEME_PROMPT_SUFFIX="" ## ls colors # thanks a lot to http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" -export LS_COLORS="no=00:fi=00:di=01;97:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" +export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" From e7cfe6d1dfd1591926979c7267354d19767e4221 Mon Sep 17 00:00:00 2001 From: John Schulz Date: Tue, 9 Nov 2010 23:52:25 -0500 Subject: [PATCH 02/14] Lost the wrapping for non-printable characters --- themes/bobby/bobby.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index f0f84476..c8d6204a 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -4,7 +4,7 @@ SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${green}|" -PROMPT="${bold_blue}\[\$(scm_char)\]${green}\$(scm_prompt_info)${blue}\$(rvm_version_prompt) ${orange}\h ${reset_color}in ${green}\w ${reset_color}\]\[→ " +PROMPT="\[${bold_blue}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt)\] \[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[→ " # git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" From 7ce4184c939fe141230344ded3add3de6492115d Mon Sep 17 00:00:00 2001 From: John Schulz Date: Wed, 10 Nov 2010 11:46:05 -0500 Subject: [PATCH 03/14] Alter test for `brew` to prevent false positive. `brew` reports 'no brew found in ...' to `stdout` (at least on Solaris) resulting in a false positive. --- completion/brew.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/brew.completion.bash b/completion/brew.completion.bash index a0d98193..371fe77f 100644 --- a/completion/brew.completion.bash +++ b/completion/brew.completion.bash @@ -1,4 +1,4 @@ -if [ `which brew` ]; then +if which brew >/dev/null 2>&1; then if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then . `brew --prefix`/Library/Contributions/brew_bash_completion.sh fi From 1148f42c5b117612b18bbb296b025f2e8be968b8 Mon Sep 17 00:00:00 2001 From: Robert R Evans Date: Wed, 10 Nov 2010 15:45:48 -0800 Subject: [PATCH 04/14] Updated bobby theme and merged in noqqe's additions --- themes/bobby/bobby.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 8eb50c54..c8e34473 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -1,6 +1,6 @@ #!/bin/bash -PROMPT="\[${bold_blue}\]\[\$(prompt_char)\]\[\$(git_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt) \]\[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[→ " +PROMPT="\[${bold_blue}\]\[\$(prompt_char)\]\[\$(git_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt) \]\[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[\n\[${bold_blue}\]→\[${reset_color}\] " # git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" From 7b1312002fccf4053adc5e7c8b53693f72c5f2f3 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 13 Nov 2010 10:21:59 -0600 Subject: [PATCH 05/14] Changed 'cd's to 'builtin cd's, because I have a modified cd command (cd then ls) and it can get annoying when using the Jekyll aliases. --- aliases/jekyll.aliases.bash | 16 ++++++++-------- plugins/jekyll.plugins.bash | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aliases/jekyll.aliases.bash b/aliases/jekyll.aliases.bash index a5078e32..11922d6c 100644 --- a/aliases/jekyll.aliases.bash +++ b/aliases/jekyll.aliases.bash @@ -1,27 +1,27 @@ -# Open the root of your site in your vim or cd to it +# Open the root of your site in your vim or builtin cd to it if [[ $EDITOR = "vim" ]] -then alias newentry="cd $JEKYLL_LOCAL_ROOT && $EDITOR ." -else alias newentry="cd $JEKYLL_LOCAL_ROOT" +then alias newentry="builtin cd $JEKYLL_LOCAL_ROOT && $EDITOR ." +else alias newentry="builtin cd $JEKYLL_LOCAL_ROOT" fi # Open the _posts/ directory for making a new blog post (seperate from above alias because not everyone uses jekyll for a blog) # if [ $editor = "vim" ] # then -# alias newpost="cd $jekyll_local_root/_posts && $editor ." +# alias newpost="builtin cd $jekyll_local_root/_posts && $editor ." # else -# alias newpost="cd $jekyll_local_root" +# alias newpost="builtin cd $jekyll_local_root" # fi # Build and locally serve the site -alias testsite="cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto" +alias testsite="builtin cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto" # Build but don't locally serve the site -alias buildsite="cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll" +alias buildsite="builtin cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll" # Rsync the site to the remote server -alias deploysite="cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT" +alias deploysite="builtin cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT" diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 1933f074..00ac7b0f 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -1,8 +1,8 @@ newpost() { - # 'cd' into the local jekyll root + # 'builtin cd' into the local jekyll root - cd "$JEKYLL_LOCAL_ROOT/_posts" + builtin cd "$JEKYLL_LOCAL_ROOT/_posts" # Get the date for the new post's filename From c8f94b08926181e190d6986d795ef1933e024b33 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 15 Nov 2010 20:03:35 -0600 Subject: [PATCH 06/14] Added shebang --- plugins/jekyll.plugins.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 00ac7b0f..9a044a99 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -1,3 +1,5 @@ +#!/bin/bash + newpost() { # 'builtin cd' into the local jekyll root From 12d8abda060e06a1704b26ea8411fde7b0089b60 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 15 Nov 2010 20:29:36 -0600 Subject: [PATCH 07/14] Added ability to choose post type with newpost() function. --- plugins/jekyll.plugins.bash | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index 9a044a99..adb39fcc 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -10,6 +10,44 @@ newpost() { FNAME_DATE=$(date "+%Y-%m-%d") + # If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr. + # TODO: Add support for Textile formatting too. + + OPTIONS="Text Quote Image Audio Video" + + select OPTION in $OPTIONS + do + if [[ $OPTION = "Text" ]] + then + POST_TYPE="Text" + break + fi + + if [[ $OPTION = "Quote" ]] + then + POST_TYPE="Quote" + break + fi + + if [[ $OPTION = "Image" ]] + then + POST_TYPE="Image" + break + fi + + if [[ $OPTION = "Audio" ]] + then + POST_TYPE="Audio" + break + fi + + if [[ $OPTION = "Video" ]] + then + POST_TYPE="Video" + break + fi + done + # Get the title for the new post read -p "Enter title of the new post: " POST_TITLE @@ -52,6 +90,35 @@ newpost() { echo "---" >> $FNAME echo >> $FNAME + # Generate template text based on the post type + + if [[ $POST_TYPE = "Text" ]] + then + true + fi + + if [[ $POST_TYPE = "Quote" ]] + then + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi + + if [[ $POST_TYPE = "Image" ]] + then + echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME + fi + + if [[ $POST_TYPE = "Audio" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME + fi + # Open the file in your favorite editor $EDITOR $FNAME From 14c78bff05efa06b98bfe875281f9866ecca949b Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 15 Nov 2010 20:31:38 -0600 Subject: [PATCH 08/14] Added check to make sure the user is using Markdown formatting with newpost() --- plugins/jekyll.plugins.bash | 106 +++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index adb39fcc..ef8888c6 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -14,39 +14,42 @@ newpost() { # TODO: Add support for Textile formatting too. OPTIONS="Text Quote Image Audio Video" - - select OPTION in $OPTIONS - do - if [[ $OPTION = "Text" ]] - then - POST_TYPE="Text" - break - fi - - if [[ $OPTION = "Quote" ]] - then - POST_TYPE="Quote" - break - fi - if [[ $OPTION = "Image" ]] - then - POST_TYPE="Image" - break - fi + if [[ $JEKYLL_FORMATTING = "markdown" ]] + then + select OPTION in $OPTIONS + do + if [[ $OPTION = "Text" ]] + then + POST_TYPE="Text" + break + fi - if [[ $OPTION = "Audio" ]] - then - POST_TYPE="Audio" - break - fi + if [[ $OPTION = "Quote" ]] + then + POST_TYPE="Quote" + break + fi + + if [[ $OPTION = "Image" ]] + then + POST_TYPE="Image" + break + fi - if [[ $OPTION = "Video" ]] - then - POST_TYPE="Video" - break - fi - done + if [[ $OPTION = "Audio" ]] + then + POST_TYPE="Audio" + break + fi + + if [[ $OPTION = "Video" ]] + then + POST_TYPE="Video" + break + fi + done + fi # Get the title for the new post @@ -92,31 +95,34 @@ newpost() { # Generate template text based on the post type - if [[ $POST_TYPE = "Text" ]] + if [[ $JEKYLL_FORMATTING = "markdown" ]] then - true - fi + if [[ $POST_TYPE = "Text" ]] + then + true + fi - if [[ $POST_TYPE = "Quote" ]] - then - echo "> Quote" >> $FNAME - echo >> $FNAME - echo "— Author" >> $FNAME - fi + if [[ $POST_TYPE = "Quote" ]] + then + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi - if [[ $POST_TYPE = "Image" ]] - then - echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME - fi + if [[ $POST_TYPE = "Image" ]] + then + echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME + fi - if [[ $POST_TYPE = "Audio" ]] - then - echo "" >> $FNAME - fi + if [[ $POST_TYPE = "Audio" ]] + then + echo "" >> $FNAME + fi - if [[ $POST_TYPE = "Video" ]] - then - echo "" >> $FNAME + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME + fi fi # Open the file in your favorite editor From 415d8b7458f6d77c072fc1cecdd7761008666b18 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Mon, 15 Nov 2010 20:42:36 -0600 Subject: [PATCH 09/14] Added support for Textile formatting in newpost() --- plugins/jekyll.plugins.bash | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash index ef8888c6..9b0d5c1e 100644 --- a/plugins/jekyll.plugins.bash +++ b/plugins/jekyll.plugins.bash @@ -11,11 +11,10 @@ newpost() { FNAME_DATE=$(date "+%Y-%m-%d") # If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr. - # TODO: Add support for Textile formatting too. OPTIONS="Text Quote Image Audio Video" - if [[ $JEKYLL_FORMATTING = "markdown" ]] + if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ] then select OPTION in $OPTIONS do @@ -116,12 +115,42 @@ newpost() { if [[ $POST_TYPE = "Audio" ]] then - echo "" >> $FNAME + echo "" >> $FNAME fi if [[ $POST_TYPE = "Video" ]] then - echo "" >> $FNAME + echo "" >> $FNAME + fi + fi + + if [[ $JEKYLL_FORMATTING = "textile" ]] + then + if [[ $POST_TYPE = "Text" ]] + then + true + fi + + if [[ $POST_TYPE = "Quote" ]] + then + echo "bq. Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi + + if [[ $POST_TYPE = "Image" ]] + then + echo "!url(alt text)" >> $FNAME + fi + + if [[ $POST_TYPE = "Audio" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME fi fi From cb681121e42572f312edc463d6b9e9e98087026d Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Wed, 17 Nov 2010 17:09:16 -0600 Subject: [PATCH 10/14] Added custom PS3 (prompt used with "select", for instance with the new, newpost comman) for minimal theme --- themes/minimal/minimal.theme.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/minimal/minimal.theme.bash b/themes/minimal/minimal.theme.bash index e70165d2..2f9b926e 100644 --- a/themes/minimal/minimal.theme.bash +++ b/themes/minimal/minimal.theme.bash @@ -7,3 +7,5 @@ prompt_setter() { } PROMPT_COMMAND=prompt_setter + +export PS3=">> " From 4350c3f13fbe2f615012d1e9bf147d578d77c31f Mon Sep 17 00:00:00 2001 From: Fedyashev Nikita Date: Thu, 18 Nov 2010 23:42:30 -0500 Subject: [PATCH 11/14] Vagrant autocompletion: base working version --- plugins/vagrant.plugins.bash | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/vagrant.plugins.bash diff --git a/plugins/vagrant.plugins.bash b/plugins/vagrant.plugins.bash new file mode 100644 index 00000000..3d05f7ec --- /dev/null +++ b/plugins/vagrant.plugins.bash @@ -0,0 +1,34 @@ +#!/bin/bash +_vagrant() +{ + local cur prev commands + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + # The commands we will complete + commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version" + + case "${prev}" in + "remove"|"repackage") + #local vagrantlist=$(gem list -l|grep '([0-9].*)'|awk 'BEGIN {ORS=" "} { print $1}'|sort) + #local vagrantlist=$(command ls --color=none -l $HOME/.vagrant/boxes 2>/dev/null | sed -e 's/ /\\ /g' | awk 'BEGIN {ORS=" "} {print $2}' ) + local vagrantlist=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') + COMPREPLY=($(compgen -W "${vagrantlist}" -- ${cur})) + return 0 + ;; + "box") + commands="add help list remove repackage" + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + return 0 +} +complete -F _vagrant vagrant +complete -F _vagrant vagrant-e + From 5f6125e480267a2bcd52827f4430b7cec2ab35df Mon Sep 17 00:00:00 2001 From: Fedyashev Nikita Date: Fri, 19 Nov 2010 00:22:13 -0500 Subject: [PATCH 12/14] refactored version; valid workflow --- plugins/vagrant.plugins.bash | 56 +++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/plugins/vagrant.plugins.bash b/plugins/vagrant.plugins.bash index 3d05f7ec..27b3761f 100644 --- a/plugins/vagrant.plugins.bash +++ b/plugins/vagrant.plugins.bash @@ -1,34 +1,44 @@ #!/bin/bash _vagrant() { - local cur prev commands - COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - # The commands we will complete - commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version" - case "${prev}" in - "remove"|"repackage") - #local vagrantlist=$(gem list -l|grep '([0-9].*)'|awk 'BEGIN {ORS=" "} { print $1}'|sort) - #local vagrantlist=$(command ls --color=none -l $HOME/.vagrant/boxes 2>/dev/null | sed -e 's/ /\\ /g' | awk 'BEGIN {ORS=" "} {print $2}' ) - local vagrantlist=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') - COMPREPLY=($(compgen -W "${vagrantlist}" -- ${cur})) - return 0 - ;; - "box") - commands="add help list remove repackage" - COMPREPLY=($(compgen -W "${commands}" -- ${cur})) - return 0 - ;; - *) - ;; - esac + if [ $COMP_CWORD == 1 ] + then + commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version" + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + return 0 + fi + + if [ $COMP_CWORD == 2 ] + then + if [ $prev == 'box' ] + then + commands="add help list remove repackage" + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + return 0 + fi + fi + + if [ $COMP_CWORD == 3 ] + then + action="${COMP_WORDS[COMP_CWORD-2]}" + if [ $action == 'box' ] + then + case "$prev" in + "remove"|"repackage") + local vagrantlist=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') + COMPREPLY=($(compgen -W "${vagrantlist}" -- ${cur})) + return 0 + ;; + *) + ;; + esac + fi + fi - COMPREPLY=($(compgen -W "${commands}" -- ${cur})) - return 0 } complete -F _vagrant vagrant -complete -F _vagrant vagrant-e From 7f721fe5e7bc9d845d177beb044c096d95b155b8 Mon Sep 17 00:00:00 2001 From: Fedyashev Nikita Date: Fri, 19 Nov 2010 00:27:14 -0500 Subject: [PATCH 13/14] completion to help command added --- plugins/vagrant.plugins.bash | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/plugins/vagrant.plugins.bash b/plugins/vagrant.plugins.bash index 27b3761f..17aff4ea 100644 --- a/plugins/vagrant.plugins.bash +++ b/plugins/vagrant.plugins.bash @@ -3,23 +3,29 @@ _vagrant() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - + commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version" if [ $COMP_CWORD == 1 ] then - commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version" COMPREPLY=($(compgen -W "${commands}" -- ${cur})) return 0 fi if [ $COMP_CWORD == 2 ] then - if [ $prev == 'box' ] - then - commands="add help list remove repackage" - COMPREPLY=($(compgen -W "${commands}" -- ${cur})) - return 0 - fi + case "$prev" in + "box") + box_commands="add help list remove repackage" + COMPREPLY=($(compgen -W "${box_commands}" -- ${cur})) + return 0 + ;; + "help") + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + return 0 + ;; + *) + ;; + esac fi if [ $COMP_CWORD == 3 ] @@ -29,8 +35,8 @@ _vagrant() then case "$prev" in "remove"|"repackage") - local vagrantlist=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') - COMPREPLY=($(compgen -W "${vagrantlist}" -- ${cur})) + local box_list=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') + COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) return 0 ;; *) From 62295973ca3bce1990a859b1f085b62cf9fd4d55 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 20 Nov 2010 16:27:47 -0600 Subject: [PATCH 14/14] 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