From b36d86ddff8f83c691e761d1f9a9789ca8d52fbd Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 11:36:11 -0500 Subject: [PATCH 01/51] Add minimal-git theme Just like the minimal theme, but with git info --- themes/minimal-git/minimal-git.theme.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 themes/minimal-git/minimal-git.theme.bash diff --git a/themes/minimal-git/minimal-git.theme.bash b/themes/minimal-git/minimal-git.theme.bash new file mode 100644 index 00000000..1862f7ff --- /dev/null +++ b/themes/minimal-git/minimal-git.theme.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +SCM_THEME_PROMPT_PREFIX="${cyan}(${green}" +SCM_THEME_PROMPT_SUFFIX="${cyan})" +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" + +PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " From 989de733309ef79308b3806268ad35467f7ee9b8 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 12:06:30 -0500 Subject: [PATCH 02/51] No more bold --- themes/minimal-git/minimal-git.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/minimal-git/minimal-git.theme.bash b/themes/minimal-git/minimal-git.theme.bash index 1862f7ff..b4c34627 100644 --- a/themes/minimal-git/minimal-git.theme.bash +++ b/themes/minimal-git/minimal-git.theme.bash @@ -3,6 +3,6 @@ SCM_THEME_PROMPT_PREFIX="${cyan}(${green}" SCM_THEME_PROMPT_SUFFIX="${cyan})" SCM_THEME_PROMPT_DIRTY=" ${red}✗" -SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " From 4e14eefca83e7386e02aa1013b11353583c5a134 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 12:08:36 -0500 Subject: [PATCH 03/51] Works now --- themes/minimal-git/minimal-git.theme.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/minimal-git/minimal-git.theme.bash b/themes/minimal-git/minimal-git.theme.bash index b4c34627..76cb24d5 100644 --- a/themes/minimal-git/minimal-git.theme.bash +++ b/themes/minimal-git/minimal-git.theme.bash @@ -5,4 +5,8 @@ SCM_THEME_PROMPT_SUFFIX="${cyan})" SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${green}✓" -PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " +prompt() { + PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " +} + +PROMPT_COMMAND=prompt From 5af99be158656bbcb5f4d56fb799e3313837bb53 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 17:45:13 -0500 Subject: [PATCH 04/51] Get rid of old jekyll aliases --- aliases/available/jekyll.aliases.bash | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 aliases/available/jekyll.aliases.bash diff --git a/aliases/available/jekyll.aliases.bash b/aliases/available/jekyll.aliases.bash deleted file mode 100644 index e52c0351..00000000 --- a/aliases/available/jekyll.aliases.bash +++ /dev/null @@ -1,20 +0,0 @@ -# Open the root of your site in your vim or builtin cd to it - -if [[ $EDITOR = "vim" ]] -then - alias newentry="builtin cd $JEKYLL_LOCAL_ROOT && $EDITOR ." -else - alias newentry="builtin cd $JEKYLL_LOCAL_ROOT" -fi - -# Build and locally serve the site - -alias testsite="builtin cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto" - -# Build but don't locally serve the site - -alias buildsite="builtin cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll" - -# Rsync the site to the remote server - -alias deploysite="builtin cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT" From 10ac7731703eaeecc9b4fb3d7e601569cbe5c980 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 17:45:37 -0500 Subject: [PATCH 05/51] Get rid of old, unneeded jekyll config stuff --- template/bash_profile.template.bash | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 30ab0fc1..95f481e9 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -26,18 +26,6 @@ export NGINX_PATH='/opt/nginx' # Don't check mail when opening terminal. unset MAILCHECK -# Change this to the path of your local jekyll root to use the jekyll aliases - -export JEKYLL_LOCAL_ROOT="$HOME/Sites/jekyllsite" - -# And change this to the remote server and root - -export JEKYLL_REMOTE_ROOT="user@server:/path/to/jekyll/root" - -# And, for the last of the jekyll variables, this is the formatting you use, eg: markdown, -# textile, etc. Basically whatever you use as the extension for posts, without the preceding dot - -export JEKYLL_FORMATTING="markdown" # Change this to your console based IRC client of choice. From 56b83c76cbc1b8d257103982563a6690e36068a0 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 17:45:55 -0500 Subject: [PATCH 06/51] Add new jekyll config stuff --- template/jekyllconfig.template.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 template/jekyllconfig.template.bash diff --git a/template/jekyllconfig.template.bash b/template/jekyllconfig.template.bash new file mode 100644 index 00000000..e4705181 --- /dev/null +++ b/template/jekyllconfig.template.bash @@ -0,0 +1,17 @@ +# This is a space-delimited list of your Jekyll project paths + +SITES="$HOME/sites/project_1 $HOME/sites/project_2" + +# This is another space-delimited list. +# This one is of the remote user@host:path location of your jekyll site +# NOTE: The locations of these must correspond to the locations +# of the sites in the first list +# For instance, the host for the first Jekyll site +# must be first in this list, the second second, etc. + +REMOTES="user@host_1:path user@host_2:path" + +# list of markup syntaxes to use for the sites, +# Same rules as above. Can be HTML, textile, or markdown + +MARKUPS="markdown textile" From 9ad7964c861504d9ef030dd11742d5dc00e4320a Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 17:49:19 -0500 Subject: [PATCH 07/51] Add support for multiple Jekyll sites --- bash_it.sh | 7 + plugins/available/jekyll.plugins.bash | 448 +++++++++++++++++--------- 2 files changed, 300 insertions(+), 155 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index a030069e..7734c10c 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -56,6 +56,13 @@ PREVIEW="less" [ -s /usr/bin/gloobus-preview ] && PREVIEW="gloobus-preview" [ -s /Applications/Preview.app ] && PREVIEW="/Applications/Preview.app" +# Load all the Jekyll stuff + +if [ -e $HOME/.jekyllconfig ] +then + . $HOME/.jekyllconfig +fi + # # Custom Help diff --git a/plugins/available/jekyll.plugins.bash b/plugins/available/jekyll.plugins.bash index aebe69bc..8efdd11f 100644 --- a/plugins/available/jekyll.plugins.bash +++ b/plugins/available/jekyll.plugins.bash @@ -1,208 +1,346 @@ #!/bin/bash editpost() { - builtin cd "$JEKYLL_LOCAL_ROOT/_posts" + unset SITE + if [ -z "$1" ] + then + echo "Error: no site specified." + echo "The site is the name of the directory your project is in." + return 1 + fi - COUNTER=1 - NUMBER="$RANDOM" - TMPFILE="/tmp/editpost-$NUMBER" + for site in ${SITES[@]} + do + if [ "$(basename $site)" = "$1" ] + then + SITE=$site + break + fi + done - 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: //'` - 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 + if [ -z "$SITE" ] + then + echo "No such site." + return 1 + fi + + builtin cd "$SITE/_posts" + + 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: //'` + 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() { + unset SITE + if [ -z "$1" ] + then + echo "Error: no site specified." + echo "The site is the name of the directory your project is in." + return 1 + fi - # 'builtin cd' into the local jekyll root + if [ -z "$SITE" ] + then + echo "No such site." + return 1 + fi - builtin cd "$JEKYLL_LOCAL_ROOT/_posts" + loc=0 - # Get the date for the new post's filename + for site in ${SITES[@]} + do + if [ "$(basename $site)" = "$1" ] + then + SITE=$site + JEKYLL_FORMATTING=${MARKUPS[$loc]} + break + fi + loc=$(($loc+1)) + done - FNAME_DATE=$(date "+%Y-%m-%d") + # 'builtin cd' into the local jekyll root - # If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr. + builtin cd "$SITE/_posts" - OPTIONS="Text Quote Image Audio Video Link" - - if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ] - then - select OPTION in $OPTIONS - do - if [[ $OPTION = "Text" ]] - then - POST_TYPE="Text" - break - fi + # Get the date for the new post's filename - if [[ $OPTION = "Quote" ]] - then - POST_TYPE="Quote" - break - fi - - if [[ $OPTION = "Image" ]] - then - POST_TYPE="Image" - break - fi + FNAME_DATE=$(date "+%Y-%m-%d") - if [[ $OPTION = "Audio" ]] - then - POST_TYPE="Audio" - break - fi + # If the user is using markdown or textile formatting, let them choose what type of post they want. Sort of like Tumblr. - if [[ $OPTION = "Video" ]] - then - POST_TYPE="Video" - break - fi + OPTIONS="Text Quote Image Audio Video Link" - if [[ $OPTION = "Link" ]] - then - POST_TYPE="Link" - break - fi - done - fi + if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ] + then + select OPTION in $OPTIONS + do + if [[ $OPTION = "Text" ]] + then + POST_TYPE="Text" + break + fi - # Get the title for the new post + if [[ $OPTION = "Quote" ]] + then + POST_TYPE="Quote" + break + fi - read -p "Enter title of the new post: " POST_TITLE + if [[ $OPTION = "Image" ]] + then + POST_TYPE="Image" + break + fi - # Convert the spaces in the title to hyphens for use in the filename + if [[ $OPTION = "Audio" ]] + then + POST_TYPE="Audio" + break + fi - FNAME_POST_TITLE=`echo $POST_TITLE | tr ' ' "-"` + if [[ $OPTION = "Video" ]] + then + POST_TYPE="Video" + break + fi - # Now, put it all together for the full filename + if [[ $OPTION = "Link" ]] + then + POST_TYPE="Link" + break + fi + done + fi - FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING" + # Get the title for the new post - # And, finally, create the actual post file. But we're not done yet... + read -p "Enter title of the new post: " POST_TITLE - touch "$FNAME" + # Convert the spaces in the title to hyphens for use in the filename - # Write a little stuff to the file for the YAML Front Matter + FNAME_POST_TITLE=`echo $POST_TITLE | tr ' ' "-"` - echo "---" >> $FNAME + # Now, put it all together for the full filename - # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of - # the file + FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING" - YAML_DATE=$(date "+%B %d %Y %X") + # And, finally, create the actual post file. But we're not done yet... - # Echo the YAML Formatted date to the post file + touch "$FNAME" - echo "date: $YAML_DATE" >> $FNAME + # Write a little stuff to the file for the YAML Front Matter - # Echo the original post title to the YAML Front Matter header + echo "---" >> $FNAME - echo "title: $POST_TITLE" >> $FNAME + # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of + # the file - # And, now, echo the "post" layout to the YAML Front Matter header + YAML_DATE=$(date "+%B %d %Y %X") - echo "layout: post" >> $FNAME + # Echo the YAML Formatted date to the post file - # Close the YAML Front Matter Header + echo "date: $YAML_DATE" >> $FNAME - echo "---" >> $FNAME - echo >> $FNAME + # Echo the original post title to the YAML Front Matter header - # Generate template text based on the post type + echo "title: $POST_TITLE" >> $FNAME - if [[ $JEKYLL_FORMATTING = "markdown" ]] - then - if [[ $POST_TYPE = "Text" ]] - then - true - fi + # And, now, echo the "post" layout to the YAML Front Matter header - if [[ $POST_TYPE = "Quote" ]] - then - echo "> Quote" >> $FNAME - echo >> $FNAME - echo "— Author" >> $FNAME - fi + echo "layout: post" >> $FNAME - if [[ $POST_TYPE = "Image" ]] - then - echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME - fi + # Close the YAML Front Matter Header - if [[ $POST_TYPE = "Audio" ]] - then - echo "" >> $FNAME - fi + echo "---" >> $FNAME + echo >> $FNAME - if [[ $POST_TYPE = "Video" ]] - 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 + # Generate template text based on the post type - if [[ $JEKYLL_FORMATTING = "textile" ]] - then - if [[ $POST_TYPE = "Text" ]] - then - true - fi + if [[ $JEKYLL_FORMATTING = "markdown" ]] + 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 = "Quote" ]] + then + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi - if [[ $POST_TYPE = "Image" ]] - then - echo "!url(alt text)" >> $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 - fi + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME + fi - if [[ $POST_TYPE = "Link" ]] - then - echo "\"Site\":url" >> $FNAME - echo >> $FNAME - echo "bq. Quote" >> $FNAME - fi - fi + if [[ $POST_TYPE = "Link" ]] + then + echo "[link][1]" >> $FNAME + echo >> $FNAME + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "[1]: url" >> $FNAME + fi + fi - # Open the file in your favorite editor + if [[ $JEKYLL_FORMATTING = "textile" ]] + then + if [[ $POST_TYPE = "Text" ]] + then + true + fi - "$EDITOR" $FNAME + 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 + + if [[ $POST_TYPE = "Link" ]] + then + echo "\"Site\":url" >> $FNAME + echo >> $FNAME + echo "bq. Quote" >> $FNAME + fi + fi + + # Open the file in your favorite editor + + "$EDITOR" $FNAME +} + +function testsite() { + unset SITE + if [ -z "$1" ] + then + echo "Error: no site specified." + echo "The site is the name of the directory your project is in." + return 1 + fi + + for site in ${SITES[@]} + do + if [ "$(basename $site)" = "$1" ] + then + SITE=$site + break + fi + done + + if [ -z "$SITE" ] + then + echo "No such site." + return 1 + fi + + builtin cd $SITE + jekyll --server --auto +} + +function buildsite() { + unset SITE + if [ -z "$1" ] + then + echo "Error: no site specified." + echo "The site is the name of the directory your project is in." + return 1 + fi + + for site in ${SITES[@]} + do + if [ "$(basename $site)" = "$1" ] + then + SITE=$site + break + fi + done + + if [ -z "$SITE" ] + then + echo "No such site." + return 1 + fi + + builtin cd $SITE + rm -rf _site + jekyll --no-server +} + +function deploysite() { + unset SITE + if [ -z "$1" ] + then + echo "Error: no site specified." + echo "The site is the name of the directory your project is in." + return 1 + fi + + loc=0 + + for site in ${SITES[@]} + do + if [ "$(basename $site)" = "$1" ] + then + SITE=$site + REMOTE=${REMOTES[$loc]} + break + fi + loc=$(($loc+1)) + done + + if [ -z "$SITE" ] + then + echo "No such site." + return 1 + fi + + builtin cd $SITE + rsync -rz $REMOTE } From 4ac4049a7595e1d694e7283dba7714e5aff14569 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 24 Jun 2011 17:50:02 -0500 Subject: [PATCH 08/51] Add note for configuring Jekyll support --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index c8412c92..5af3056e 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ Check a clone of this repo. You can view what a sample `~/.bash_profile` looks l cp ~/.bash_profile ~/.bash_profile_original cp /template/bash_profile.template.bash ~/.bash_profile +To configure Jekyll support for bash it, move the +jekyllconfig.template.bash to your home directory: + + cp /template/jekyllconfig.template.bash ~/.jekyllconfig + +Be sure to edit this file to your needed specifications. Please note +that this file is *not* required. Only use it if you plan on using the +jekyll plugins. ## Help Screens From 6e8733ea98d09ca5d87f07a9e4a1b696b2a6fe0e Mon Sep 17 00:00:00 2001 From: Jeff Carouth Date: Sat, 25 Jun 2011 10:05:25 -0500 Subject: [PATCH 09/51] Adding multiple SCM support to doubletime theme. The doubletime theme improves the SCM status prompt for git. However, it accomplishes this at the expense of other SCM systems. This delegates prompt to the default bash-it prompt function when the SCM is not git. --- themes/doubletime/doubletime.theme.bash | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 1237f80f..e16ba66c 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -17,11 +17,12 @@ fi doubletime_scm_prompt() { CHAR=$(scm_char) - if [ $CHAR = $SCM_NONE_CHAR ] - then + if [ $CHAR = $SCM_NONE_CHAR ]; then return - else + elif [ $CHAR = $SCM_GIT_CHAR ]; then echo "$(git_prompt_status)" + else + echo "[$(scm_prompt_info)]" fi } From ff0859d28966035e310277ef3e8701b1fe119d80 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 25 Jun 2011 11:50:56 -0500 Subject: [PATCH 10/51] Move minimal-git theme into minimal theme --- themes/minimal/minimal.theme.bash | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/themes/minimal/minimal.theme.bash b/themes/minimal/minimal.theme.bash index 8de4a6c7..76cb24d5 100644 --- a/themes/minimal/minimal.theme.bash +++ b/themes/minimal/minimal.theme.bash @@ -1,7 +1,12 @@ -prompt_setter() { - PS1="${cyan}\W${normal} " +#!/usr/bin/env bash + +SCM_THEME_PROMPT_PREFIX="${cyan}(${green}" +SCM_THEME_PROMPT_SUFFIX="${cyan})" +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" + +prompt() { + PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " } -PROMPT_COMMAND=prompt_setter - -export PS3=">> " +PROMPT_COMMAND=prompt From 052da726df55cf7019b08f897d3d3dc1371d2d85 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 25 Jun 2011 11:52:50 -0500 Subject: [PATCH 11/51] Get rid of old minimal-git theme --- themes/minimal-git/minimal-git.theme.bash | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 themes/minimal-git/minimal-git.theme.bash diff --git a/themes/minimal-git/minimal-git.theme.bash b/themes/minimal-git/minimal-git.theme.bash deleted file mode 100644 index 76cb24d5..00000000 --- a/themes/minimal-git/minimal-git.theme.bash +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -SCM_THEME_PROMPT_PREFIX="${cyan}(${green}" -SCM_THEME_PROMPT_SUFFIX="${cyan})" -SCM_THEME_PROMPT_DIRTY=" ${red}✗" -SCM_THEME_PROMPT_CLEAN=" ${green}✓" - -prompt() { - PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " -} - -PROMPT_COMMAND=prompt From 93df02f19389151f9bc5f0420024605289081f63 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 26 Jun 2011 09:30:16 -0500 Subject: [PATCH 12/51] Fix irregular usage of bash it vs. bash-it --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5af3056e..e5c7aae2 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ and anything in the custom directory will be ignored with the exception of `cust ## Themes -There are a few bash-it themes, but I'm hoping the community will jump in and create their own custom prompts and share their creations with everyone else by submitting a pull request to me (revans). +There are a few bash it themes, but I'm hoping the community will jump in and create their own custom prompts and share their creations with everyone else by submitting a pull request to me (revans). ## Help out -I think all of us have our own custom scripts that we have added over time and so following in the footsteps of oh-my-zsh, bash-it was created as a framework for those who choose to use bash as their shell. As a community, I'm excited to see what everyone else has in their custom toolbox and am hoping that they'll share it with everyone by submitting a pull request to bash-it. +I think all of us have our own custom scripts that we have added over time and so following in the footsteps of oh-my-zsh, bash it was created as a framework for those who choose to use bash as their shell. As a community, I'm excited to see what everyone else has in their custom toolbox and am hoping that they'll share it with everyone by submitting a pull request to bash it. -So, if you have contributions to bash-it, please send me a pull request and I'll take a look at it and commit it to the repo as long as it looks good. If you do change an existing command, please give an explanation as to why. That will help a lot when I merge your changes in. Thanks, and happing bashing! +So, if you have contributions to bash it, please send me a pull request and I'll take a look at it and commit it to the repo as long as it looks good. If you do change an existing command, please give an explanation as to why. That will help a lot when I merge your changes in. Thanks, and happing bashing! ## Contributors From e1eb0114ed1d152d3c32dec8d8a8167817c93ed0 Mon Sep 17 00:00:00 2001 From: Adrian Rego Date: Mon, 27 Jun 2011 20:00:27 -0400 Subject: [PATCH 13/51] relieving headaches with a tylenol theme --- themes/tylenol/tylenol.theme.bash | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 themes/tylenol/tylenol.theme.bash diff --git a/themes/tylenol/tylenol.theme.bash b/themes/tylenol/tylenol.theme.bash new file mode 100644 index 00000000..c915f561 --- /dev/null +++ b/themes/tylenol/tylenol.theme.bash @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Based on 'bobby' theme with the addition of virtualenv_prompt +# + +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" +SCM_THEME_PROMPT_PREFIX=" ${yellow}|${reset_color}" +SCM_THEME_PROMPT_SUFFIX="${yellow}|" + +RVM_THEME_PROMPT_PREFIX="|" +RVM_THEME_PROMPT_SUFFIX="|" +VIRTUALENV_THEME_PROMPT_PREFIX='|' +VIRTUALENV_THEME_PROMPT_SUFFIX='|' + +function prompt_command() { + PS1="\n${green}$(virtualenv_prompt)${red}$(rvm_version_prompt) ${reset_color}\h ${orange}in ${reset_color}\w\n${yellow}$(scm_char)$(scm_prompt_info) ${yellow}→${white} " +} + +PROMPT_COMMAND=prompt_command; From d82d8fbbe8fe0ab67781136177684d34b79d71ca Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Tue, 28 Jun 2011 00:22:43 -0500 Subject: [PATCH 14/51] Add install script --- install.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..3fc647b4 --- /dev/null +++ b/install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +cp $HOME/.bash_profile $HOME/.bash_profile.bak + +echo "Your original .bash_profile has been backed up to .bash_profile.bak" + +cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/.bash_profile + +echo "Copied the template .bash_profile into ~/.bash_profile, edit this file to customize bash-it" + +while true +do + read -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [Y/N] " RESP + + case $RESP + in + [yY]) + cp $HOME/.bash_it/template/jekyllconfig.template.bash $HOME/.jekyllconfig + echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins" + break + ;; + [nN]) + break + ;; + *) + echo "Please enter Y or N" + esac +done From b7c4b36ed247a90636200c4e9610e0a1032d85b9 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Tue, 28 Jun 2011 00:22:51 -0500 Subject: [PATCH 15/51] Add instructions for installing with the installation script --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e5c7aae2..89f3d0d0 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,17 @@ Includes some autocompletion tools, theming support, aliases, custom functions, ## Install -Check a clone of this repo. You can view what a sample `~/.bash_profile` looks like in `template/bash_profile.template.bash`. If you wanted to use that template, make sure to make a backup of your current `~/.bash_profile` file. +Check a clone of this repo: git clone http://github.com/revans/bash-it.git bash_it - cp ~/.bash_profile ~/.bash_profile_original - cp /template/bash_profile.template.bash ~/.bash_profile +Then run the `install.sh` file, it will backup your `~/.bash_profile` +file and move the template one into it's place (the template file is at +`~/.bash_it/template/bash_profile.template.bash`). It will also prompt +you asking if you use [Jekyll](https://github.com/mojombo/jekyll). This +is to set up the `.jekyllconfig` file, the file that stores the +information needed to use the Jekyll plugin supplied with bash it. -To configure Jekyll support for bash it, move the -jekyllconfig.template.bash to your home directory: - - cp /template/jekyllconfig.template.bash ~/.jekyllconfig - -Be sure to edit this file to your needed specifications. Please note -that this file is *not* required. Only use it if you plan on using the -jekyll plugins. ## Help Screens From ed8332d8d4161ff7ffeaa21f2bfe678466f0caa3 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Tue, 28 Jun 2011 00:25:26 -0500 Subject: [PATCH 16/51] Add clarification to README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89f3d0d0..933b333c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,10 @@ Check a clone of this repo: Then run the `install.sh` file, it will backup your `~/.bash_profile` file and move the template one into it's place (the template file is at -`~/.bash_it/template/bash_profile.template.bash`). It will also prompt +`~/.bash_it/template/bash_profile.template.bash`). Be sure to edit this +template file in order to customize bash-it. + +The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll). This is to set up the `.jekyllconfig` file, the file that stores the information needed to use the Jekyll plugin supplied with bash it. From f6950f9f7bcff2b58aff995b4fddde438d1c1a1b Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Wed, 29 Jun 2011 11:33:39 -0500 Subject: [PATCH 17/51] Add gem completion --- completion/available/gem.completion.bash | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 completion/available/gem.completion.bash diff --git a/completion/available/gem.completion.bash b/completion/available/gem.completion.bash new file mode 100644 index 00000000..7231eef0 --- /dev/null +++ b/completion/available/gem.completion.bash @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Completion for gem + +if [ -z "$REMOTE_GEMS" ] +then + REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) +fi + +if [ -z "$LOCAL_GEMS" ] +then + LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) +fi + +_installcomp() { + local cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) ) +} + +_uninstallcomp() { + local cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) ) +} + +_gem() { + local cur=${COMP_WORDS[COMP_CWORD]} + local prev=${COMP_WORDS[COMP_CWORD-1]} + case $prev in + install) + _installcomp + return 0 + ;; + uninstall) + _uninstallcomp + return 0 + ;; + esac + local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which) + COMPREPLY=( $(compgen -W "${commands[*]}" -- $cur) ) +} + +complete -F _gem gem From 1a969458858a5ad892ab9a6b36592cf50348d162 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Thu, 30 Jun 2011 08:30:46 -0500 Subject: [PATCH 18/51] Fix grammar on error message --- plugins/available/osx.plugin.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index e6271bd7..76e4b9a5 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -17,7 +17,7 @@ EOF function dock-switch() { if [ $(uname) = "Darwin" ]; then - + if [ $1 = 3d ] ; then defaults write com.apple.dock no-glass -boolean NO killall Dock @@ -28,10 +28,10 @@ function dock-switch() { else echo "usage:" - echo "dock-switch 2d" + echo "dock-switch 2d" echo "dock-switch 3d." fi else - echo "sorry. you're currently not using os x" + echo "Sorry, this only works on Mac OS X" fi } From c5b5a1982f335e34bc20f644f496aa1664a0bf98 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 Jun 2011 08:15:26 -0700 Subject: [PATCH 19/51] Edited README.md for punctuation, phrasing, tone, and clarity. --- README.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 933b333c..f5b9201b 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,53 @@ # 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](https://github.com/robbyrussell/oh-my-zsh). :) +**Bash it** is a mash up of my own bash commands and scripts, other bash stuff I have found. -Includes some autocompletion tools, theming support, aliases, custom functions, a few stolen pieces from Steve Losh, and more. +(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh). :) + +Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. ## Install -Check a clone of this repo: +1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git bash_it` +2. Run `install.sh` (it automatically backs up your `~/.bash_profile`) +3. Move `~/.bash_it/template/bash_profile.template.bash` into its place. (Edit this template file in order to customize bash-it.) - git clone http://github.com/revans/bash-it.git bash_it - -Then run the `install.sh` file, it will backup your `~/.bash_profile` -file and move the template one into it's place (the template file is at -`~/.bash_it/template/bash_profile.template.bash`). Be sure to edit this -template file in order to customize bash-it. - -The install script will also prompt -you asking if you use [Jekyll](https://github.com/mojombo/jekyll). This -is to set up the `.jekyllconfig` file, the file that stores the -information needed to use the Jekyll plugin supplied with bash it. +**NOTE:** +The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll). +This is to set up the `.jekyllconfig` file, which stores info necessary to use the Jekyll plugin. ## Help Screens - bash-it (will show all the help commands) - aliases-help - rails-help - git-help - plugins-help +``` +bash-it (will show all the help commands) +aliases-help +rails-help +git-help +plugins-help +``` ## Your Custom scripts, aliases, and functions -For custom scripts, and aliases, you can create the following files and they will be ignored by the git repo: +For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo): * `aliases/custom.aliases.bash` * `lib/custom.bash` * `plugins/custom.plugins.bash` -and anything in the custom directory will be ignored with the exception of `custom/example.bash`. +Anything in the custom directory will be ignored, with the exception of `custom/example.bash`. ## Themes -There are a few bash it themes, but I'm hoping the community will jump in and create their own custom prompts and share their creations with everyone else by submitting a pull request to me (revans). +There are a few bash it themes. If you've created your own custom prompts, I'd love it if you shared with everyone else! Just submit a Pull Request to me (revans). ## Help out -I think all of us have our own custom scripts that we have added over time and so following in the footsteps of oh-my-zsh, bash it was created as a framework for those who choose to use bash as their shell. As a community, I'm excited to see what everyone else has in their custom toolbox and am hoping that they'll share it with everyone by submitting a pull request to bash it. +I think everyone has their own custom scripts accumulated over time. And so, following in the footsteps of oh-my-zsh, bash it is a framework for easily customizing your bash shell. Everyone's got a custom toolbox, so let's start making them even better, **as a community!** -So, if you have contributions to bash it, please send me a pull request and I'll take a look at it and commit it to the repo as long as it looks good. If you do change an existing command, please give an explanation as to why. That will help a lot when I merge your changes in. Thanks, and happing bashing! +Send me a pull request and I'll merge it as long as it looks good. If you change an existing command, please give an explanation why. That will help a lot when I merge your changes in. + +Thanks, and happing bashing! ## Contributors From a85080c8b0c2acff0190b856b62eff1db0521d58 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Thu, 30 Jun 2011 11:28:32 -0500 Subject: [PATCH 20/51] Fix extra step in install section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5b9201b..3a529e3a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces 1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git bash_it` 2. Run `install.sh` (it automatically backs up your `~/.bash_profile`) -3. Move `~/.bash_it/template/bash_profile.template.bash` into its place. (Edit this template file in order to customize bash-it.) +3. Edit your `~/.bash_profile` file in order to customize bash-it. **NOTE:** The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll). From 450a1d1090a5fdc7afc66ad752f87471d2a004d6 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 2 Jul 2011 21:44:47 -0500 Subject: [PATCH 21/51] Added JEKYLL_EDITOR variable This will replace the default $EDITOR used in the Jekyll plugin --- template/jekyllconfig.template.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/jekyllconfig.template.bash b/template/jekyllconfig.template.bash index e4705181..291bf85e 100644 --- a/template/jekyllconfig.template.bash +++ b/template/jekyllconfig.template.bash @@ -15,3 +15,7 @@ REMOTES="user@host_1:path user@host_2:path" # Same rules as above. Can be HTML, textile, or markdown MARKUPS="markdown textile" + +# If you want to use a different editor for Jekyll, change the value of this variable + +JEKYLL_EDITOR="$EDITOR" From e1a299eafba5b6777c2f8234062fc67c8c8790f4 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 2 Jul 2011 21:44:56 -0500 Subject: [PATCH 22/51] Implement JEKYLL_EDITOR variable --- plugins/available/jekyll.plugins.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/available/jekyll.plugins.bash b/plugins/available/jekyll.plugins.bash index 8efdd11f..eff85ce3 100644 --- a/plugins/available/jekyll.plugins.bash +++ b/plugins/available/jekyll.plugins.bash @@ -41,11 +41,11 @@ editpost() { done less $TMPFILE read -p "Number of post to edit: " POST_TO_EDIT - if [ -z "$EDITOR" ] + if [ -z "$JEKYLL_EDITOR" ] then nano "${POSTS[$POST_TO_EDIT]}" else - "$EDITOR" "${POSTS[$POST_TO_EDIT]}" + "$JEKYLL_EDITOR" "${POSTS[$POST_TO_EDIT]}" fi } @@ -253,7 +253,7 @@ newpost() { # Open the file in your favorite editor - "$EDITOR" $FNAME + "$JEKYLL_EDITOR" $FNAME } function testsite() { From 3a2b525ac65fd06470cb3fed6efdac70b03d4e35 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Thu, 7 Jul 2011 11:04:27 -0500 Subject: [PATCH 23/51] Added prevcurl function Downloads a file and opens it in Preivew.app --- plugins/available/osx.plugin.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 76e4b9a5..cf553777 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -35,3 +35,14 @@ function dock-switch() { echo "Sorry, this only works on Mac OS X" fi } + +# Download a file and open it in Preview + +function prevcurl() { + if [ ! $(uname) = "Darwin" ] + then + echo "This function only works with Mac OS X" + return 1 + fi + curl "$*" | open -fa "Preview" +} From 86aa9ff36a3f5e9ab3fcdf79b2da23d1b10cae75 Mon Sep 17 00:00:00 2001 From: Ryan Kanno Date: Thu, 7 Jul 2011 22:13:29 -1000 Subject: [PATCH 24/51] ip address can be enabled/disabled (default is enabled) --- themes/hawaii50/hawaii50.theme.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash index 21c0b413..1b0a5998 100644 --- a/themes/hawaii50/hawaii50.theme.bash +++ b/themes/hawaii50/hawaii50.theme.bash @@ -75,6 +75,9 @@ MAX_GIT_HEX_LENGTH=5 # IP address IP_SEPARATOR=', ' +# Show IP +IP_ENABLED=1 + # FUNCS ======================================================================= function ip { @@ -82,6 +85,13 @@ function ip { echo -e "$(ips | sed -e :a -e '$!N;s/\n/${IP_SEPARATOR}/;ta' | sed -e 's/127\.0\.0\.1\${IP_SEPARATOR}//g'), ${myip}" } +# Displays ip prompt +function ip_prompt_info() { + if [[ $IP_ENABLED == 1 ]]; then + echo -e " ${DEFAULT_COLOR}(${IP_COLOR}$(ip)${DEFAULT_COLOR})" + fi +} + # Displays virtual info prompt (virtualenv/rvm) function virtual_prompt_info() { local virtual_env_info=$(virtualenv_prompt) @@ -176,9 +186,9 @@ function prompt() { [ $UID -eq "0" ] && UC=$SUPERUSER_COLOR if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then - PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h ${DEFAULT_COLOR}(${IP_COLOR}$(ip)${DEFAULT_COLOR}) in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${reset_color} \$ " + PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${reset_color} \$ " else - PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h ${DEFAULT_COLOR}(${IP_COLOR}$(ip)${DEFAULT_COLOR}) in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ " + PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ " fi PS2='> ' PS4='+ ' From 3cd70de071ed3b5bf875e8c51759f218d97e802d Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sat, 9 Jul 2011 17:38:37 -0500 Subject: [PATCH 25/51] adds a tmuxinator plugin --- plugins/available/tmuxinator.plugin.bash | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 plugins/available/tmuxinator.plugin.bash diff --git a/plugins/available/tmuxinator.plugin.bash b/plugins/available/tmuxinator.plugin.bash new file mode 100644 index 00000000..d8236fc5 --- /dev/null +++ b/plugins/available/tmuxinator.plugin.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +[[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && . $HOME/.tmuxinator/scripts/tmuxinator From caa1bba1298a7dd35b5844e4b18ddb538bd52b7d Mon Sep 17 00:00:00 2001 From: Ryan Kanno Date: Sat, 9 Jul 2011 14:04:08 -1000 Subject: [PATCH 26/51] Moved IP and virtualenv variables to top of file --- themes/hawaii50/hawaii50.theme.bash | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash index 1b0a5998..93cef469 100644 --- a/themes/hawaii50/hawaii50.theme.bash +++ b/themes/hawaii50/hawaii50.theme.bash @@ -30,6 +30,15 @@ # specific like getting ip, etc. # +# IMPORTANT THINGS TO CHANGE ================================================== + +# Show IP in prompt +# One thing to be weary about if you have slow Internets +IP_ENABLED=1 + +# virtual prompts +VIRTUAL_PROMPT_ENABLED=1 + # COLORS ====================================================================== ORANGE='\[\e[0;33m\]' @@ -60,9 +69,6 @@ RVM_THEME_PROMPT_SUFFIX='' VIRTUALENV_THEME_PROMPT_PREFIX='' VIRTUALENV_THEME_PROMPT_SUFFIX='' -# virtual prompts -VIRTUAL_PROMPT_ENABLED=1 - VIRTUAL_THEME_PROMPT_PREFIX=' using ' VIRTUAL_THEME_PROMPT_SUFFIX='' @@ -75,9 +81,6 @@ MAX_GIT_HEX_LENGTH=5 # IP address IP_SEPARATOR=', ' -# Show IP -IP_ENABLED=1 - # FUNCS ======================================================================= function ip { From 8c7b8f26c8ae77a41946c254d9a29f3f542a6d91 Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Sun, 17 Jul 2011 06:52:27 +0300 Subject: [PATCH 27/51] Node version manager as plugin --- plugins/available/nvm.plugin.bash | 251 ++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 plugins/available/nvm.plugin.bash diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash new file mode 100644 index 00000000..a02722e1 --- /dev/null +++ b/plugins/available/nvm.plugin.bash @@ -0,0 +1,251 @@ +# Node Version Manager +# Implemented as a bash function +# To use source this file from your bash profile +# +# Implemented by Tim Caswell +# with much bash help from Matthew Ranney +# https://github.com/creationix/nvm + +export NVM_DIR=$HOME/.nvm + +if [ ! -d "$NVM_DIR" ]; then + mkdir $NVM_DIR +fi + +# Auto detect the NVM_DIR +if [ ! -d "$NVM_DIR" ]; then + export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd) +fi + +# Emulate curl with wget, if necessary +if [ ! `which curl` ]; then + if [ `which wget` ]; then + curl() { + ARGS="$* " + ARGS=${ARGS/-s /-q } + ARGS=${ARGS/-\# /} + ARGS=${ARGS/-C - /-c } + ARGS=${ARGS/-o /-O } + + wget $ARGS + } + else + NOCURL='nocurl' + curl() { echo 'Need curl or wget to proceed.' >&2; } + fi +fi + +# Expand a version using the version cache +nvm_version() +{ + PATTERN=$1 + VERSION='' + if [ -f "$NVM_DIR/alias/$PATTERN" ]; then + nvm_version `cat $NVM_DIR/alias/$PATTERN` + return + fi + # If it looks like an explicit version, don't do anything funny + if [[ "$PATTERN" == v*.*.* ]]; then + VERSION="$PATTERN" + fi + # The default version is the current one + if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then + VERSION=`node -v 2>/dev/null` + fi + if [ "$PATTERN" = 'stable' ]; then + PATTERN='*.*[02468].' + fi + if [ "$PATTERN" = 'latest' ]; then + PATTERN='*.*.' + fi + if [ "$PATTERN" = 'all' ]; then + (cd $NVM_DIR; \ls -dG v* 2>/dev/null || echo "N/A") + return + fi + if [ ! "$VERSION" ]; then + VERSION=`(cd $NVM_DIR; \ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1` + fi + if [ ! "$VERSION" ]; then + echo "N/A" + return 13 + elif [ -e "$NVM_DIR/$VERSION" ]; then + (cd $NVM_DIR; \ls -dG "$VERSION") + else + echo "$VERSION" + fi +} + +nvm() +{ + if [ $# -lt 1 ]; then + nvm help + return + fi + case $1 in + "help" ) + echo + echo "Node Version Manager" + echo + echo "Usage:" + echo " nvm help Show this message" + echo " nvm install Download and install a " + echo " nvm use Modify PATH to use " + echo " nvm ls List versions (installed versions are blue)" + echo " nvm ls List versions matching a given description" + echo " nvm deactivate Undo effects of NVM on current shell" + echo " nvm sync Update the local cache of available versions" + echo " nvm alias [] Show all aliases beginning with " + echo " nvm alias Set an alias named pointing to " + echo + echo "Example:" + echo " nvm install v0.4.0 Install a specific version number" + echo " nvm use stable Use the stable release" + echo " nvm install latest Install the latest, possibly unstable version" + echo " nvm use 0.2 Use the latest available 0.2.x release" + echo " nvm alias default v0.4.0 Set v0.4.0 as the default" + echo + ;; + "install" ) + if [ $# -ne 2 ]; then + nvm help + return + fi + [ "$NOCURL" ] && curl && return + VERSION=`nvm_version $2` + if ( + mkdir -p "$NVM_DIR/src" && \ + cd "$NVM_DIR/src" && \ + curl -C - -# "http://nodejs.org/dist/node-$VERSION.tar.gz" -o "node-$VERSION.tar.gz" && \ + tar -xzf "node-$VERSION.tar.gz" && \ + cd "node-$VERSION" && \ + ./configure --prefix="$NVM_DIR/$VERSION" && \ + make && \ + rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \ + make install + ) + then + nvm use $VERSION + if ! which npm ; then + echo "Installing npm..." + # TODO: if node version 0.2.x add npm_install=0.2.19 before sh + curl http://npmjs.org/install.sh | clean=yes sh + fi + else + echo "nvm: install $VERSION failed!" + fi + ;; + "deactivate" ) + if [[ $PATH == *$NVM_DIR/*/bin* ]]; then + export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:} + hash -r + echo "$NVM_DIR/*/bin removed from \$PATH" + else + echo "Could not find $NVM_DIR/*/bin in \$PATH" + fi + if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then + export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:} + echo "$NVM_DIR/*/share/man removed from \$MANPATH" + else + echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" + fi + ;; + "use" ) + if [ $# -ne 2 ]; then + nvm help + return + fi + VERSION=`nvm_version $2` + if [ ! -d $NVM_DIR/$VERSION ]; then + echo "$VERSION version is not installed yet" + return; + fi + if [[ $PATH == *$NVM_DIR/*/bin* ]]; then + PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin} + else + PATH="$NVM_DIR/$VERSION/bin:$PATH" + fi + if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then + MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man} + else + MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH" + fi + export PATH + hash -r + export MANPATH + export NVM_PATH="$NVM_DIR/$VERSION/lib/node" + export NVM_BIN="$NVM_DIR/$VERSION/bin" + echo "Now using node $VERSION" + ;; + "ls" ) + if [ $# -ne 1 ]; then + nvm_version $2 + return + fi + nvm_version all + for P in {stable,latest,current}; do + echo -ne "$P: \t"; nvm_version $P + done + nvm alias + echo "# use 'nvm sync' to update from nodejs.org" + ;; + "alias" ) + mkdir -p $NVM_DIR/alias + if [ $# -le 2 ]; then + (cd $NVM_DIR/alias && for ALIAS in `\ls $2* 2>/dev/null`; do + DEST=`cat $ALIAS` + VERSION=`nvm_version $DEST` + if [ "$DEST" = "$VERSION" ]; then + echo "$ALIAS -> $DEST" + else + echo "$ALIAS -> $DEST (-> $VERSION)" + fi + done) + return + fi + if [ ! "$3" ]; then + rm -f $NVM_DIR/alias/$2 + echo "$2 -> *poof*" + return + fi + mkdir -p $NVM_DIR/alias + VERSION=`nvm_version $3` + if [ $? -ne 0 ]; then + echo "! WARNING: Version '$3' does not exist." >&2 + fi + echo $3 > "$NVM_DIR/alias/$2" + if [ ! "$3" = "$VERSION" ]; then + echo "$2 -> $3 (-> $VERSION)" + echo "! WARNING: Moving target. Aliases to implicit versions may change without warning." + else + echo "$2 -> $3" + fi + ;; + "sync" ) + [ "$NOCURL" ] && curl && return + LATEST=`nvm_version latest` + STABLE=`nvm_version stable` + (cd $NVM_DIR + rm -f v* 2>/dev/null + printf "# syncing with nodejs.org..." + for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'node-v.*\.tar\.gz' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//'`; do + touch $VER + done + echo " done." + ) + [ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`" + [ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`" + ;; + "clear-cache" ) + rm -f $NVM_DIR/v* 2>/dev/null + echo "Cache cleared." + ;; + "version" ) + nvm_version $2 + ;; + * ) + nvm help + ;; + esac +} + +nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null From 35df3d6a579f53579d072013771d967742363419 Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Sun, 17 Jul 2011 07:17:56 +0300 Subject: [PATCH 28/51] Just extract() --- lib/extract.bash | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/extract.bash diff --git a/lib/extract.bash b/lib/extract.bash new file mode 100644 index 00000000..1c55928a --- /dev/null +++ b/lib/extract.bash @@ -0,0 +1,20 @@ +extract () { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via >extract<" ;; + esac + else + echo "'$1' is not a valid file" + fi +} From 561c4d60a0a149367e35aa460f09dd3035ad0abc Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 17 Jul 2011 13:21:38 -0500 Subject: [PATCH 29/51] Move extract.bash to a proper location --- lib/extract.bash => plugins/available/extract.plugin.bash | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/extract.bash => plugins/available/extract.plugin.bash (100%) diff --git a/lib/extract.bash b/plugins/available/extract.plugin.bash similarity index 100% rename from lib/extract.bash rename to plugins/available/extract.plugin.bash From 105172025742cf32734825c7d446250332627d55 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 17 Jul 2011 13:22:49 -0500 Subject: [PATCH 30/51] Add error throw for no file specified --- plugins/available/extract.plugin.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index 1c55928a..1c3e9b1a 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -1,4 +1,9 @@ extract () { + if [ $# -ne 1 ] + then + echo "Error: No file specified." + return 1 + fi if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; @@ -12,7 +17,7 @@ extract () { *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via >extract<" ;; + *) echo "'$1' cannot be extracted via extract" ;; esac else echo "'$1' is not a valid file" From ec3158908b943ff34cdbf0eb2dfe94fb453ad070 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Tue, 19 Jul 2011 07:31:49 -0700 Subject: [PATCH 31/51] Fixed installation paths in docs. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a529e3a..0c9c303f 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces ## Install -1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git bash_it` -2. Run `install.sh` (it automatically backs up your `~/.bash_profile`) +1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git ~/.bash_it` +2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile`) 3. Edit your `~/.bash_profile` file in order to customize bash-it. **NOTE:** From aa56e2ad01977a4bf1237721a7aa089b1990e3bd Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sat, 23 Jul 2011 21:42:02 -0500 Subject: [PATCH 32/51] ditch custom virtualenv_prompt in favor of one in base --- themes/doubletime/doubletime.theme.bash | 7 ------- 1 file changed, 7 deletions(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index e16ba66c..997b3f24 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -26,13 +26,6 @@ doubletime_scm_prompt() { fi } -virtualenv_prompt() { - if [ ! -z "$VIRTUAL_ENV" ] - then - echo "(`basename $VIRTUAL_ENV`) " - fi -} - function prompt_setter() { # Save history history -a From 1251c20a5825a6fa9461a03b42ec27d2ddc8491d Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sat, 23 Jul 2011 21:42:22 -0500 Subject: [PATCH 33/51] add rvm to prompt --- themes/doubletime/doubletime.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 997b3f24..0ec8497c 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -38,7 +38,7 @@ function prompt_setter() { clock=$THEME_PROMPT_CLOCK_FORMAT fi PS1=" -$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)\w +$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(rvm_version_prompt)\w $(doubletime_scm_prompt)$reset_color $ " PS2='> ' PS4='+ ' From 11995c1c1d6623c8aabbce356988e9f7bcec5fba Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sat, 23 Jul 2011 21:42:48 -0500 Subject: [PATCH 34/51] make sure its obvious which is ruby and which is python --- themes/doubletime/doubletime.theme.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 0ec8497c..17def320 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -6,8 +6,10 @@ SCM_SVN_CHAR="${bold_cyan}⑆${normal}" SCM_HG_CHAR="${bold_red}☿${normal}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -RVM_THEME_PROMPT_PREFIX=" (" -RVM_THEME_PROMPT_SUFFIX=")" +RVM_THEME_PROMPT_PREFIX="(rb: " +RVM_THEME_PROMPT_SUFFIX=") " +VIRTUALENV_THEME_PROMPT_PREFIX="(py: " +VIRTUALENV_THEME_PROMPT_SUFFIX=") " if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); From 41ca567f95496d290b3fc3311c2220975ae47731 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sat, 23 Jul 2011 21:48:07 -0500 Subject: [PATCH 35/51] add color to the prefix --- themes/doubletime/doubletime.theme.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 17def320..c3bf453d 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -6,9 +6,19 @@ SCM_SVN_CHAR="${bold_cyan}⑆${normal}" SCM_HG_CHAR="${bold_red}☿${normal}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -RVM_THEME_PROMPT_PREFIX="(rb: " +if [ ! -z $RVM_THEME_PROMPT_COLOR ]; then + RVM_THEME_PROMPT_COLOR=$(eval echo $`echo ${RVM_THEME_PROMPT_COLOR}`); +else + RVM_THEME_PROMPT_COLOR="${red}" +fi +RVM_THEME_PROMPT_PREFIX="(${RVM_THEME_PROMPT_COLOR}rb${normal}: " RVM_THEME_PROMPT_SUFFIX=") " -VIRTUALENV_THEME_PROMPT_PREFIX="(py: " +if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ]; then + VIRTUALENV_THEME_PROMPT_COLOR=$(eval echo $`echo ${VIRTUALENV_THEME_PROMPT_COLOR}`); +else + VIRTUALENV_THEME_PROMPT_COLOR="${green}" +fi +VIRTUALENV_THEME_PROMPT_PREFIX="(${VIRTUALENV_THEME_PROMPT_COLOR}py${normal}: " VIRTUALENV_THEME_PROMPT_SUFFIX=") " if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then From 80ec9c06bae86a0f51b155a3e7298d2c869f6acd Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 24 Jul 2011 13:35:43 -0500 Subject: [PATCH 36/51] Remove automatic creation of enabled plugins/aliases/completion --- bash_it.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 7734c10c..c7cbaa73 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -22,8 +22,7 @@ for file_type in "aliases" "completion" "plugins" do if [ ! -d "${BASH}/${file_type}/enabled" ] then - mkdir "${BASH}/${file_type}/enabled" - ln -s ${BASH}/${file_type}/available/* "${BASH}/${file_type}/enabled" + break fi FILES="${BASH}/${file_type}/enabled/*.bash" for config_file in $FILES From 3eff6b2d3838b4b566f8e311f929f078469afba4 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 24 Jul 2011 13:36:07 -0500 Subject: [PATCH 37/51] Add ability to choose what plugins/aliases/completion to install at install time --- install.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/install.sh b/install.sh index 3fc647b4..4affdbaf 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +BASH="$HOME/.bash_it" cp $HOME/.bash_profile $HOME/.bash_profile.bak @@ -26,3 +27,62 @@ do echo "Please enter Y or N" esac done + +function load_all() { + for file_type in "aliases" "completion" "plugins" + do + [ ! -d "$BASH/$file_type/enabled" ] && mkdir "$BASH/${file_type}/enabled" + ln -s $BASH/${file_type}/available/* "${BASH}/${file_type}/enabled" + done +} + +function load_some() { + for file_type in "aliases" "completion" "plugins" + do + for file in `ls $BASH/${file_type}/available` + do + if [ ! -d "$BASH/$file_type/enabled" ] + then + mkdir "$BASH/$file_type/enabled" + fi + while true + do + read -p "Would you like to enable the ${file%.*.*} $file_type? [Y/N] " RESP + case $RESP in + [yY]) + ln -s "$BASH/$file_type/available/$file" "$BASH/$file_type/enabled" + ;; + [nN]) + break + ;; + *) + echo "Please choose y or n." + ;; + esac + done + done + done +} + +while true +do + read -p "Would you like to enable all, some, or no plugins/aliases/tab-completion plugins? Some of these may make bash slower to start up. (all/some/none) " RESP + case $RESP + in + some) + load_some + break + ;; + all) + load_all + break + ;; + none) + break + ;; + *) + echo "Unknown choice. Please enter some, all, or none" + continue + ;; + esac +done From 159e1e42fa7019471f8763a2dc0ba5f55d82c378 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sun, 24 Jul 2011 15:01:07 -0500 Subject: [PATCH 38/51] More granular enabling of plugins/completion/aliases --- install.sh | 55 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index 4affdbaf..74ff6979 100755 --- a/install.sh +++ b/install.sh @@ -29,16 +29,13 @@ do done function load_all() { - for file_type in "aliases" "completion" "plugins" - do - [ ! -d "$BASH/$file_type/enabled" ] && mkdir "$BASH/${file_type}/enabled" - ln -s $BASH/${file_type}/available/* "${BASH}/${file_type}/enabled" - done + file_type=$1 + [ ! -d "$BASH/$file_type/enabled" ] && mkdir "$BASH/${file_type}/enabled" + ln -s $BASH/${file_type}/available/* "${BASH}/${file_type}/enabled" } function load_some() { - for file_type in "aliases" "completion" "plugins" - do + file_type=$1 for file in `ls $BASH/${file_type}/available` do if [ ! -d "$BASH/$file_type/enabled" ] @@ -61,28 +58,30 @@ function load_some() { esac done done - done } -while true +for type in "aliases" "plugins" "completion" do - read -p "Would you like to enable all, some, or no plugins/aliases/tab-completion plugins? Some of these may make bash slower to start up. (all/some/none) " RESP - case $RESP - in - some) - load_some - break - ;; - all) - load_all - break - ;; - none) - break - ;; - *) - echo "Unknown choice. Please enter some, all, or none" - continue - ;; - esac + while true + do + read -p "Would you like to enable all, some, or no $type? Some of these may make bash slower to start up (especially completion). (all/some/none) " RESP + case $RESP + in + some) + load_some $type + break + ;; + all) + load_all $type + break + ;; + none) + break + ;; + *) + echo "Unknown choice. Please enter some, all, or none" + continue + ;; + esac + done done From 55c32cc3e910022cfef08ed827b9d15f86dbbb21 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Mon, 25 Jul 2011 13:34:39 +0200 Subject: [PATCH 39/51] Break needed in load_some Y case --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 74ff6979..f84c097b 100755 --- a/install.sh +++ b/install.sh @@ -48,6 +48,7 @@ function load_some() { case $RESP in [yY]) ln -s "$BASH/$file_type/available/$file" "$BASH/$file_type/enabled" + break ;; [nN]) break From 484c57b7d22bad8797f073951c5f0682bb1c5921 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Mon, 25 Jul 2011 13:47:03 +0200 Subject: [PATCH 40/51] Refactored gem completion to load gem lists on demand intead of on load --- completion/available/gem.completion.bash | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/completion/available/gem.completion.bash b/completion/available/gem.completion.bash index 7231eef0..de986e08 100644 --- a/completion/available/gem.completion.bash +++ b/completion/available/gem.completion.bash @@ -1,22 +1,22 @@ #!/usr/bin/env bash # Completion for gem -if [ -z "$REMOTE_GEMS" ] -then - REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) -fi - -if [ -z "$LOCAL_GEMS" ] -then - LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) -fi - _installcomp() { + if [ -z "$REMOTE_GEMS" ] + then + REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) + fi + local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) ) } _uninstallcomp() { + if [ -z "$LOCAL_GEMS" ] + then + LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) + fi + local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) ) } From c6e096e35d43fd3ecaaadad5ff92fee2d37a0922 Mon Sep 17 00:00:00 2001 From: Yakkala Yagnesh Raghava Date: Sat, 6 Aug 2011 00:14:15 +0900 Subject: [PATCH 41/51] Add BOOKMARKing functionality to dirs plugin --- plugins/available/dirs.plugins.bash | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) mode change 100644 => 100755 plugins/available/dirs.plugins.bash diff --git a/plugins/available/dirs.plugins.bash b/plugins/available/dirs.plugins.bash old mode 100644 new mode 100755 index dfa9a323..a9f59749 --- a/plugins/available/dirs.plugins.bash +++ b/plugins/available/dirs.plugins.bash @@ -50,3 +50,35 @@ function dirs-help() { echo "8 : Chance to stack location 8." echo "9 : Chance to stack location 9." } + + +# ADD BOOKMARKing functionality +# usage: + +if [ ! -f ~/.dirs ]; then # if doesn't exist, create it + touch ~/.dirs +else + source ~/.dirs +fi + +alias L='cat ~/.dirs' + +G () { # goes to distination dir otherwise , stay in the dir + cd ${1:-$(pwd)} ; +} + +S () { # SAVE a BOOKMARK + /bin/sed "/$@/d" ~/.dirs > ~/.dirs1; + \mv ~/.dirs1 ~/.dirs; + echo "$@"=\"`pwd`\" >> ~/.dirs; + source ~/.dirs ; +} + +R () { # remove a BOOKMARK + /bin/sed "/$@/d" ~/.dirs > ~/.dirs1; + \mv ~/.dirs1 ~/.dirs; +} + +alias U='source ~/.dirs' # Update BOOKMARK stack +# set the bash option so that no '$' is required when using the above facility +shopt -s cdable_vars From dcdfd66d2a566dc637f916486e5622b651cc095f Mon Sep 17 00:00:00 2001 From: Yakkala Yagnesh Raghava Date: Sat, 6 Aug 2011 01:01:17 +0900 Subject: [PATCH 42/51] BOOKMARKing:remove absolute path of sed, to make compatible with OS X --- plugins/available/dirs.plugins.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/dirs.plugins.bash b/plugins/available/dirs.plugins.bash index a9f59749..9353c5b5 100755 --- a/plugins/available/dirs.plugins.bash +++ b/plugins/available/dirs.plugins.bash @@ -68,14 +68,14 @@ G () { # goes to distination dir otherwise , stay in the dir } S () { # SAVE a BOOKMARK - /bin/sed "/$@/d" ~/.dirs > ~/.dirs1; + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ; } R () { # remove a BOOKMARK - /bin/sed "/$@/d" ~/.dirs > ~/.dirs1; + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; } From e964c029aa5cf6a0a45a6a34eb7f8149f1feed69 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Wed, 10 Aug 2011 18:49:07 -0500 Subject: [PATCH 43/51] Add alias for shuf -> gshuf --- aliases/available/general.aliases.bash | 53 ++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 79bd7aa0..74f54280 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -12,7 +12,12 @@ alias _="sudo" if [ $(uname) = "Linux" ] then - alias ls="ls --color=always" + alias ls="ls --color=always" +fi + +if [ ! -z "$(which gshuf)" ] +then + alias shuf=gshuf fi alias c='clear' @@ -47,27 +52,27 @@ 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 +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 } From 576434048bf58bbab1c527d08e8eb3b6dfbe29c0 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Wed, 10 Aug 2011 18:49:20 -0500 Subject: [PATCH 44/51] Add simple password generator --- plugins/available/base.plugin.bash | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index e361e04a..cccd956c 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -15,6 +15,18 @@ function myip { echo "Your public IP is: ${bold_green} $res ${normal}" } +pass() { + if [ -z "$(which gshuf)" ] + then + echo "Error: shuf isn't installed!" + return 1 + fi + + pass=$(shuf -n4 /usr/share/dict/words | tr '\n' ' ') + echo "With spaces (easier to memorize): $pass" + echo "Without (use this as the pass): $(echo $pass | tr -d ' ')" +} + # Function for previewing markdown files in the browser function pmdown() { From 818e687790ecca69102268f17c5798acae2d7ee0 Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Fri, 12 Aug 2011 04:07:12 +0300 Subject: [PATCH 45/51] Detect OS in emacs.aliases.bash --- aliases/available/emacs.aliases.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aliases/available/emacs.aliases.bash b/aliases/available/emacs.aliases.bash index 5b328768..5042b17e 100644 --- a/aliases/available/emacs.aliases.bash +++ b/aliases/available/emacs.aliases.bash @@ -1,3 +1,11 @@ #!/bin/bash -alias em="open -a emacs" \ No newline at end of file +case $OSTYPE in + linux*) + alias em='emacs' + alias e='emacsclient -n' + ;; + darwin*) + alias em="open -a emacs" + ;; +esac From 89da5f9ceccc5667ff4d946d25d4d4a5b2b98698 Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Fri, 12 Aug 2011 04:08:11 +0300 Subject: [PATCH 46/51] general.aliases.bash: use native tree if [ -x ] .... --- aliases/available/general.aliases.bash | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 74f54280..457d6b5b 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -37,15 +37,19 @@ alias rb="ruby" alias piano="pianobar" -alias ..='cd ..' # Go up one directory -alias ...='cd ../..' # Go up two directories -alias -- -="cd -" # Go back +alias ..='cd ..' # Go up one directory +alias ...='cd ../..' # Go up two directories +alias ....='cd ../../..' # Go up two directories +alias -- -="cd -" # Go back # Shell History alias h='history' # Tree -alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" +if [ ! -x "$(which tree)" ] +then + alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" +fi # Directory alias md='mkdir -p' From 380a4a6c0e482a6f8f139d3cc8fc3daa8023f63a Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Fri, 12 Aug 2011 04:12:07 +0300 Subject: [PATCH 47/51] Alias for textmate only on darwin* --- aliases/available/textmate.aliases.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/aliases/available/textmate.aliases.bash b/aliases/available/textmate.aliases.bash index ecd616ff..4e696a55 100644 --- a/aliases/available/textmate.aliases.bash +++ b/aliases/available/textmate.aliases.bash @@ -1,5 +1,9 @@ #!/bin/bash -# Textmate -alias e='mate . &' -alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &' \ No newline at end of file +case $OSTYPE in + darwin*) + # Textmate + alias e='mate . &' + alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &' + ;; +esac From ba8fde85ebbc59e4440dfe45834c8da78671811f Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Fri, 12 Aug 2011 16:30:55 -0500 Subject: [PATCH 48/51] Make gshuf alias checker work on other bash versions --- aliases/available/general.aliases.bash | 4 ++-- plugins/available/base.plugin.bash | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 74f54280..4f49a6a8 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -14,8 +14,8 @@ if [ $(uname) = "Linux" ] then alias ls="ls --color=always" fi - -if [ ! -z "$(which gshuf)" ] +which gshuf &> /dev/null +if [ $? -eq 1 ] then alias shuf=gshuf fi diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index cccd956c..7a6dc80f 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -16,7 +16,8 @@ function myip { } pass() { - if [ -z "$(which gshuf)" ] + which gshuf &> /dev/null + if [ $? -eq 1 ] then echo "Error: shuf isn't installed!" return 1 From 8e0b66899dc1fcc818c45f925a14fea36cd5e279 Mon Sep 17 00:00:00 2001 From: Noorul Islam K M Date: Mon, 22 Aug 2011 12:35:00 +0530 Subject: [PATCH 49/51] Do not break out of the loop instead continue with other items in the list. --- bash_it.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_it.sh b/bash_it.sh index c7cbaa73..fd7b546d 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -22,7 +22,7 @@ for file_type in "aliases" "completion" "plugins" do if [ ! -d "${BASH}/${file_type}/enabled" ] then - break + continue fi FILES="${BASH}/${file_type}/enabled/*.bash" for config_file in $FILES From 18bcceaa0860366d8fced94759dfd12fdd4ca217 Mon Sep 17 00:00:00 2001 From: Antono Vasiljev Date: Thu, 25 Aug 2011 16:45:51 +0300 Subject: [PATCH 50/51] Updated nvm.plugin.bash --- plugins/available/nvm.plugin.bash | 66 ++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash index a02722e1..a5145ec2 100644 --- a/plugins/available/nvm.plugin.bash +++ b/plugins/available/nvm.plugin.bash @@ -4,7 +4,6 @@ # # Implemented by Tim Caswell # with much bash help from Matthew Ranney -# https://github.com/creationix/nvm export NVM_DIR=$HOME/.nvm @@ -89,6 +88,7 @@ nvm() echo "Usage:" echo " nvm help Show this message" echo " nvm install Download and install a " + echo " nvm uninstall Uninstall a version" echo " nvm use Modify PATH to use " echo " nvm ls List versions (installed versions are blue)" echo " nvm ls List versions matching a given description" @@ -96,13 +96,15 @@ nvm() echo " nvm sync Update the local cache of available versions" echo " nvm alias [] Show all aliases beginning with " echo " nvm alias Set an alias named pointing to " + echo " nvm unalias Deletes the alias named " + echo " nvm copy-packages Install global NPM packages contained in to current version" echo echo "Example:" echo " nvm install v0.4.0 Install a specific version number" echo " nvm use stable Use the stable release" echo " nvm install latest Install the latest, possibly unstable version" echo " nvm use 0.2 Use the latest available 0.2.x release" - echo " nvm alias default v0.4.0 Set v0.4.0 as the default" + echo " nvm alias default v0.4.0 Set v0.4.0 as the default" echo ;; "install" ) @@ -112,10 +114,17 @@ nvm() fi [ "$NOCURL" ] && curl && return VERSION=`nvm_version $2` + tarball='' + if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then + tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" + elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | grep '200 OK'`" != '' ]; then + tarball="http://nodejs.org/dist/node-$VERSION.tar.gz" + fi if ( + [ ! -z $tarball ] && \ mkdir -p "$NVM_DIR/src" && \ cd "$NVM_DIR/src" && \ - curl -C - -# "http://nodejs.org/dist/node-$VERSION.tar.gz" -o "node-$VERSION.tar.gz" && \ + curl -C - -# $tarball -o "node-$VERSION.tar.gz" && \ tar -xzf "node-$VERSION.tar.gz" && \ cd "node-$VERSION" && \ ./configure --prefix="$NVM_DIR/$VERSION" && \ @@ -134,6 +143,36 @@ nvm() echo "nvm: install $VERSION failed!" fi ;; + "uninstall" ) + [ $# -ne 2 ] && nvm help && return + if [[ $2 == `nvm_version` ]]; then + echo "nvm: Cannot uninstall currently-active node version, $2." + return + fi + VERSION=`nvm_version $2` + if [ ! -d $NVM_DIR/$VERSION ]; then + echo "$VERSION version is not installed yet" + return; + fi + + # Delete all files related to target version. + (cd "$NVM_DIR" && \ + rm -rf "node-$VERSION" 2>/dev/null && \ + mkdir -p "$NVM_DIR/src" && \ + cd "$NVM_DIR/src" && \ + rm -f "node-$VERSION.tar.gz" 2>/dev/null && \ + rm -rf "$NVM_DIR/$VERSION" 2>/dev/null) + echo "Uninstalled node $VERSION" + + # Rm any aliases that point to uninstalled version. + for A in `grep -l $VERSION $NVM_DIR/alias/*` + do + nvm unalias `basename $A` + done + + # Run sync in order to restore version stub file in $NVM_DIR. + nvm sync 1>/dev/null + ;; "deactivate" ) if [[ $PATH == *$NVM_DIR/*/bin* ]]; then export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:} @@ -210,7 +249,7 @@ nvm() mkdir -p $NVM_DIR/alias VERSION=`nvm_version $3` if [ $? -ne 0 ]; then - echo "! WARNING: Version '$3' does not exist." >&2 + echo "! WARNING: Version '$3' does not exist." >&2 fi echo $3 > "$NVM_DIR/alias/$2" if [ ! "$3" = "$VERSION" ]; then @@ -220,6 +259,13 @@ nvm() echo "$2 -> $3" fi ;; + "unalias" ) + mkdir -p $NVM_DIR/alias + [ $# -ne 2 ] && nvm help && return + [ ! -f $NVM_DIR/alias/$2 ] && echo "Alias $2 doesn't exist!" && return + rm -f $NVM_DIR/alias/$2 + echo "Deleted alias $2" + ;; "sync" ) [ "$NOCURL" ] && curl && return LATEST=`nvm_version latest` @@ -227,7 +273,7 @@ nvm() (cd $NVM_DIR rm -f v* 2>/dev/null printf "# syncing with nodejs.org..." - for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'node-v.*\.tar\.gz' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//'`; do + for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'v[0-9].*' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//' -e 's/<[^>]*>//' -e 's/\/<[^>]*>.*//'`; do touch $VER done echo " done." @@ -235,6 +281,16 @@ nvm() [ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`" [ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`" ;; + "copy-packages" ) + if [ $# -ne 2 ]; then + nvm help + return + fi + VERSION=`nvm_version $2` + ROOT=`nvm use $VERSION && npm -g root` + INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | grep -v npm | tr "\n" " "` + npm install -g $INSTALLS + ;; "clear-cache" ) rm -f $NVM_DIR/v* 2>/dev/null echo "Cache cleared." From 8a46e195d6f0dc5f8b5388816c38e60aeac8ff87 Mon Sep 17 00:00:00 2001 From: Martin Westin Date: Mon, 29 Aug 2011 08:22:19 +0200 Subject: [PATCH 51/51] Bundler aliases "inspired by" OhMyZsh --- aliases/available/bundler.aliases.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 aliases/available/bundler.aliases.bash diff --git a/aliases/available/bundler.aliases.bash b/aliases/available/bundler.aliases.bash new file mode 100644 index 00000000..12484f62 --- /dev/null +++ b/aliases/available/bundler.aliases.bash @@ -0,0 +1,21 @@ +#!/bin/bash + +# 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 +} +