* 'master' of http://github.com/revans/bash-it: (51 commits)
  Bundler aliases "inspired by" OhMyZsh
  Updated nvm.plugin.bash
  Do not break out of the loop instead continue with other items in the list.
  Make gshuf alias checker work on other bash versions
  Alias for textmate only on darwin*
  general.aliases.bash: use native tree if [ -x ] ....
  Detect OS in emacs.aliases.bash
  Add simple password generator
  Add alias for shuf -> gshuf
  BOOKMARKing:remove absolute path of sed, to make compatible with OS X
  Add BOOKMARKing functionality to dirs plugin
  Refactored gem completion to load gem lists on demand intead of on load
  Break needed in load_some Y case
  More granular enabling of plugins/completion/aliases
  Add ability to choose what plugins/aliases/completion to install at install time
  Remove automatic creation of enabled plugins/aliases/completion
  add color to the prefix
  make sure its obvious which is ruby and which is python
  add rvm to prompt
  ditch custom virtualenv_prompt in favor of one in base
  ...
pull/81/merge^2
John Schulz 2011-09-20 10:49:10 -04:00
commit 11214382c5
22 changed files with 1010 additions and 264 deletions

View File

@ -1,46 +1,53 @@
# Bash it # 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 ## 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. 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.
git clone http://github.com/revans/bash-it.git bash_it **NOTE:**
The install script will also prompt you asking if you use [Jekyll](https://github.com/mojombo/jekyll).
cp ~/.bash_profile ~/.bash_profile_original This is to set up the `.jekyllconfig` file, which stores info necessary to use the Jekyll plugin.
cp <path/to/cloned/repo>/template/bash_profile.template.bash ~/.bash_profile
## Help Screens ## Help Screens
```
bash-it (will show all the help commands) bash-it (will show all the help commands)
aliases-help aliases-help
rails-help rails-help
git-help git-help
plugins-help plugins-help
```
## Your Custom scripts, aliases, and functions ## 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` * `aliases/custom.aliases.bash`
* `lib/custom.bash` * `lib/custom.bash`
* `plugins/custom.plugins.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 ## 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 ## 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 ## Contributors

View File

@ -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
}

View File

@ -1,3 +1,11 @@
#!/bin/bash #!/bin/bash
case $OSTYPE in
linux*)
alias em='emacs'
alias e='emacsclient -n'
;;
darwin*)
alias em="open -a emacs" alias em="open -a emacs"
;;
esac

View File

@ -14,6 +14,11 @@ if [ $(uname) = "Linux" ]
then then
alias ls="ls --color=always" alias ls="ls --color=always"
fi fi
which gshuf &> /dev/null
if [ $? -eq 1 ]
then
alias shuf=gshuf
fi
alias c='clear' alias c='clear'
alias k='clear' alias k='clear'
@ -34,13 +39,17 @@ alias piano="pianobar"
alias ..='cd ..' # Go up one directory alias ..='cd ..' # Go up one directory
alias ...='cd ../..' # Go up two directories alias ...='cd ../..' # Go up two directories
alias ....='cd ../../..' # Go up two directories
alias -- -="cd -" # Go back alias -- -="cd -" # Go back
# Shell History # Shell History
alias h='history' alias h='history'
# Tree # Tree
if [ ! -x "$(which tree)" ]
then
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
fi
# Directory # Directory
alias md='mkdir -p' alias md='mkdir -p'

View File

@ -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"

View File

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
case $OSTYPE in
darwin*)
# Textmate # Textmate
alias e='mate . &' alias e='mate . &'
alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &' alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &'
;;
esac

View File

@ -22,8 +22,7 @@ for file_type in "aliases" "completion" "plugins"
do do
if [ ! -d "${BASH}/${file_type}/enabled" ] if [ ! -d "${BASH}/${file_type}/enabled" ]
then then
mkdir "${BASH}/${file_type}/enabled" continue
ln -s ${BASH}/${file_type}/available/* "${BASH}/${file_type}/enabled"
fi fi
FILES="${BASH}/${file_type}/enabled/*.bash" FILES="${BASH}/${file_type}/enabled/*.bash"
for config_file in $FILES for config_file in $FILES
@ -56,6 +55,13 @@ PREVIEW="less"
[ -s /usr/bin/gloobus-preview ] && PREVIEW="gloobus-preview" [ -s /usr/bin/gloobus-preview ] && PREVIEW="gloobus-preview"
[ -s /Applications/Preview.app ] && PREVIEW="/Applications/Preview.app" [ -s /Applications/Preview.app ] && PREVIEW="/Applications/Preview.app"
# Load all the Jekyll stuff
if [ -e $HOME/.jekyllconfig ]
then
. $HOME/.jekyllconfig
fi
# #
# Custom Help # Custom Help

View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Completion for gem
_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) )
}
_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

88
install.sh 100755
View File

@ -0,0 +1,88 @@
#!/usr/bin/env bash
BASH="$HOME/.bash_it"
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
function load_all() {
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() {
file_type=$1
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"
break
;;
[nN])
break
;;
*)
echo "Please choose y or n."
;;
esac
done
done
}
for type in "aliases" "plugins" "completion"
do
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

View File

@ -15,6 +15,19 @@ function myip {
echo "Your public IP is: ${bold_green} $res ${normal}" echo "Your public IP is: ${bold_green} $res ${normal}"
} }
pass() {
which gshuf &> /dev/null
if [ $? -eq 1 ]
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 for previewing markdown files in the browser
function pmdown() { function pmdown() {

View File

@ -50,3 +50,35 @@ function dirs-help() {
echo "8 : Chance to stack location 8." echo "8 : Chance to stack location 8."
echo "9 : Chance to stack location 9." 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
sed "/$@/d" ~/.dirs > ~/.dirs1;
\mv ~/.dirs1 ~/.dirs;
echo "$@"=\"`pwd`\" >> ~/.dirs;
source ~/.dirs ;
}
R () { # remove a BOOKMARK
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

View File

@ -0,0 +1,25 @@
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 ;;
*.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
}

View File

@ -1,7 +1,30 @@
#!/bin/bash #!/bin/bash
editpost() { 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
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/_posts"
COUNTER=1 COUNTER=1
NUMBER="$RANDOM" NUMBER="$RANDOM"
@ -18,25 +41,51 @@ editpost() {
done done
less $TMPFILE less $TMPFILE
read -p "Number of post to edit: " POST_TO_EDIT read -p "Number of post to edit: " POST_TO_EDIT
if [ -z "$EDITOR" ] if [ -z "$JEKYLL_EDITOR" ]
then then
nano "${POSTS[$POST_TO_EDIT]}" nano "${POSTS[$POST_TO_EDIT]}"
else else
"$EDITOR" "${POSTS[$POST_TO_EDIT]}" "$JEKYLL_EDITOR" "${POSTS[$POST_TO_EDIT]}"
fi fi
} }
newpost() { 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
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
loc=0
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
JEKYLL_FORMATTING=${MARKUPS[$loc]}
break
fi
loc=$(($loc+1))
done
# 'builtin cd' into the local jekyll root # 'builtin cd' into the local jekyll root
builtin cd "$JEKYLL_LOCAL_ROOT/_posts" builtin cd "$SITE/_posts"
# Get the date for the new post's filename # Get the date for the new post's filename
FNAME_DATE=$(date "+%Y-%m-%d") 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. # If the user is using markdown or textile formatting, let them choose what type of post they want. Sort of like Tumblr.
OPTIONS="Text Quote Image Audio Video Link" OPTIONS="Text Quote Image Audio Video Link"
@ -204,5 +253,94 @@ newpost() {
# Open the file in your favorite editor # Open the file in your favorite editor
"$EDITOR" $FNAME "$JEKYLL_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
} }

View File

@ -0,0 +1,307 @@
# Node Version Manager
# Implemented as a bash function
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
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 <version> Download and install a <version>"
echo " nvm uninstall <version> Uninstall a version"
echo " nvm use <version> Modify PATH to use <version>"
echo " nvm ls List versions (installed versions are blue)"
echo " nvm ls <version> 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 [<pattern>] Show all aliases beginning with <pattern>"
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
echo " nvm unalias <name> Deletes the alias named <name>"
echo " nvm copy-packages <version> Install global NPM packages contained in <version> 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
;;
"install" )
if [ $# -ne 2 ]; then
nvm help
return
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 - -# $tarball -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
;;
"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:}
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
;;
"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`
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 'v[0-9].*' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//' -e 's/<[^>]*>//' -e 's/\/<[^>]*>.*//'`; 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`"
;;
"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."
;;
"version" )
nvm_version $2
;;
* )
nvm help
;;
esac
}
nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null

View File

@ -32,6 +32,17 @@ function dock-switch() {
echo "dock-switch 3d." echo "dock-switch 3d."
fi fi
else else
echo "sorry. you're currently not using os x" echo "Sorry, this only works on Mac OS X"
fi 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"
}

View File

@ -0,0 +1,3 @@
#!/bin/bash
[[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && . $HOME/.tmuxinator/scripts/tmuxinator

View File

@ -26,18 +26,6 @@ export NGINX_PATH='/opt/nginx'
# Don't check mail when opening terminal. # Don't check mail when opening terminal.
unset MAILCHECK 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. # Change this to your console based IRC client of choice.

View File

@ -0,0 +1,21 @@
# 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"
# If you want to use a different editor for Jekyll, change the value of this variable
JEKYLL_EDITOR="$EDITOR"

View File

@ -6,8 +6,20 @@ SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
SCM_HG_CHAR="${bold_red}${normal}" SCM_HG_CHAR="${bold_red}${normal}"
SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""
RVM_THEME_PROMPT_PREFIX=" (" 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=") " RVM_THEME_PROMPT_SUFFIX=") "
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 if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then
THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`);
@ -17,18 +29,12 @@ fi
doubletime_scm_prompt() { doubletime_scm_prompt() {
CHAR=$(scm_char) CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ] if [ $CHAR = $SCM_NONE_CHAR ]; then
then
return return
else elif [ $CHAR = $SCM_GIT_CHAR ]; then
echo "$(git_prompt_status)" echo "$(git_prompt_status)"
fi else
} echo "[$(scm_prompt_info)]"
virtualenv_prompt() {
if [ ! -z "$VIRTUAL_ENV" ]
then
echo "(`basename $VIRTUAL_ENV`) "
fi fi
} }
@ -44,7 +50,7 @@ function prompt_setter() {
clock=$THEME_PROMPT_CLOCK_FORMAT clock=$THEME_PROMPT_CLOCK_FORMAT
fi fi
PS1=" 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 $ " $(doubletime_scm_prompt)$reset_color $ "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -30,6 +30,15 @@
# specific like getting ip, etc. # 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 ====================================================================== # COLORS ======================================================================
ORANGE='\[\e[0;33m\]' ORANGE='\[\e[0;33m\]'
@ -60,9 +69,6 @@ RVM_THEME_PROMPT_SUFFIX=''
VIRTUALENV_THEME_PROMPT_PREFIX='' VIRTUALENV_THEME_PROMPT_PREFIX=''
VIRTUALENV_THEME_PROMPT_SUFFIX='' VIRTUALENV_THEME_PROMPT_SUFFIX=''
# virtual prompts
VIRTUAL_PROMPT_ENABLED=1
VIRTUAL_THEME_PROMPT_PREFIX=' using ' VIRTUAL_THEME_PROMPT_PREFIX=' using '
VIRTUAL_THEME_PROMPT_SUFFIX='' VIRTUAL_THEME_PROMPT_SUFFIX=''
@ -82,6 +88,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}" 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) # Displays virtual info prompt (virtualenv/rvm)
function virtual_prompt_info() { function virtual_prompt_info() {
local virtual_env_info=$(virtualenv_prompt) local virtual_env_info=$(virtualenv_prompt)
@ -176,9 +189,9 @@ function prompt() {
[ $UID -eq "0" ] && UC=$SUPERUSER_COLOR [ $UID -eq "0" ] && UC=$SUPERUSER_COLOR
if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then 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 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 fi
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '

View File

@ -1,7 +1,12 @@
prompt_setter() { #!/usr/bin/env bash
PS1="${cyan}\W${normal} "
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 PROMPT_COMMAND=prompt
export PS3=">> "

View File

@ -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;