diff --git a/.bash_it b/.bash_it deleted file mode 120000 index dee1f0d3..00000000 --- a/.bash_it +++ /dev/null @@ -1 +0,0 @@ -.bash_it \ No newline at end of file diff --git a/.gitignore b/.gitignore index fec6fae1..32e62dec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*/enabled/* .DS_Store custom/*.bash !custom/example.bash diff --git a/README.md b/README.md index c8412c92..0c9c303f 100644 --- a/README.md +++ b/README.md @@ -1,46 +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. 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 - - cp ~/.bash_profile ~/.bash_profile_original - cp /template/bash_profile.template.bash ~/.bash_profile +**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 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 +} + diff --git a/aliases/available/emacs.aliases.bash b/aliases/available/emacs.aliases.bash new file mode 100644 index 00000000..5042b17e --- /dev/null +++ b/aliases/available/emacs.aliases.bash @@ -0,0 +1,11 @@ +#!/bin/bash + +case $OSTYPE in + linux*) + alias em='emacs' + alias e='emacsclient -n' + ;; + darwin*) + alias em="open -a emacs" + ;; +esac diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash new file mode 100644 index 00000000..cfd456fc --- /dev/null +++ b/aliases/available/general.aliases.bash @@ -0,0 +1,82 @@ +#!/bin/bash + +# List directory contents +alias sl=ls +alias ls='ls -G' # Compact view, show colors +alias la='ls -AF' # Compact view, show hidden +alias ll='ls -al' +alias l='ls -a' +alias l1='ls -1' + +alias _="sudo" + +if [ $(uname) = "Linux" ] +then + alias ls="ls --color=always" +fi +which gshuf &> /dev/null +if [ $? -eq 1 ] +then + alias shuf=gshuf +fi + +alias c='clear' +alias k='clear' +alias cls='clear' + +alias edit="$EDITOR" +alias pager="$PAGER" + +alias q="exit" + +alias irc="$IRC_CLIENT" + +alias rb="ruby" + +# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/ + +alias piano="pianobar" + +alias ..='cd ..' # Go up one directory +alias ...='cd ../..' # Go up two directories +alias ....='cd ../../..' # Go up two directories +alias -- -="cd -" # Go back + +# Shell History +alias h='history' + +# Tree +if [ ! -x "$(which tree)" ] +then + alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" +fi + +# Directory +alias md='mkdir -p' +alias rd=rmdir + +function aliases-help() { +echo "Generic Alias Usage" +echo +echo " sl = ls" +echo " ls = ls -G" +echo " la = ls -AF" +echo " ll = ls -al" +echo " l = ls -a" +echo " c/k/cls = clear" +echo " .. = cd .." +echo " ... = cd ../.." +echo " - = cd -" +echo " h = history" +echo " md = mkdir -p" +echo " rd = rmdir" +echo " editor = $EDITOR" +echo " pager = $PAGER" +echo " piano = pianobar" +echo " q = exit" +echo " irc = $IRC_CLIENT" +echo " md = mkdir -p" +echo " rd = rmdir" +echo " rb = ruby" +echo +} diff --git a/aliases/git.aliases.bash b/aliases/available/git.aliases.bash similarity index 100% rename from aliases/git.aliases.bash rename to aliases/available/git.aliases.bash diff --git a/aliases/heroku.aliases.bash b/aliases/available/heroku.aliases.bash similarity index 100% rename from aliases/heroku.aliases.bash rename to aliases/available/heroku.aliases.bash diff --git a/aliases/hg.aliases.bash b/aliases/available/hg.aliases.bash similarity index 100% rename from aliases/hg.aliases.bash rename to aliases/available/hg.aliases.bash diff --git a/aliases/available/homebrew.aliases.bash b/aliases/available/homebrew.aliases.bash new file mode 100644 index 00000000..051081d9 --- /dev/null +++ b/aliases/available/homebrew.aliases.bash @@ -0,0 +1,24 @@ +# Some aliases for Homebrew + +alias bup="brew update && brew upgrade" +alias bout="brew outdated" +alias bin="brew install" +alias brm="brew uninstall" +alias bls="brew list" +alias bsr="brew search" +alias binf="brew info" +alias bdr="brew doctor" + +function brew-help() { + echo "Homebrew Alias Usage" + echo + echo "bup = brew update && brew upgrade" + echo "bout = brew outdated" + echo "bin = brew install" + echo "brm = brew uninstall" + echo "bls = brew list" + echo "bsr = brew search" + echo "binf = brew info" + echo "bdr = brew doctor" + echo +} diff --git a/aliases/osx.aliases.bash b/aliases/available/osx.aliases.bash similarity index 100% rename from aliases/osx.aliases.bash rename to aliases/available/osx.aliases.bash diff --git a/aliases/rails.aliases.bash b/aliases/available/rails.aliases.bash similarity index 97% rename from aliases/rails.aliases.bash rename to aliases/available/rails.aliases.bash index d4415f6d..6e1ca149 100644 --- a/aliases/rails.aliases.bash +++ b/aliases/available/rails.aliases.bash @@ -10,6 +10,7 @@ alias rd='rails dbconsole' alias rp='rails plugin' alias ra='rails application' alias rd='rails destroy' +alias dbm='rake db:migrate' alias ss='script/server' alias ts="thin start" # thin server diff --git a/aliases/available/textmate.aliases.bash b/aliases/available/textmate.aliases.bash new file mode 100644 index 00000000..4e696a55 --- /dev/null +++ b/aliases/available/textmate.aliases.bash @@ -0,0 +1,9 @@ +#!/bin/bash + +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 diff --git a/aliases/todo.txt-cli.aliases.bash b/aliases/available/todo.txt-cli.aliases.bash similarity index 100% rename from aliases/todo.txt-cli.aliases.bash rename to aliases/available/todo.txt-cli.aliases.bash diff --git a/aliases/vim.aliases.bash b/aliases/available/vim.aliases.bash similarity index 100% rename from aliases/vim.aliases.bash rename to aliases/available/vim.aliases.bash diff --git a/aliases/emacs.aliases.bash b/aliases/emacs.aliases.bash deleted file mode 100644 index 5b328768..00000000 --- a/aliases/emacs.aliases.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -alias em="open -a emacs" \ No newline at end of file diff --git a/aliases/general.aliases.bash b/aliases/general.aliases.bash deleted file mode 100644 index 0e05eb02..00000000 --- a/aliases/general.aliases.bash +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# List directory contents -alias sl=ls -alias ls='ls -G' # Compact view, show colors -alias la='ls -AF' # Compact view, show hidden -alias ll='ls -al' -alias l='ls -a' -alias l1='ls -1' - -if [ $(uname) = "Linux" ] -then - alias ls="ls --color=always" -fi - -alias c='clear' -alias k='clear' - -alias edit="$EDITOR" -alias page="$PAGER" - -alias q="exit" - -alias irc="$IRC_CLIENT" - -alias rb="ruby" - -# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/ - -alias piano="pianobar" - -alias ..='cd ..' # Go up one directory -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'" - -# Directory -alias md='mkdir -p' -alias rd=rmdir -alias d='dirs -v' - -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 = clear" - echo " .. = cd .." - echo " ... = cd ../.." - echo " - = cd -" - echo " h = history" - echo " md = mkdir -p" - echo " rd = rmdir" - echo " d = dirs -v" - echo " editor = $EDITOR" - echo " pager = $PAGER" - echo " piano = pianobar" - echo " q = exit" - echo " irc = $IRC_CLIENT" - echo -} diff --git a/aliases/jekyll.aliases.bash b/aliases/jekyll.aliases.bash deleted file mode 100644 index e52c0351..00000000 --- a/aliases/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" diff --git a/aliases/textmate.aliases.bash b/aliases/textmate.aliases.bash deleted file mode 100644 index ecd616ff..00000000 --- a/aliases/textmate.aliases.bash +++ /dev/null @@ -1,5 +0,0 @@ -#!/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 diff --git a/bash_it.sh b/bash_it.sh index 60bef802..7844f37e 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -4,48 +4,65 @@ # Reload Library alias reload='source ~/.bash_profile' -# Load the framework +# Only set $BASH_IT if it's not already set +if [ -z "$BASH_IT" ]; +then + # Setting $BASH to maintain backwards compatibility + # TODO: warn users that they should upgrade their .bash_profile + export BASH_IT=$BASH + export BASH=`bash -c 'echo $BASH'` +fi + +# For backwards compatibility, look in old BASH_THEME location +if [ -z "$BASH_IT_THEME" ]; +then + # TODO: warn users that they should upgrade their .bash_profile + export BASH_IT_THEME="$BASH_THEME"; + unset $BASH_THEME; +fi # Load colors first so they can be use in base theme -source "${BASH}/themes/colors.theme.bash" -source "${BASH}/themes/base.theme.bash" +source "${BASH_IT}/themes/colors.theme.bash" +source "${BASH_IT}/themes/base.theme.bash" -# Library -LIB="${BASH}/lib/*.bash" +# library +LIB="${BASH_IT}/lib/*.bash" for config_file in $LIB do source $config_file done -# Tab Completion -COMPLETION="${BASH}/completion/*.bash" -for config_file in $COMPLETION +# Load enabled aliases, completion, plugins +for file_type in "aliases" "completion" "plugins" do - source $config_file + if [ ! -d "${BASH_IT}/${file_type}/enabled" ] + then + continue + fi + FILES="${BASH_IT}/${file_type}/enabled/*.bash" + for config_file in $FILES + do + if [ -e "${config_file}" ]; then + source $config_file + fi + done done -# Plugins -PLUGINS="${BASH}/plugins/*.bash" -for config_file in $PLUGINS -do - source $config_file -done - -# Aliases -FUNCTIONS="${BASH}/aliases/*.bash" -for config_file in $FUNCTIONS -do - source $config_file -done +# Load any custom aliases that the user has added +if [ -e "${BASH_IT}/aliases/custom.aliases.bash" ] +then + source "${BASH_IT}/aliases/custom.aliases.bash" +fi # Custom -CUSTOM="${BASH}/custom/*.bash" +CUSTOM="${BASH_IT}/custom/*.bash" for config_file in $CUSTOM do - source $config_file + if [ -e "${config_file}" ]; then + source $config_file + fi done - unset config_file if [[ $PROMPT ]]; then export PS1=$PROMPT @@ -56,6 +73,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 @@ -68,6 +92,7 @@ function bash-it() { echo " rails-help This will list out all the aliases you can use with rails." echo " git-help This will list out all the aliases you can use with git." echo " todo-help This will list out all the aliases you can use with todo.txt-cli" + echo " brew-help This will list out all the aliases you can use with Homebrew" echo " aliases-help Generic list of aliases." echo " plugins-help This will list out all the plugins and functions you can use with bash-it" echo diff --git a/completion/brew.completion.bash b/completion/available/brew.completion.bash similarity index 64% rename from completion/brew.completion.bash rename to completion/available/brew.completion.bash index 371fe77f..50f6c08d 100644 --- a/completion/brew.completion.bash +++ b/completion/available/brew.completion.bash @@ -1,5 +1,9 @@ if which brew >/dev/null 2>&1; then + if [ -f `brew --prefix`/etc/bash_completion ]; then + . `brew --prefix`/etc/bash_completion + fi + if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then . `brew --prefix`/Library/Contributions/brew_bash_completion.sh fi -fi \ No newline at end of file +fi diff --git a/completion/available/gem.completion.bash b/completion/available/gem.completion.bash new file mode 100644 index 00000000..de986e08 --- /dev/null +++ b/completion/available/gem.completion.bash @@ -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 diff --git a/completion/git.completion.bash b/completion/available/git.completion.bash similarity index 100% rename from completion/git.completion.bash rename to completion/available/git.completion.bash diff --git a/completion/git_flow.completion.bash b/completion/available/git_flow.completion.bash similarity index 100% rename from completion/git_flow.completion.bash rename to completion/available/git_flow.completion.bash diff --git a/completion/rake.completion.bash b/completion/available/rake.completion.bash similarity index 100% rename from completion/rake.completion.bash rename to completion/available/rake.completion.bash diff --git a/completion/ssh.completion.bash b/completion/available/ssh.completion.bash similarity index 100% rename from completion/ssh.completion.bash rename to completion/available/ssh.completion.bash diff --git a/completion/todo.completion.bash b/completion/available/todo.completion.bash similarity index 100% rename from completion/todo.completion.bash rename to completion/available/todo.completion.bash diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..a80a7499 --- /dev/null +++ b/install.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +BASH_IT="$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_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled" + ln -s $BASH_IT/${file_type}/available/* "${BASH_IT}/${file_type}/enabled" +} + +function load_some() { + file_type=$1 + for file in `ls $BASH_IT/${file_type}/available` + do + if [ ! -d "$BASH_IT/$file_type/enabled" ] + then + mkdir "$BASH_IT/$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_IT/$file_type/available/$file" "$BASH_IT/$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 diff --git a/lib/appearance.bash b/lib/appearance.bash index f7235118..28a131a4 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -8,6 +8,6 @@ export GREP_COLOR='1;33' export LSCOLORS='Gxfxcxdxdxegedabagacad' # Load the theme -if [[ $BASH_THEME ]]; then - source "$BASH/themes/$BASH_THEME/$BASH_THEME.theme.bash" -fi \ No newline at end of file +if [[ $BASH_IT_THEME ]]; then + source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" +fi diff --git a/plugins/base.plugin.bash b/plugins/available/base.plugin.bash similarity index 65% rename from plugins/base.plugin.bash rename to plugins/available/base.plugin.bash index 02c0104b..7a6dc80f 100644 --- a/plugins/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -6,14 +6,50 @@ function ips { ifconfig | grep "inet " | awk '{ print $2 }' } +function down4me() { + curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g' +} + function myip { res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') echo "Your public IP is: ${bold_green} $res ${normal}" } -function mkcd(){ - mkdir -p "$*" - cd "$*" +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 pmdown() { + if command -v markdown &>/dev/null + then + markdown $1 | browser + else + echo "You don't have a markdown command installed!" + fi +} + +# Make a directory and immediately 'cd' into it + +function mkcd() { + mkdir -p "$*" + cd "$*" +} + +# Search through directory contents with grep + +function lsgrep(){ + ls | grep "$*" } # View man documentation in Preview @@ -69,6 +105,11 @@ function t() { fi } +# Checks for existence of a command +command_exists () { + type "$1" &> /dev/null ; +} + # List all plugins and functions defined by bash-it function plugins-help() { diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash new file mode 100644 index 00000000..7c158122 --- /dev/null +++ b/plugins/available/battery.plugin.bash @@ -0,0 +1,129 @@ +#!/bin/bash + +battery_percentage(){ + if command_exists acpi; + then + local ACPI_OUTPUT=$(acpi -b) + case $ACPI_OUTPUT in + *" Unknown"*) + local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 22 | tail -c 2) + case $PERC_OUTPUT in + *%) + echo "0${PERC_OUTPUT}" | head -c 2 + ;; + *) + echo ${PERC_OUTPUT} + ;; + esac + ;; + *" Discharging"*) + local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 26 | tail -c 2) + case $PERC_OUTPUT in + *%) + echo "0${PERC_OUTPUT}" | head -c 2 + ;; + *) + echo ${PERC_OUTPUT} + ;; + esac + ;; + *" Charging"*) + local PERC_OUTPUT=$(echo $ACPI_OUTPUT | head -c 23 | tail -c 2) + case $PERC_OUTPUT in + *%) + echo "0${PERC_OUTPUT}" | head -c 2 + ;; + *) + echo ${PERC_OUTPUT} + ;; + esac + ;; + *" Full"*) + echo '99' + ;; + *) + echo '-1' + ;; + esac + elif command_exists ioreg; + then + # http://hints.macworld.com/article.php?story=20100130123935998 + #local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}') + #local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}') + local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') + case $IOREG_OUTPUT in + 100*) + echo '99' + ;; + *) + echo $IOREG_OUTPUT | head -c 2 + ;; + esac + else + echo "no" + fi +} + +battery_charge(){ + # Full char + local F_C='▸' + # Depleted char + local D_C='▹' + local DEPLETED_COLOR="${normal}" + local FULL_COLOR="${green}" + local HALF_COLOR="${yellow}" + local DANGER_COLOR="${red}" + local BATTERY_OUTPUT="${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${D_C}" + local BATTERY_PERC=$(battery_percentage) + + case $BATTERY_PERC in + no) + echo "" + ;; + 9*) + echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${normal}" + ;; + 8*) + echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${normal}" + ;; + 7*) + echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${normal}" + ;; + 6*) + echo "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${normal}" + ;; + 5*) + echo "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}" + ;; + 4*) + echo "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}" + ;; + 3*) + echo "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}" + ;; + 2*) + echo "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}" + ;; + 1*) + echo "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + 05) + echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + 04) + echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + 03) + echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + 02) + echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + 0*) + echo "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}" + ;; + *) + echo "${DANGER_COLOR}UNPLG${normal}" + ;; + esac +} diff --git a/plugins/available/browser.plugin.bash b/plugins/available/browser.plugin.bash new file mode 100644 index 00000000..fdfba4f6 --- /dev/null +++ b/plugins/available/browser.plugin.bash @@ -0,0 +1,97 @@ +# based on https://gist.github.com/318247 + +# Usage: browser +# pipe html to a browser +# e.g. +# $ echo "

hi mom!

" | browser +# $ ron -5 man/rip.5.ron | browser + +function browser() { + if [ -t 0 ]; then + if [ -n "$1" ]; then + open $1 + else + cat <hi mom!' | browser +$ ron -5 man/rip.5.ron | browser +usage + + fi + + else + f="/tmp/browser.$RANDOM.html" + cat /dev/stdin > $f + open $f + fi +} + + +# pipe hot spicy interwebs into textmate and cleanup! +# +# Usage: wmate +# wget into a pipe into TextMate and force Tidy (you can undo in textmate) +# e.g. +# $ wmate google.com + +function wmate() { + if [ -t 0 ]; then + if [ -n "$1" ]; then + wget -qO- $1 | /usr/bin/mate + +TIDY=`/usr/bin/osascript << EOT +tell application "TextMate" + activate +end tell + +tell application "System Events" + tell process "TextMate" + tell menu bar 1 + tell menu bar item "Bundles" + tell menu "Bundles" + tell menu item "HTML" + tell menu "HTML" + click menu item "Tidy" + end tell + end tell + end tell + end tell + end tell + end tell +end tell +EOT` + + else + cat <: Adds given location to stack." + echo "1 : Chance to stack location 1." + echo "2 : Chance to stack location 2." + echo "3 : Chance to stack location 3." + echo "4 : Chance to stack location 4." + echo "5 : Chance to stack location 5." + echo "6 : Chance to stack location 6." + echo "7 : Chance to stack location 7." + 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 + 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 diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash new file mode 100644 index 00000000..1c3e9b1a --- /dev/null +++ b/plugins/available/extract.plugin.bash @@ -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 +} diff --git a/plugins/git.plugins.bash b/plugins/available/git.plugins.bash similarity index 50% rename from plugins/git.plugins.bash rename to plugins/available/git.plugins.bash index 5f4cc51e..b0b9ce8c 100644 --- a/plugins/git.plugins.bash +++ b/plugins/available/git.plugins.bash @@ -54,3 +54,42 @@ function git_info() { fi } +function git_stats { +# awesome work from https://github.com/esc/git-stats +# including some modifications + +if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + echo "Number of commits per author:" + git --no-pager shortlog -sn --all + AUTHORS=$( git shortlog -sn --all | cut -f2 | cut -f1 -d' ') + LOGOPTS="" + if [ "$1" == '-w' ]; then + LOGOPTS="$LOGOPTS -w" + shift + fi + if [ "$1" == '-M' ]; then + LOGOPTS="$LOGOPTS -M" + shift + fi + if [ "$1" == '-C' ]; then + LOGOPTS="$LOGOPTS -C --find-copies-harder" + shift + fi + for a in $AUTHORS + do + echo '-------------------' + echo "Statistics for: $a" + echo -n "Number of files changed: " + git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f3 | sort -iu | wc -l + echo -n "Number of lines added: " + git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}' + echo -n "Number of lines deleted: " + git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}' + echo -n "Number of merges: " + git log $LOGOPTS --all --merges --author=$a | grep -c '^commit' + done +else + echo "you're currently not in a git repository" +fi +} + diff --git a/plugins/hg.plugins.bash b/plugins/available/hg.plugins.bash similarity index 100% rename from plugins/hg.plugins.bash rename to plugins/available/hg.plugins.bash diff --git a/plugins/available/javascript.plugins.bash b/plugins/available/javascript.plugins.bash new file mode 100644 index 00000000..a480d9e4 --- /dev/null +++ b/plugins/available/javascript.plugins.bash @@ -0,0 +1,32 @@ +#!/bin/bash +# +# The install directory is hard-coded. TOOD: allow the directory to be specified on the command line. +# + +[[ -z "$JQUERY_VERSION_NUMBER" ]] && JQUERY_VERSION_NUMBER="1.6.1" +[[ -z "$JQUERY_UI_VERSION_NUMBER" ]] && JQUERY_UI_VERSION_NUMBER="1.8.13" + +function rails_jquery { + curl -o public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js +} + +function jquery_install { + if [ -z "$1" ] + then + version=$JQUERY_VERSION_NUMBER + else + version="$1" + fi + curl -o public/javascripts/jquery.js "http://ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js" +} + +function jquery_ui_install { + if [ -z "$1" ] + then + version=$JQUERY_UI_VERSION_NUMBER + else + version="$1" + fi + + curl -o public/javascripts/jquery_ui.js "http://ajax.googleapis.com/ajax/libs/jqueryui/$version/jquery-ui.min.js" +} diff --git a/plugins/available/jekyll.plugins.bash b/plugins/available/jekyll.plugins.bash new file mode 100644 index 00000000..eff85ce3 --- /dev/null +++ b/plugins/available/jekyll.plugins.bash @@ -0,0 +1,346 @@ +#!/bin/bash + +editpost() { + 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 + 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 "$JEKYLL_EDITOR" ] + then + nano "${POSTS[$POST_TO_EDIT]}" + else + "$JEKYLL_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 + + 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 "$SITE/_posts" + + # Get the date for the new post's filename + + FNAME_DATE=$(date "+%Y-%m-%d") + + # 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" + + if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ] + then + select OPTION in $OPTIONS + do + if [[ $OPTION = "Text" ]] + then + POST_TYPE="Text" + break + fi + + if [[ $OPTION = "Quote" ]] + then + POST_TYPE="Quote" + break + fi + + if [[ $OPTION = "Image" ]] + then + POST_TYPE="Image" + break + fi + + if [[ $OPTION = "Audio" ]] + then + POST_TYPE="Audio" + break + fi + + if [[ $OPTION = "Video" ]] + then + POST_TYPE="Video" + break + fi + + if [[ $OPTION = "Link" ]] + then + POST_TYPE="Link" + break + fi + done + fi + + # Get the title for the new post + + read -p "Enter title of the new post: " POST_TITLE + + # Convert the spaces in the title to hyphens for use in the filename + + FNAME_POST_TITLE=`echo $POST_TITLE | tr ' ' "-"` + + # Now, put it all together for the full filename + + FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING" + + # And, finally, create the actual post file. But we're not done yet... + + touch "$FNAME" + + # Write a little stuff to the file for the YAML Front Matter + + echo "---" >> $FNAME + + # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of + # the file + + YAML_DATE=$(date "+%B %d %Y %X") + + # Echo the YAML Formatted date to the post file + + echo "date: $YAML_DATE" >> $FNAME + + # Echo the original post title to the YAML Front Matter header + + echo "title: $POST_TITLE" >> $FNAME + + # And, now, echo the "post" layout to the YAML Front Matter header + + echo "layout: post" >> $FNAME + + # Close the YAML Front Matter Header + + echo "---" >> $FNAME + echo >> $FNAME + + # Generate template text based on the post type + + if [[ $JEKYLL_FORMATTING = "markdown" ]] + then + if [[ $POST_TYPE = "Text" ]] + then + true + fi + + if [[ $POST_TYPE = "Quote" ]] + then + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi + + if [[ $POST_TYPE = "Image" ]] + then + echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME + fi + + if [[ $POST_TYPE = "Audio" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Link" ]] + then + echo "[link][1]" >> $FNAME + echo >> $FNAME + echo "> Quote" >> $FNAME + echo >> $FNAME + echo "[1]: url" >> $FNAME + fi + fi + + if [[ $JEKYLL_FORMATTING = "textile" ]] + then + if [[ $POST_TYPE = "Text" ]] + then + true + fi + + if [[ $POST_TYPE = "Quote" ]] + then + echo "bq. Quote" >> $FNAME + echo >> $FNAME + echo "— Author" >> $FNAME + fi + + if [[ $POST_TYPE = "Image" ]] + then + echo "!url(alt text)" >> $FNAME + fi + + if [[ $POST_TYPE = "Audio" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Video" ]] + then + echo "" >> $FNAME + fi + + if [[ $POST_TYPE = "Link" ]] + then + echo "\"Site\":url" >> $FNAME + echo >> $FNAME + echo "bq. Quote" >> $FNAME + fi + fi + + # Open the file in your favorite editor + + "$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 +} diff --git a/plugins/available/latex.plugin.bash b/plugins/available/latex.plugin.bash new file mode 100644 index 00000000..95592556 --- /dev/null +++ b/plugins/available/latex.plugin.bash @@ -0,0 +1,8 @@ +#!/bin/bash + +# add mactex to the path if its present +MACTEX_PATH=/usr/local/texlive/2009/bin/universal-darwin +if [[ -d $MACTEX_PATH ]]; then + export PATH=$PATH:$MACTEX_PATH +fi +unset MACTEX_PATH diff --git a/plugins/nginx.plugins.bash b/plugins/available/nginx.plugins.bash similarity index 100% rename from plugins/nginx.plugins.bash rename to plugins/available/nginx.plugins.bash diff --git a/plugins/available/nvm.plugin.bash b/plugins/available/nvm.plugin.bash new file mode 100644 index 00000000..a5145ec2 --- /dev/null +++ b/plugins/available/nvm.plugin.bash @@ -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 +# 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 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" + 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 " 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 + ;; + "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 diff --git a/plugins/osx.plugin.bash b/plugins/available/osx.plugin.bash similarity index 73% rename from plugins/osx.plugin.bash rename to plugins/available/osx.plugin.bash index e6271bd7..cf553777 100644 --- a/plugins/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,21 @@ 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 } + +# 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" +} diff --git a/plugins/available/python.plugin.bash b/plugins/available/python.plugin.bash new file mode 100644 index 00000000..3a0bf7fd --- /dev/null +++ b/plugins/available/python.plugin.bash @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ $(uname) = "Linux" ] +then + alias http='python2 -m SimpleHTTPServer' +else + alias http='python -m SimpleHTTPServer' +fi + diff --git a/plugins/ruby.plugin.bash b/plugins/available/ruby.plugin.bash similarity index 100% rename from plugins/ruby.plugin.bash rename to plugins/available/ruby.plugin.bash diff --git a/plugins/available/rvm.plugin.bash b/plugins/available/rvm.plugin.bash new file mode 100644 index 00000000..e158a800 --- /dev/null +++ b/plugins/available/rvm.plugin.bash @@ -0,0 +1,29 @@ +#!/bin/bash + +# Load RVM, if you are using it +[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm + +# Check to make sure that RVM is actually loaded before adding +# the customizations to it. +if [ "$rvm_path" ] +then + # Load the auto-completion script if RVM was loaded. + [[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion + + switch () { + rvm $1 + local v=$(rvm_version) + rvm wrapper $1 textmate + echo "Switch to Ruby version: "$v + } + + rvm_default () { + rvm --default $1 + rvm wrapper $1 textmate + } + + function rvm_version () { + ruby --version + } + +fi diff --git a/plugins/ssh.plugins.bash b/plugins/available/ssh.plugins.bash similarity index 100% rename from plugins/ssh.plugins.bash rename to plugins/available/ssh.plugins.bash diff --git a/plugins/subversion.plugin.bash b/plugins/available/subversion.plugin.bash similarity index 100% rename from plugins/subversion.plugin.bash rename to plugins/available/subversion.plugin.bash diff --git a/plugins/available/tmux.plugin.bash b/plugins/available/tmux.plugin.bash new file mode 100644 index 00000000..ff353364 --- /dev/null +++ b/plugins/available/tmux.plugin.bash @@ -0,0 +1,2 @@ +# make sure that tmux is launched in 256 color mode +alias tmux="TERM=xterm-256color tmux" 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 diff --git a/plugins/vagrant.plugins.bash b/plugins/available/vagrant.plugins.bash similarity index 100% rename from plugins/vagrant.plugins.bash rename to plugins/available/vagrant.plugins.bash diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash new file mode 100644 index 00000000..a0e7b3f4 --- /dev/null +++ b/plugins/available/virtualenv.plugin.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +# make sure virtualenvwrapper is enabled if availalbe +[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh + diff --git a/plugins/z.bash b/plugins/available/z.bash similarity index 100% rename from plugins/z.bash rename to plugins/available/z.bash diff --git a/plugins/browser.plugin.bash b/plugins/browser.plugin.bash deleted file mode 100644 index 6de184c3..00000000 --- a/plugins/browser.plugin.bash +++ /dev/null @@ -1,29 +0,0 @@ -# based on https://gist.github.com/318247 - -# Usage: browser -# pipe html to a browser -# e.g. -# $ echo "

hi mom!

" | browser -# $ ron -5 man/rip.5.ron | browser - -function browser() { - if [ -t 0 ]; then - if [ -n "$1" ]; then - open $1 - else - cat <hi mom!' | browser -$ ron -5 man/rip.5.ron | browser -usage - - fi - - else - f="/tmp/browser.$RANDOM.html" - cat /dev/stdin > $f - open $f - fi -} diff --git a/plugins/hcht.plugin.bash b/plugins/hcht.plugin.bash deleted file mode 100644 index cdab44fb..00000000 --- a/plugins/hcht.plugin.bash +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# hcht.plugin.bash: the handmade commandline history tool -# Copyright: (C) 2010 Florian Baumann -# License: GPL-3 -# Date: Dienstag 2010-11-30 - -### readme -# basiclly the handmade commandline history tool was made for storing -# informations. yeah, you're right. sounds a bit boring. many other -# applications can do this much better. but storing things from commandline? -# -# hcht was fitted to work at your terminal. -# your daily stuff like notices, todos, commands or output from a command. -# all these things will be stored without complex syntax. -# -# once you defined your storing-directory you will be able to easily -# save all the stuff listed above. -# - -### create a file -# the basic feature. open a file, do stuff and save. -# -# $ hcht evilcommand.hch -# -# this will create a new file or edit a existing one. -# paste your command or notice in your favorite editor - -### show all stored informations -# to get an overview of your storedir: -# -# $ hcht - -### todo with a whole sentence -# you can give hcht a bunch of parameters -# -# $ hcht this is a long reminder about a anything - -### save last executed command -# lets say you did a great hack at your system and you -# want to save it without complicated use of coping: -# -# $ hcht !! -# -# the "!!" will repeat the _last_ command you executed at -# your terminal. after asking you about a name the hch file -# will be saved. - -### read from stdin -# hcht is also able to read anything from stdin. -# -# $ cat any_important_logfile | hcht anylog -# -# "anylog" will be the name of the saved file. - -hcht() { - # configured? - if [ -z $hchtstoredir ]; then - echo "ERROR: handmade commandline history tool isn't configured." - return 1 - else - hchtstoredir=$(echo $hchtstoredir | sed -e 's/\/$//') - fi - - # dir available? - if [ ! -d $hchtstoredir ]; then - echo "ERROR: No such directory: $hchtstoredir" - return 1 - fi - - # get favorite editor - if [ -z $EDITOR ]; then - EDITOR=$(which vim || which nano) - fi - - # check if stdin-data is present and save content - if [ "$(tty)" = "not a tty" ]; then - hchname=$(echo $1 | sed -e 's/\ //g') - if [ -z $hchname ]; then - cat < /dev/stdin >> $hchtstoredir/$(date +%Y%m%d%H%M%S).hch - else - cat < /dev/stdin >> $hchtstoredir/$hchname.hch - fi - return 0 - fi - - # list all hch files if no parameter is given - if [ $# -eq 0 ]; then - for file in $(ls $hchtstoredir); do - echo $file - done - return 0 - fi - - # if a *.hch file is given start editing or creating it - if [ "$#" -eq "1" ]; then - if echo "$1" | grep -q -e ".*.hch$" ; then - $EDITOR ${hchtstoredir}/${1} - return 0 - else - $EDITOR ${hchtstoredir}/${1}.hch - return 0 - fi - fi - - # autocreate a new hch - if [ "$#" -gt "1" ]; then - echo -n "define a name: " ; read hchname - hchname=$(echo $hchname | sed -e 's/\ /_/g') - if [ -z "$hchname" ]; then - echo "$*" > $hchtstoredir/${1}-$(date +%Y%m%d%H%M%S).hch - else - echo "$*" > ${hchtstoredir}/${hchname}.hch - fi - return 0 - fi -} diff --git a/plugins/javascript.plugins.bash b/plugins/javascript.plugins.bash deleted file mode 100644 index 2e0b56cb..00000000 --- a/plugins/javascript.plugins.bash +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# The install directory is hard-coded. TOOD: allow the directory to be specified on the command line. -# - - -function rails_jquery { - curl -o public/javascripts/rails.js http://github.com/rails/jquery-ujs/raw/master/src/rails.js -} - -function jquery_install { - curl -o public/javascripts/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js -} - -function jquery_ui_install { - curl -o public/javascripts/jquery_ui.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js -} \ No newline at end of file diff --git a/plugins/jekyll.plugins.bash b/plugins/jekyll.plugins.bash deleted file mode 100644 index aebe69bc..00000000 --- a/plugins/jekyll.plugins.bash +++ /dev/null @@ -1,208 +0,0 @@ -#!/bin/bash - -editpost() { - builtin cd "$JEKYLL_LOCAL_ROOT/_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() { - - # 'builtin cd' into the local jekyll root - - builtin cd "$JEKYLL_LOCAL_ROOT/_posts" - - # Get the date for the new post's filename - - 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. - - 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 - - if [[ $OPTION = "Quote" ]] - then - POST_TYPE="Quote" - break - fi - - if [[ $OPTION = "Image" ]] - then - POST_TYPE="Image" - break - fi - - if [[ $OPTION = "Audio" ]] - then - POST_TYPE="Audio" - break - fi - - if [[ $OPTION = "Video" ]] - then - POST_TYPE="Video" - break - fi - - if [[ $OPTION = "Link" ]] - then - POST_TYPE="Link" - break - fi - done - fi - - # Get the title for the new post - - read -p "Enter title of the new post: " POST_TITLE - - # Convert the spaces in the title to hyphens for use in the filename - - FNAME_POST_TITLE=`echo $POST_TITLE | tr ' ' "-"` - - # Now, put it all together for the full filename - - FNAME="$FNAME_DATE-$FNAME_POST_TITLE.$JEKYLL_FORMATTING" - - # And, finally, create the actual post file. But we're not done yet... - - touch "$FNAME" - - # Write a little stuff to the file for the YAML Front Matter - - echo "---" >> $FNAME - - # Now we have to get the date, again. But this time for in the header (YAML Front Matter) of - # the file - - YAML_DATE=$(date "+%B %d %Y %X") - - # Echo the YAML Formatted date to the post file - - echo "date: $YAML_DATE" >> $FNAME - - # Echo the original post title to the YAML Front Matter header - - echo "title: $POST_TITLE" >> $FNAME - - # And, now, echo the "post" layout to the YAML Front Matter header - - echo "layout: post" >> $FNAME - - # Close the YAML Front Matter Header - - echo "---" >> $FNAME - echo >> $FNAME - - # Generate template text based on the post type - - if [[ $JEKYLL_FORMATTING = "markdown" ]] - then - if [[ $POST_TYPE = "Text" ]] - then - true - fi - - if [[ $POST_TYPE = "Quote" ]] - then - echo "> Quote" >> $FNAME - echo >> $FNAME - echo "— Author" >> $FNAME - fi - - if [[ $POST_TYPE = "Image" ]] - then - echo "![Alternate Text](/path/to/image/or/url)" >> $FNAME - fi - - if [[ $POST_TYPE = "Audio" ]] - then - echo "" >> $FNAME - fi - - if [[ $POST_TYPE = "Video" ]] - then - echo "" >> $FNAME - fi - - if [[ $POST_TYPE = "Link" ]] - then - echo "[link][1]" >> $FNAME - echo >> $FNAME - echo "> Quote" >> $FNAME - echo >> $FNAME - echo "[1]: url" >> $FNAME - fi - fi - - if [[ $JEKYLL_FORMATTING = "textile" ]] - then - if [[ $POST_TYPE = "Text" ]] - then - true - fi - - if [[ $POST_TYPE = "Quote" ]] - then - echo "bq. Quote" >> $FNAME - echo >> $FNAME - echo "— Author" >> $FNAME - fi - - if [[ $POST_TYPE = "Image" ]] - then - echo "!url(alt text)" >> $FNAME - fi - - if [[ $POST_TYPE = "Audio" ]] - then - echo "" >> $FNAME - fi - - if [[ $POST_TYPE = "Video" ]] - then - echo "" >> $FNAME - fi - - 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 -} diff --git a/plugins/python.plugin.bash b/plugins/python.plugin.bash deleted file mode 100644 index 92f50e02..00000000 --- a/plugins/python.plugin.bash +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -alias http='python -m SimpleHTTPServer' - diff --git a/plugins/rvm.plugin.bash b/plugins/rvm.plugin.bash deleted file mode 100644 index d3c81ed4..00000000 --- a/plugins/rvm.plugin.bash +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -switch () { - rvm $1 - local v=$(rvm_version) - rvm wrapper $1 textmate - echo "Switch to Ruby version: "$v -} - -rvm_default () { - rvm --default $1 - rvm wrapper $1 textmate -} - -function rvm_version () { - ruby --version -} \ No newline at end of file diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 17853b1a..34d99ac1 100644 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -7,11 +7,11 @@ export PATH=$PATH:~/.gem/ruby/1.8/bin:/opt/nginx/sbin # Path to the bash it configuration -export BASH=$HOME/.bash_it +export BASH_IT=$HOME/.bash_it # Lock and Load a custom theme file # location /.bash_it/themes/ -export BASH_THEME='bobby' +export BASH_IT_THEME='bobby' # Your place for hosting Git repos. I use this for private repos. export GIT_HOSTING='git@git.domain.com' @@ -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. @@ -47,8 +35,9 @@ export IRC_CLIENT='irssi' export TODO="t" -# Set store directory for handmade commandline history tool -export hchtstoredir="$HOME/.hcht" +# Set vcprompt executable path for scm advance info in prompt (demula theme) +# https://github.com/xvzf/vcprompt +#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt # Load Bash It -source $BASH/bash_it.sh +source $BASH_IT/bash_it.sh diff --git a/template/jekyllconfig.template.bash b/template/jekyllconfig.template.bash new file mode 100644 index 00000000..291bf85e --- /dev/null +++ b/template/jekyllconfig.template.bash @@ -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" diff --git a/themes/base.theme.bash b/themes/base.theme.bash index d9f5c580..5a823c87 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -1,79 +1,109 @@ #!/bin/bash +THEME_PROMPT_HOST='\H' SCM_THEME_PROMPT_DIRTY=' ✗' SCM_THEME_PROMPT_CLEAN=' ✓' SCM_THEME_PROMPT_PREFIX=' |' SCM_THEME_PROMPT_SUFFIX='|' -GIT='git' +SCM_GIT='git' SCM_GIT_CHAR='±' -HG='hg' +SCM_HG='hg' SCM_HG_CHAR='☿' -SVN='svn' +SCM_SVN='svn' SCM_SVN_CHAR='⑆' +SCM_NONE='NONE' SCM_NONE_CHAR='○' RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_SUFFIX='|' +VIRTUALENV_THEME_PROMPT_PREFIX=' |' +VIRTUALENV_THEME_PROMPT_SUFFIX='|' + function scm { - if [[ -d .git ]]; then SCM=$GIT - elif [[ -d .hg ]]; then SCM=$HG - elif [[ -d .svn ]]; then SCM=$SVN - else SCM='NONE' + if [[ -d .git ]]; then SCM=$SCM_GIT + elif [[ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]]; then SCM=$SCM_GIT + elif [[ -d .hg ]]; then SCM=$SCM_HG + elif [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG + elif [[ -d .svn ]]; then SCM=$SCM_SVN + else SCM=$SCM_NONE fi } -function scm_char { +function scm_prompt_char { if [[ -z $SCM ]]; then scm; fi - [[ $SCM == $GIT ]] && echo $SCM_GIT_CHAR && return - [[ $SCM == $HG ]] && echo $SCM_HG_CHAR && return - [[ $SCM == $SVN ]] && echo $SCM_SVN_CHAR && return - echo $SCM_NONE_CHAR + if [[ $SCM == $SCM_GIT ]]; then SCM_CHAR=$SCM_GIT_CHAR + elif [[ $SCM == $SCM_HG ]]; then SCM_CHAR=$SCM_HG_CHAR + elif [[ $SCM == $SCM_SVN ]]; then SCM_CHAR=$SCM_SVN_CHAR + else SCM_CHAR=$SCM_NONE_CHAR + fi +} + +function scm_prompt_vars { + scm + scm_prompt_char + SCM_DIRTY=0 + SCM_STATE='' + [[ $SCM == $SCM_GIT ]] && git_prompt_vars && return + [[ $SCM == $SCM_HG ]] && hg_prompt_vars && return + [[ $SCM == $SCM_SVN ]] && svn_prompt_vars && return } function scm_prompt_info { - if [[ -z $SCM ]]; then scm; fi - [[ $SCM == $GIT ]] && git_prompt_info && return - [[ $SCM == $HG ]] && hg_prompt_info && return -# [[ $SCM == $SVN ]] && svn_prompt_info && return + scm + scm_prompt_char + SCM_DIRTY=0 + SCM_STATE='' + [[ $SCM == $SCM_GIT ]] && git_prompt_info && return + [[ $SCM == $SCM_HG ]] && hg_prompt_info && return + [[ $SCM == $SCM_SVN ]] && svn_prompt_info && return } -# Stolen from Steve Losh -# left in for backwards-compatibility -function prompt_char { - char=$(scm_char); - echo -e "$char" -} - -function git_prompt_info { +function git_prompt_vars { if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then - state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + SCM_DIRTY=1 + SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else - state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + SCM_DIRTY=0 + SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi - prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} - suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - - echo -e "$prefix${ref#refs/heads/}$state$suffix" + SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + local ref=$(git symbolic-ref HEAD 2> /dev/null) + SCM_BRANCH=${ref#refs/heads/} + SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null) } -function svn_prompt_info { +function svn_prompt_vars { if [[ -n $(svn status 2> /dev/null) ]]; then - state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + SCM_DIRTY=1 + SCM_STATE=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else - state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + SCM_DIRTY=0 + SCM_STATE=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi - prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} - suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return + SCM_PREFIX=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + SCM_SUFFIX=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + SCM_BRANCH=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return + SCM_CHANGE=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) +} - [[ -z $ref ]] && return - echo -e "$prefix$ref$state$suffix" +function hg_prompt_vars { + if [[ -n $(hg status 2> /dev/null) ]]; then + SCM_DIRTY=1 + SCM_STATE=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + SCM_DIRTY=0 + SCM_STATE=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + SCM_PREFIX=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + SCM_BRANCH=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') + SCM_CHANGE=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') } function hg_prompt_info() { @@ -96,3 +126,35 @@ function rvm_version_prompt { echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" fi } + +function virtualenv_prompt { + if which virtualenv &> /dev/null; then + virtualenv=$([ ! -z "$VIRTUAL_ENV" ] && echo "`basename $VIRTUAL_ENV`") || return + echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX" + fi +} + +# backwards-compatibility +function git_prompt_info { + git_prompt_vars + echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX" +} + +function svn_prompt_info { + svn_prompt_vars + echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX" +} + +function hg_prompt_info() { + hg_prompt_vars + echo -e "$SCM_PREFIX$SCM_BRANCH:${SCM_CHANGE#*:}$SCM_STATE$SCM_SUFFIX" +} + +function scm_char { + scm_prompt_char + echo -e "$SCM_CHAR" +} + +function prompt_char { + scm_char +} diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 8b48ddd9..cb51fb85 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -4,15 +4,6 @@ SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${green}|" - -# PROMPT="\[${bold_cyan}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\]\[${purple}\]\[\$(rvm_version_prompt)\] \[${yellow}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[\n\[${green}\]→\[${reset_color}\] " - - -PROMPT="\n\[${yellow}\]\[\$(rvm_version_prompt)\] \[${purple}\]\h \[${reset_color}\]in \[${green}\]\w\n\[${bold_cyan}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\] \[\[${green}\]→\[${reset_color}\] " - - - -# git theming GIT_THEME_PROMPT_DIRTY=" ${red}✗" GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${green}|" @@ -21,3 +12,9 @@ GIT_THEME_PROMPT_SUFFIX="${green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" +function prompt_command() { + #PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(rvm_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} " + PS1="\n${yellow}$(rvm_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} " +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/candy/candy.theme.bash b/themes/candy/candy.theme.bash index ef0ba262..64d31b83 100644 --- a/themes/candy/candy.theme.bash +++ b/themes/candy/candy.theme.bash @@ -1,2 +1,6 @@ #!/bin/bash -PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(scm_prompt_info)\]${blue} →${bold_blue} \$${reset_color} " \ No newline at end of file +function prompt_command() { + PS1="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}$(scm_prompt_info)\]${blue} →${bold_blue} ${reset_color} "; +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 2fc418f8..9998d65e 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -1,9 +1,3 @@ -if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi - -PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " -RPROMPT='[\t]' - - # git theming ZSH_THEME_GIT_PROMPT_PREFIX="${bold_blue}(${yellow}%B" ZSH_THEME_GIT_PROMPT_SUFFIX="%b${bold_blue})${reset_color} " @@ -13,4 +7,14 @@ ZSH_THEME_GIT_PROMPT_DIRTY="${bold_red}✗" # LS colors, made with http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" -export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' \ No newline at end of file +export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' + +function prompt_command() { + + if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi + + PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ " + RPROMPT='[\t]' +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash new file mode 100644 index 00000000..bd48e12c --- /dev/null +++ b/themes/demula/demula.theme.bash @@ -0,0 +1,121 @@ +#!/bin/bash + +# Theme inspired on: +# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ +# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ +# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ +# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ +# - Bash_it modern theme +# +# Screenshot: http://goo.gl/VCmX5 +# by Jesus de Mula + +# For the real Monokai colors you should add these to your .XDefaults or +# terminal configuration: +#! ----------------------------------------------------------- TERMINAL COLORS +#! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/ +#*background: #272822 +#*foreground: #E2DA6E +#*color0: black +#! mild red +#*color1: #CD0000 +#! light green +#*color2: #A5E02D +#! orange (yellow) +#*color3: #FB951F +#! "dark" blue +#*color4: #076BCC +#! hot pink +#*color5: #F6266C +#! cyan +#*color6: #64D9ED +#! gray +#*color7: #E5E5E5 + +# ----------------------------------------------------------------- COLOR CONF +D_DEFAULT_COLOR="${normal}" +D_INTERMEDIATE_COLOR="${white}" +D_USER_COLOR="${purple}" +D_SUPERUSER_COLOR="${red}" +D_MACHINE_COLOR="${cyan}" +D_DIR_COLOR="${green}" +D_SCM_COLOR="${yellow}" +D_BRANCH_COLOR="${yellow}" +D_CHANGES_COLOR="${white}" +D_CMDFAIL_COLOR="${red}" +D_VIMSHELL_COLOR="${cyan}" + +# ------------------------------------------------------------------ FUNCTIONS +case $TERM in + xterm*) + TITLEBAR="\033]0;\w\007" + ;; + *) + TITLEBAR="" + ;; +esac + +is_vim_shell() { + if [ ! -z "$VIMRUNTIME" ]; + then + echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ +vim shell${D_DEFAULT_COLOR} " + fi +} + +mitsuhikos_lastcommandfailed() { + code=$? + if [ $code != 0 ]; + then + echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\ +$code ${D_DEFAULT_COLOR}" + fi +} + +# vcprompt for scm instead of bash_it default +demula_vcprompt() { + if [ ! -z "$VCPROMPT_EXECUTABLE" ]; + then + local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\ +${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" + $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" + fi +} + +# -------------------------------------------------------------- PROMPT OUTPUT +prompt() { + local SAVE_CURSOR='\033[s' + local RESTORE_CURSOR='\033[u' + local MOVE_CURSOR_RIGHTMOST='\033[500C' + local MOVE_CURSOR_5_LEFT='\033[5D' + + if [ $(uname) = "Linux" ]; + then + PS1="${TITLEBAR} +${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\ +$(battery_charge)${RESTORE_CURSOR}\ +${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ +at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ +in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ +$(mitsuhikos_lastcommandfailed)\ +$(demula_vcprompt)\ +$(is_vim_shell) +${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" + else + PS1="${TITLEBAR} +${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ +at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ +in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ +$(mitsuhikos_lastcommandfailed)\ +$(demula_vcprompt)\ +$(is_vim_shell)\ +$(battery_charge) +${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" + fi + + PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" +} + +# Runs prompt (this bypasses bash_it $PROMPT setting) +PROMPT_COMMAND=prompt + diff --git a/themes/dos/dos.theme.bash b/themes/dos/dos.theme.bash new file mode 100644 index 00000000..17f0cff6 --- /dev/null +++ b/themes/dos/dos.theme.bash @@ -0,0 +1 @@ +PROMPT="\w>>" diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash new file mode 100644 index 00000000..c3bf453d --- /dev/null +++ b/themes/doubletime/doubletime.theme.bash @@ -0,0 +1,91 @@ +#!/bin/bash +SCM_THEME_PROMPT_DIRTY='' +SCM_THEME_PROMPT_CLEAN='' +SCM_GIT_CHAR="${bold_cyan}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" +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=") " +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 + THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); +else + THEME_PROMPT_HOST_COLOR="$blue" +fi + +doubletime_scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ]; then + return + elif [ $CHAR = $SCM_GIT_CHAR ]; then + echo "$(git_prompt_status)" + else + echo "[$(scm_prompt_info)]" + fi +} + +function prompt_setter() { + # Save history + history -a + history -c + history -r + if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]] + then + clock="\t" + else + clock=$THEME_PROMPT_CLOCK_FORMAT + fi + PS1=" +$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='+ ' +} + +PROMPT_COMMAND=prompt_setter + +git_prompt_status() { + + if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then + git_status="${bold_red}$(scm_prompt_info) ✗" + elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then + git_status="${bold_yellow}$(scm_prompt_info) ^" + elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then + git_status="${bold_cyan}$(scm_prompt_info) +" + elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then + git_status="${bold_green}$(scm_prompt_info) ${green}✓" + else + git_status="$(scm_prompt_info)" + fi + echo "[$git_status${normal}]" + +} + +# git_prompt_color() { +# +# if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then +# git_status='${bold_red} ✗' +# elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then +# git_status='${bold_yellow} ^' +# elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then +# git_status='${bold_cyan} +' +# else +# git_status='${bold_green} ✓' +# fi +# echo $git_status +# +# } diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash new file mode 100644 index 00000000..93cef469 --- /dev/null +++ b/themes/hawaii50/hawaii50.theme.bash @@ -0,0 +1,200 @@ +#!/bin/bash +# +# This theme was obviously inspired a lot by +# +# - Demula theme +# +# which in itself was inspired by : +# +# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ +# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ +# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ +# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ +# - Bash_it modern theme +# +# Hawaii50 theme supports : +# +# - configurable directory length +# - hg, svn, git detection (I work in all of them) +# - virtualenv, rvm + gemsets +# +# Screenshot: http://i.imgur.com/4IAMJ.png +# +# by Ryan Kanno +# +# And yes, we code out in Hawaii. :D +# +# Note: I also am really new to this bash scripting game, so if you see things +# that are flat out wrong, or if you think of something neat, just send a pull +# request. This probably only works on a Mac - as some functions are OS +# 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\]' + +DEFAULT_COLOR="${white}" + +USER_COLOR="${purple}" +SUPERUSER_COLOR="${red}" +MACHINE_COLOR=$ORANGE +IP_COLOR=$ORANGE +DIRECTORY_COLOR="${green}" + +VE_COLOR="${cyan}" +RVM_COLOR="${cyan}" + +REF_COLOR="${purple}" + +# SCM prompts +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_THEME_PROMPT_PREFIX=' on ' +SCM_THEME_PROMPT_SUFFIX='' + +# rvm prompts +RVM_THEME_PROMPT_PREFIX='' +RVM_THEME_PROMPT_SUFFIX='' + +# virtualenv prompts +VIRTUALENV_THEME_PROMPT_PREFIX='' +VIRTUALENV_THEME_PROMPT_SUFFIX='' + +VIRTUAL_THEME_PROMPT_PREFIX=' using ' +VIRTUAL_THEME_PROMPT_SUFFIX='' + +# Max length of PWD to display +MAX_PWD_LENGTH=20 + +# Max length of Git Hex to display +MAX_GIT_HEX_LENGTH=5 + +# IP address +IP_SEPARATOR=', ' + +# FUNCS ======================================================================= + +function ip { + myip=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') + 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) + local rvm_info=$(rvm_version_prompt) + local virtual_prompt="" + + local prefix=${VIRTUAL_THEME_PROMPT_PREFIX} + local suffix=${VIRTUAL_THEME_PROMPT_SUFFIX} + + # If no virtual info, just return + [[ -z "$virtual_env_info" && -z "$rvm_info" ]] && return + + # If virtual_env info present, append to prompt + [[ -n "$virtual_env_info" ]] && virtual_prompt="virtualenv: ${VE_COLOR}$virtual_env_info${DEFAULT_COLOR}" + + if [[ -n "$rvm_info" ]] + then + [[ -n "$virtual_env_info" ]] && virtual_prompt="$virtual_prompt, " + virtual_prompt="${virtual_prompt}rvm: ${RVM_COLOR}$rvm_info${DEFAULT_COLOR}" + fi + echo -e "$prefix$virtual_prompt$suffix" +} + +# Parse git info +function git_prompt_info() { + if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then + state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + commit_id=$(git rev-parse HEAD 2>/dev/null) || return + + echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix" +} + +# Parse hg info +function hg_prompt_info() { + if [[ -n $(hg status 2> /dev/null) ]]; then + state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}') + changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}') + + echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix" +} + +# Parse svn info +function svn_prompt_info() { + if [[ -n $(svn status --ignore-externals -q 2> /dev/null) ]]; then + state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} + else + state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} + fi + prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} + suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} + ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return + [[ -z $ref ]] && return + + revision=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) + + echo -e "$prefix${REF_COLOR}$ref${DEFAULT_COLOR}:$revision$state$suffix" +} + +# Displays last X characters of pwd +function limited_pwd() { + + # Replace $HOME with ~ if possible + RELATIVE_PWD=${PWD/#$HOME/\~} + + local offset=$((${#RELATIVE_PWD}-$MAX_PWD_LENGTH)) + + if [ $offset -gt "0" ] + then + local truncated_symbol="..." + TRUNCATED_PWD=${RELATIVE_PWD:$offset:$MAX_PWD_LENGTH} + echo -e "${truncated_symbol}/${TRUNCATED_PWD#*/}" + else + echo -e "${RELATIVE_PWD}" + fi +} + +# Displays the current prompt +function prompt() { + local UC=$USER_COLOR + [ $UID -eq "0" ] && UC=$SUPERUSER_COLOR + + if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then + 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$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ " + fi + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt diff --git a/themes/minimal/minimal.theme.bash b/themes/minimal/minimal.theme.bash index a94c4536..76cb24d5 100644 --- a/themes/minimal/minimal.theme.bash +++ b/themes/minimal/minimal.theme.bash @@ -1,21 +1,12 @@ -prompt_setter() { - if [[ $? -eq 0 ]]; then - if [ ! $VIMRUNTIME = "" ] - then - PS1="{vim} \W " - else - PS1="\W " - fi - else - if [ ! $VIMRUNTIME = "" ] - then - PS1="{vim} ${bold_red}\W ${normal}" - else - PS1="${bold_red}\W ${normal}" - fi - fi +#!/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 diff --git a/themes/modern-t/modern-t.theme.bash b/themes/modern-t/modern-t.theme.bash new file mode 100644 index 00000000..12e5b041 --- /dev/null +++ b/themes/modern-t/modern-t.theme.bash @@ -0,0 +1,56 @@ +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" + +case $TERM in + xterm*) + TITLEBAR="\[\033]0;\w\007\]" + ;; + *) + TITLEBAR="" + ;; +esac + +PS3=">> " + +is_vim_shell() { + if [ ! -z "$VIMRUNTIME" ] + then + echo "[${cyan}vim shell${normal}]" + fi +} + +modern_scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)][$(scm_prompt_info)]" + fi +} + +prompt() { + if [ $? -ne 0 ] + then + # Yes, the indenting on these is weird, but it has to be like + # this otherwise it won't display properly. + + PS1="${TITLEBAR}${bold_red}┌─[${cyan}$(t | wc -l | sed -e's/ *//')${reset_color}]${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) +${bold_red}└─▪${normal} " + else + PS1="${TITLEBAR}┌─[${cyan}$(t | wc -l | sed -e's/ *//')${reset_color}]$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) +└─▪ " + fi +} + +PS2="└─▪ " + + + +PROMPT_COMMAND=prompt diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 95d9631e..fff80350 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -1,11 +1,20 @@ SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}' -SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}' -SCM_GIT_CHAR='${bold_green}±${normal}' -SCM_SVN_CHAR='${bold_cyan}⑆${normal}' -SCM_HG_CHAR='${bold_red}☿${normal}' +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" + +case $TERM in + xterm*) + TITLEBAR="\[\033]0;\w\007\]" + ;; + *) + TITLEBAR="" + ;; +esac PS3=">> " @@ -35,7 +44,7 @@ prompt() { PS1="${bold_red}┌─${reset_color}$(scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) ${bold_red}└─▪${normal} " else - PS1="┌─$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell) + PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell) └─▪ " fi } diff --git a/themes/n0qorg/n0qorg.theme.bash b/themes/n0qorg/n0qorg.theme.bash index fcaca43f..2b9def6c 100644 --- a/themes/n0qorg/n0qorg.theme.bash +++ b/themes/n0qorg/n0qorg.theme.bash @@ -5,7 +5,11 @@ # host directory (branch*)» # for example: # ananas ~/Code/bash-it/themes (master*)» -PROMPT="${bold_blue}\[\$(hostname)\]${normal} \w${normal} ${bold_white}\[\$(git_prompt_info)\]${normal}» " +function prompt_command() { + PS1="${bold_blue}[$(hostname)]${normal} \w${normal} ${bold_white}[$(git_prompt_info)]${normal}» " +} + +PROMPT_COMMAND=prompt_command; ## git-theme # feel free to change git chars. diff --git a/themes/pete/pete.theme.bash b/themes/pete/pete.theme.bash index 95f243af..7b6702cf 100644 --- a/themes/pete/pete.theme.bash +++ b/themes/pete/pete.theme.bash @@ -5,7 +5,7 @@ prompt_setter() { history -a history -c history -r - PS1="(\t) $(scm_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(scm_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " + PS1="(\t) $(scm_char) [$blue\u$reset_color@$green\H$reset_color] $yellow\w${reset_color}$(scm_prompt_info)$(rvm_version_prompt) $reset_color " PS2='> ' PS4='+ ' } diff --git a/themes/rainbowbrite/rainbowbrite.theme.bash b/themes/rainbowbrite/rainbowbrite.theme.bash new file mode 100644 index 00000000..e4424bbe --- /dev/null +++ b/themes/rainbowbrite/rainbowbrite.theme.bash @@ -0,0 +1,29 @@ +#!/bin/bash + +# based off of n0qorg +# looks like, if you're in a git repo: +# ± ~/path/to (branch ✓) $ +# in glorious red / blue / yellow color scheme + +prompt_setter() { + # Save history + history -a + history -c + history -r + # displays user@server in purple + # PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(rvm_version_prompt) $black\$$reset_color " + # no user@server + PS1="$red$(scm_char) $blue\w$yellow$(scm_prompt_info)$(rvm_version_prompt) $black\$$reset_color " + PS2='> ' + PS4='+ ' +} + +PROMPT_COMMAND=prompt_setter + +SCM_NONE_CHAR='·' +SCM_THEME_PROMPT_DIRTY=" ${red}✗" +SCM_THEME_PROMPT_CLEAN=" ${green}✓" +SCM_THEME_PROMPT_PREFIX=" (" +SCM_THEME_PROMPT_SUFFIX="${yellow})" +RVM_THEME_PROMPT_PREFIX=" (" +RVM_THEME_PROMPT_SUFFIX=")" diff --git a/themes/sirup/sirup.theme.bash b/themes/sirup/sirup.theme.bash index 50665871..146cc356 100644 --- a/themes/sirup/sirup.theme.bash +++ b/themes/sirup/sirup.theme.bash @@ -13,6 +13,10 @@ function rvm_version_prompt { [ "$full" != "" ] && echo "$full" } + +function prompt_command() { + # Check http://github.com/Sirupsen/dotfiles for screenshot + PS1="$blue\W/$bold_blue$(rvm_version_prompt)$bold_green$(__git_ps1 " (%s)") ${normal}$ " +} -# Check http://github.com/Sirupsen/dotfiles for screenshot -PS1='\[$blue\]\W/\[$bold_blue\]$(rvm_version_prompt)\[$bold_green\]$(__git_ps1 " (%s)") \[${normal}\]$ ' +PROMPT_COMMAND=prompt_command; diff --git a/themes/standard/standard.theme.bash b/themes/standard/standard.theme.bash index 5ba288c1..87402c73 100644 --- a/themes/standard/standard.theme.bash +++ b/themes/standard/standard.theme.bash @@ -1,7 +1,3 @@ -PROMPT='\[${green}\]\u\[${normal}\]@\[${green}\]\h\[${normal}\]:\[${blue}\]\w\[${normal}\]\[${red}\]$(prompt_char)$(git_prompt_info)\[${normal}\]\$ ' - - - # scm themeing SCM_THEME_PROMPT_DIRTY="×" SCM_THEME_PROMPT_CLEAN="✓" @@ -19,4 +15,10 @@ case $TERM in *) TITLEBAR="" ;; -esac \ No newline at end of file +esac + +function prompt_command() { + PROMPT='${green}\u${normal}@${green}\h${normal}:${blue}\w${normal}${red}$(prompt_char)$(git_prompt_info)${normal}\$ ' +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/tonka/tonka.theme.bash b/themes/tonka/tonka.theme.bash new file mode 100644 index 00000000..2b28c968 --- /dev/null +++ b/themes/tonka/tonka.theme.bash @@ -0,0 +1,39 @@ +prompt_setter() { + +# Named "Tonka" because of the colour scheme +local WHITE="\[\033[1;37m\]" +local LIGHT_BLUE="\[\033[1;34m\]" +local YELLOW="\[\033[1;33m\]" +local NO_COLOUR="\[\033[0m\]" + +case $TERM in + xterm*|rxvt*) + TITLEBAR='\[\033]0;\u@\h:\w\007\]' + ;; + *) + TITLEBAR="" + ;; +esac + +PS1="$TITLEBAR\ +$YELLOW-$LIGHT_BLUE-(\ +$YELLOW\u$LIGHT_BLUE@$YELLOW\h\ +$LIGHT_BLUE)-(\ +$YELLOW\$PWD\ +$LIGHT_BLUE)-$YELLOW-\ +\n\ +$YELLOW-$LIGHT_BLUE-(\ +$YELLOW\$(date +%H%M)$LIGHT_BLUE:$YELLOW\$(date \"+%a,%d %b %y\")\ +$LIGHT_BLUE:$WHITE\\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR " + +PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR " + +} + +PROMPT_COMMAND=prompt_setter + +export PS3=">> " + +LS_COLORS='no=00:fi=00:di=00;33:ln=01;36:pi=40;34:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:'; + +export LS_COLORS 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; diff --git a/themes/zitron/zitron.theme.bash b/themes/zitron/zitron.theme.bash index c0726865..3ec4d97a 100644 --- a/themes/zitron/zitron.theme.bash +++ b/themes/zitron/zitron.theme.bash @@ -1,12 +1,6 @@ #!/bin/bash # zitron theme by Florian Baumann -## look-a-like -# user:host:pwd git-branch(*)$ -# for example: -# noqqe:deathstar:themes master*$ -PROMPT="${no_color}\u:\[\$(hostname)\]${normal}:${bold_yellow}\W/${normal} \[\$(git_prompt_info)\]${reset_color}$ " - ## git-theme # feel free to change git chars. GIT_THEME_PROMPT_DIRTY="${bold_yellow}*${normal}" @@ -18,3 +12,13 @@ GIT_THEME_PROMPT_SUFFIX="" # thanks a lot to http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" + +function prompt_command() { + ## look-a-like + # user:host:pwd git-branch(*)$ + # for example: + # noqqe:deathstar:themes master*$ + PS1="${no_color}\u:$(hostname)${normal}:${bold_yellow}\W/${normal} $(git_prompt_info)${reset_color}$ " +} + +PROMPT_COMMAND=prompt_command; diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash new file mode 100644 index 00000000..f541c0d9 --- /dev/null +++ b/themes/zork/zork.theme.bash @@ -0,0 +1,77 @@ +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}" +SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +SCM_GIT_CHAR="${bold_green}±${normal}" +SCM_SVN_CHAR="${bold_cyan}⑆${normal}" +SCM_HG_CHAR="${bold_red}☿${normal}" + +#Mysql Prompt +export MYSQL_PS1="(\u@\h) [\d]> " + +case $TERM in + xterm*) + TITLEBAR="\[\033]0;\w\007\]" + ;; + *) + TITLEBAR="" + ;; +esac + +PS3=">> " + +__my_rvm_ruby_version() { + local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') + [ "$gemset" != "" ] && gemset="@$gemset" + local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') + local full="$version$gemset" + [ "$full" != "" ] && echo "[$full]" +} + +is_vim_shell() { + if [ ! -z "$VIMRUNTIME" ] + then + echo "[${cyan}vim shell${normal}]" + fi +} + +modern_scm_prompt() { + CHAR=$(scm_char) + if [ $CHAR = $SCM_NONE_CHAR ] + then + return + else + echo "[$(scm_char)][$(scm_prompt_info)]" + fi +} + +prompt() { + + case $HOSTNAME in + "zork"* ) my_ps_host="${green}\h${normal}"; + ;; + "pandora") my_ps_host="${red}\h${normal}"; + ;; + esac + + my_ps_user="\[\033[01;32m\]\u\[\033[00m\]"; + my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; + my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; + + # nice prompt + case "`id -u`" in + 0) PS1="${TITLEBAR}┌─[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) +└─▪ " + ;; + *) PS1="${TITLEBAR}┌─[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell) +└─▪ " + ;; + esac +} + +PS2="└─▪ " + + + +PROMPT_COMMAND=prompt