Merge remote-tracking branch 'upstream/master'
commit
c089973595
|
|
@ -10,7 +10,7 @@ Includes autocompletion, themes, aliases, custom functions, a few stolen pieces
|
|||
|
||||
## Install
|
||||
|
||||
1. Check a clone of this repo: `git clone http://github.com/revans/bash-it.git ~/.bash_it`
|
||||
1. Check a clone of this repo: `git clone https://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.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ alias _="sudo"
|
|||
|
||||
if [ $(uname) = "Linux" ]
|
||||
then
|
||||
alias ls="ls --color=always"
|
||||
alias ls="ls --color=auto"
|
||||
fi
|
||||
which gshuf &> /dev/null
|
||||
if [ $? -eq 1 ]
|
||||
|
|
@ -40,7 +40,7 @@ alias piano='pianobar'
|
|||
|
||||
alias ..='cd ..' # Go up one directory
|
||||
alias ...='cd ../..' # Go up two directories
|
||||
alias ....='cd ../../..' # Go up two directories
|
||||
alias ....='cd ../../..' # Go up three directories
|
||||
alias -- -='cd -' # Go back
|
||||
|
||||
# Shell History
|
||||
|
|
|
|||
|
|
@ -5,18 +5,23 @@ about-alias 'common git abbreviations'
|
|||
alias gcl='git clone'
|
||||
alias ga='git add'
|
||||
alias gall='git add .'
|
||||
alias gus='git reset HEAD'
|
||||
alias gm="git merge"
|
||||
alias g='git'
|
||||
alias get='git'
|
||||
alias gst='git status'
|
||||
alias gs='git status'
|
||||
alias gss='git status -s'
|
||||
alias gl='git pull'
|
||||
alias gpr='git pull --rebase'
|
||||
alias gpp='git pull && git push'
|
||||
alias gup='git fetch && git rebase'
|
||||
alias gp='git push'
|
||||
alias gpo='git push origin'
|
||||
alias gdv='git diff -w "$@" | vim -R -'
|
||||
alias gc='git commit -v'
|
||||
alias gca='git commit -v -a'
|
||||
alias gcm='git commit -v -m'
|
||||
alias gci='git commit --interactive'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
|
|
@ -27,15 +32,23 @@ alias gexport='git archive --format zip --output'
|
|||
alias gdel='git branch -D'
|
||||
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
|
||||
alias gll='git log --graph --pretty=oneline --abbrev-commit'
|
||||
alias gg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
|
||||
alias ggs="gg --stat"
|
||||
alias gsl="git shortlog -sn"
|
||||
alias gw="git whatchanged"
|
||||
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
alias gd='git diff | vim -R -'
|
||||
;;
|
||||
darwin*)
|
||||
alias gd='git diff | mate'
|
||||
;;
|
||||
darwin*)
|
||||
alias gd='git diff'
|
||||
;;
|
||||
esac
|
||||
if [ -z "$EDITOR" ]; then
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
alias gd='git diff | vim -R -'
|
||||
;;
|
||||
darwin*)
|
||||
alias gd='git diff | mate'
|
||||
;;
|
||||
*)
|
||||
alias gd='git diff'
|
||||
;;
|
||||
esac
|
||||
else
|
||||
alias gd="git diff | $EDITOR"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
cite 'about-alias'
|
||||
about-alias 'common git-svn abbreviations'
|
||||
|
||||
# Aliases
|
||||
alias gsr='git svn rebase'
|
||||
alias gsc='git svn dcommit'
|
||||
alias gsi='git svn info'
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
cite 'about-alias'
|
||||
about-alias 'jitsu task abbreviations'
|
||||
|
||||
# jitsu
|
||||
alias j='jitsu'
|
||||
alias jl='jitsu login'
|
||||
alias jo='jitsu logout'
|
||||
|
||||
# deploy and update
|
||||
alias jd='jitsu apps deploy'
|
||||
alias ju='jitsu apps update'
|
||||
|
||||
# new and start, restart, stop
|
||||
alias jn='jitsu apps create'
|
||||
alias js='jitsu apps start'
|
||||
alias jr='jitsu apps restart'
|
||||
alias jx='jitsu apps stop'
|
||||
|
||||
# logs
|
||||
alias jll='jitsu logs'
|
||||
alias jlog='jitsu logs'
|
||||
alias jlogs='jitsu logs'
|
||||
|
||||
# env
|
||||
alias je='jitsu env'
|
||||
alias jel='jitsu env list'
|
||||
alias jes='jitsu env set'
|
||||
alias jeg='jitsu env get'
|
||||
alias jed='jitsu env delete'
|
||||
alias jec='jitsu env clear'
|
||||
alias jesv='jitsu env save'
|
||||
alias jeld='jitsu env load'
|
||||
|
||||
# configuration
|
||||
alias jc='jitsu conf'
|
||||
alias jcl='jitsu config list'
|
||||
alias jcs='jitsu config set'
|
||||
alias jcg='jitsu config get'
|
||||
alias jcd='jitsu config delete'
|
||||
|
||||
# list and install, view
|
||||
alias jls='jitsu list'
|
||||
alias jin='jitsu install'
|
||||
alias jv='jitsu apps view'
|
||||
|
||||
# Database, Snapshots and Tokens
|
||||
alias jdb='jitsu databases'
|
||||
alias jss='jitsu snapshots'
|
||||
alias jto='jitsu tokens'
|
||||
|
|
@ -5,7 +5,7 @@ about-alias 'osx-specific aliases'
|
|||
alias fireworks="open -a '/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app'"
|
||||
alias photoshop="open -a '/Applications/Adobe Photoshop CS3/Adobe Photoshop.app'"
|
||||
alias preview="open -a '$PREVIEW'"
|
||||
alias xcode="open -a '/Developer/Applications/Xcode.app'"
|
||||
alias xcode="open -a '/Applications/XCode.app'"
|
||||
alias filemerge="open -a '/Developer/Applications/Utilities/FileMerge.app'"
|
||||
alias safari="open -a safari"
|
||||
alias firefox="open -a firefox"
|
||||
|
|
@ -23,3 +23,12 @@ fi
|
|||
|
||||
# Requires growlnotify, which can be found in the Growl DMG under "Extras"
|
||||
alias grnot='growlnotify -s -t Terminal -m "Done"'
|
||||
|
||||
# Get rid of those pesky .DS_Store files recursively
|
||||
alias dsclean='find . -type f -name .DS_Store -print0 | xargs -0 rm'
|
||||
|
||||
# Track who is listening to your iTunes music
|
||||
alias whotunes='lsof -r 2 -n -P -F n -c iTunes -a -i TCP@`hostname`:3689'
|
||||
|
||||
# Flush your dns cache
|
||||
alias flush='dscacheutil -flushcache'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
cite 'about-alias'
|
||||
about-alias 'vagrant aliases'
|
||||
|
||||
# Aliases
|
||||
alias vup="vagrant up"
|
||||
alias vh="vagrant halt"
|
||||
alias vs="vagrant suspend"
|
||||
alias vr="vagrant resume"
|
||||
alias vrl="vagrant reload"
|
||||
alias vssh="vagrant ssh"
|
||||
alias vst="vagrant status"
|
||||
alias vp="vagrant provision"
|
||||
alias vdstr="vagrant destroy"
|
||||
# requires vagrant-list plugin
|
||||
alias vl="vagrant list"
|
||||
# requires vagrant-hostmanager plugin
|
||||
alias vhst="vagrant hostmanager"
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
# Bash completion support for Capistrano.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_capcomplete() {
|
||||
if [ -f Capfile ]; then
|
||||
recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1`
|
||||
if [[ $recent != '.cap_tasks~' ]]; then
|
||||
cap --tool --tasks | cut -d " " -f 2 > .cap_tasks~
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _capcomplete cap
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# bash completion support for Drush:
|
||||
# https://github.com/drush-ops/drush
|
||||
#
|
||||
# Originally from:
|
||||
# http://github.com/drush-ops/drush/blob/master/drush.complete.sh
|
||||
|
||||
# Ensure drush is available.
|
||||
which drush > /dev/null || alias drush &> /dev/null || return
|
||||
|
||||
__drush_ps1() {
|
||||
f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$"
|
||||
if [ -f $f ]
|
||||
then
|
||||
__DRUPAL_SITE=$(cat "$f")
|
||||
else
|
||||
__DRUPAL_SITE="$DRUPAL_SITE"
|
||||
fi
|
||||
|
||||
[[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
|
||||
}
|
||||
|
||||
# Completion function, uses the "drush complete" command to retrieve
|
||||
# completions for a specific command line COMP_WORDS.
|
||||
_drush_completion() {
|
||||
# Set IFS to newline (locally), since we only use newline separators, and
|
||||
# need to retain spaces (or not) after completions.
|
||||
local IFS=$'\n'
|
||||
# The '< /dev/null' is a work around for a bug in php libedit stdin handling.
|
||||
# Note that libedit in place of libreadline in some distributions. See:
|
||||
# https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
|
||||
COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
|
||||
}
|
||||
|
||||
# Register our completion function. We include common short aliases for Drush.
|
||||
complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
# grunt-cli
|
||||
# http://gruntjs.com/
|
||||
#
|
||||
# Copyright (c) 2012 Tyler Kellen, contributors
|
||||
# Licensed under the MIT license.
|
||||
# https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# To enable bash <tab> completion for grunt, add the following line (minus the
|
||||
# leading #, which is the bash comment character) to your ~/.bashrc file:
|
||||
#
|
||||
# eval "$(grunt --completion=bash)"
|
||||
|
||||
# Search the current directory and all parent directories for a gruntfile.
|
||||
function _grunt_gruntfile() {
|
||||
local curpath="$PWD"
|
||||
while [[ "$curpath" ]]; do
|
||||
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
|
||||
if [[ -e "$gruntfile" ]]; then
|
||||
echo "$gruntfile"
|
||||
return
|
||||
fi
|
||||
done
|
||||
curpath="${curpath%/*}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Enable bash autocompletion.
|
||||
function _grunt_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
# The current gruntfile, if it exists.
|
||||
local gruntfile="$(_grunt_gruntfile)"
|
||||
# The current grunt version, available tasks, options, etc.
|
||||
local gruntinfo="$(grunt --version --verbose 2>/dev/null)"
|
||||
# Options and tasks.
|
||||
local opts="$(echo "$gruntinfo" | awk '/Available options: / {$1=$2=""; print $0}')"
|
||||
local compls="$(echo "$gruntinfo" | awk '/Available tasks: / {$1=$2=""; print $0}')"
|
||||
# Only add -- or - options if the user has started typing -
|
||||
[[ "$cur" == -* ]] && compls="$compls $opts"
|
||||
# Tell complete what stuff to show.
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
|
||||
complete -o default -F _grunt_completions grunt
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
# pip bash completion start
|
||||
_pip_completion()
|
||||
{
|
||||
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
|
||||
COMP_CWORD=$COMP_CWORD \
|
||||
PIP_AUTO_COMPLETE=1 $1 ) )
|
||||
}
|
||||
complete -o default -F _pip_completion pip
|
||||
# pip bash completion end
|
||||
|
||||
|
|
@ -4,20 +4,33 @@
|
|||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_sshcomplete() {
|
||||
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ ${CURRENT_PROMPT} == *@* ]] ; then
|
||||
local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}"
|
||||
else
|
||||
local OPTIONS=" -- ${CURRENT_PROMPT}"
|
||||
fi
|
||||
|
||||
|
||||
# parse all defined hosts from .ssh/config
|
||||
if [ -r $HOME/.ssh/config ]; then
|
||||
COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" ${OPTIONS}) )
|
||||
fi
|
||||
|
||||
# parse all hosts found in .ssh/known_hosts
|
||||
if [ -r $HOME/.ssh/known_hosts ]; then
|
||||
if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" -- ${COMP_WORDS[COMP_CWORD]} ))
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) )
|
||||
fi
|
||||
fi
|
||||
|
||||
# parse hosts defined in /etc/hosts
|
||||
if [ -r /etc/hosts ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{print $2}' )" ${OPTIONS}) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _sshcomplete ssh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#!/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"
|
||||
test -w $HOME/.bash_profile &&
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -277,6 +277,8 @@ _enable-thing ()
|
|||
return
|
||||
fi
|
||||
|
||||
mkdir -p $BASH_IT/$subdirectory/enabled
|
||||
|
||||
ln -s $BASH_IT/$subdirectory/available/$plugin $BASH_IT/$subdirectory/enabled/$plugin
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -175,6 +175,33 @@ command_exists ()
|
|||
type "$1" &> /dev/null ;
|
||||
}
|
||||
|
||||
mkiso ()
|
||||
{
|
||||
|
||||
about 'creates iso from current dir in the parent dir (unless defined)'
|
||||
param '1: ISO name'
|
||||
param '2: dest/path'
|
||||
param '3: src/path'
|
||||
example 'mkiso'
|
||||
example 'mkiso ISO-Name dest/path src/path'
|
||||
group 'base'
|
||||
|
||||
if type "mkisofs" > /dev/null; then
|
||||
[ -z ${1+x} ] && local isoname=${PWD##*/} || local isoname=$1
|
||||
[ -z ${2+x} ] && local destpath=../ || local destpath=$2
|
||||
[ -z ${3+x} ] && local srcpath=${PWD} || local srcpath=$3
|
||||
|
||||
if [ ! -f "${destpath}${isoname}.iso" ]; then
|
||||
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
|
||||
mkisofs -V ${isoname} -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}"
|
||||
else
|
||||
echo "${destpath}${isoname}.iso already exists"
|
||||
fi
|
||||
else
|
||||
echo "mkisofs cmd does not exist, please install cdrtools"
|
||||
fi
|
||||
}
|
||||
|
||||
# useful for administrators and configs
|
||||
buf ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
cite about-plugin
|
||||
about-plugin 'load chruby + auto-switching (from /usr/local/share/chruby)'
|
||||
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
source /usr/local/share/chruby/auto.sh
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
cite about-plugin
|
||||
about-plugin 'load chruby (from /usr/local/share/chruby)'
|
||||
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
|
|
@ -17,6 +17,92 @@ function git_first_push {
|
|||
git push origin master:refs/heads/master
|
||||
}
|
||||
|
||||
function git_pub() {
|
||||
about 'publishes current branch to remote origin'
|
||||
group 'git'
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
echo "Publishing ${BRANCH} to remote origin"
|
||||
git push -u origin $BRANCH
|
||||
}
|
||||
|
||||
function git_revert() {
|
||||
about 'applies changes to HEAD that revert all changes after this commit'
|
||||
group 'git'
|
||||
|
||||
git reset $1
|
||||
git reset --soft HEAD@{1}
|
||||
git commit -m "Revert to ${1}"
|
||||
git reset --hard
|
||||
}
|
||||
|
||||
function git_rollback() {
|
||||
about 'resets the current HEAD to this commit'
|
||||
group 'git'
|
||||
|
||||
function is_clean() {
|
||||
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
|
||||
echo "Your branch is dirty, please commit your changes"
|
||||
kill -INT $$
|
||||
fi
|
||||
}
|
||||
|
||||
function commit_exists() {
|
||||
git rev-list --quiet $1
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "Commit ${1} does not exist"
|
||||
kill -INT $$
|
||||
fi
|
||||
}
|
||||
|
||||
function keep_changes() {
|
||||
while true
|
||||
do
|
||||
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
|
||||
case $RESP
|
||||
in
|
||||
[yY])
|
||||
echo "Rolling back to commit ${1} with unstaged changes"
|
||||
git reset $1
|
||||
break
|
||||
;;
|
||||
[nN])
|
||||
echo "Rolling back to commit ${1} with a clean working tree"
|
||||
git reset --hard $1
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Please enter Y or N"
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||
is_clean
|
||||
commit_exists $1
|
||||
|
||||
while true
|
||||
do
|
||||
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
|
||||
case $RESP
|
||||
in
|
||||
[yY])
|
||||
keep_changes $1
|
||||
break
|
||||
;;
|
||||
[nN])
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Please enter Y or N"
|
||||
esac
|
||||
done
|
||||
else
|
||||
echo "you're currently not in a git repository"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_remove_missing_files() {
|
||||
about "git rm's missing files"
|
||||
group 'git'
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function tab() {
|
|||
end
|
||||
tell application "Terminal"
|
||||
activate
|
||||
do script with command "cd \"$PWD\"; $*" in window 1
|
||||
do script with command " cd \"$PWD\"; $*" in window 1
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function mkvenv {
|
|||
group 'virtualenv'
|
||||
|
||||
cwd=`basename \`pwd\``
|
||||
mkvirtualenv --no-site-packages --distribute $cwd
|
||||
mkvirtualenv --distribute $cwd
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -19,12 +19,19 @@ function mkvbranch {
|
|||
about 'create a new virtualenv for the current branch'
|
||||
group 'virtualenv'
|
||||
|
||||
mkvirtualenv --no-site-packages --distribute "$(basename `pwd`)@$(git_prompt_info)"
|
||||
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH"
|
||||
}
|
||||
|
||||
function wovbranch {
|
||||
about 'sets workon branch'
|
||||
group 'virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)@$(git_prompt_info)"
|
||||
workon "$(basename `pwd`)@$SCM_BRANCH"
|
||||
}
|
||||
|
||||
function wovenv {
|
||||
about 'works on the virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
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}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
|
||||
#PS1="\n${purple}\h: ${reset_color} ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
#PS1="\n${cyan}\h: ${reset_color} ${yellow}\w\n${red}$(scm_char)${red}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
PS1="\n${cyan}\h: ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}→ "
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=prompt_command;
|
||||
|
|
@ -70,18 +70,28 @@ function scm_prompt_info {
|
|||
}
|
||||
|
||||
function git_prompt_vars {
|
||||
if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
|
||||
SCM_GIT_AHEAD=''
|
||||
SCM_GIT_BEHIND=''
|
||||
SCM_GIT_STASH=''
|
||||
local status="$(git status -bs --porcelain 2> /dev/null)"
|
||||
if [[ -n "$(grep -v ^# <<< "${status}")" ]]; then
|
||||
SCM_DIRTY=1
|
||||
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
||||
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
||||
else
|
||||
SCM_DIRTY=0
|
||||
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
||||
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
||||
fi
|
||||
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)
|
||||
local ahead_re='.+ahead ([0-9]+).+'
|
||||
local behind_re='.+behind ([0-9]+).+'
|
||||
[[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
|
||||
[[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
|
||||
local stash_count="$(git stash list | wc -l | tr -d ' ')"
|
||||
[[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}"
|
||||
}
|
||||
|
||||
function svn_prompt_vars {
|
||||
|
|
@ -108,8 +118,8 @@ function hg_prompt_vars {
|
|||
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}')
|
||||
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 rvm_version_prompt {
|
||||
|
|
@ -122,6 +132,7 @@ function rvm_version_prompt {
|
|||
function rbenv_version_prompt {
|
||||
if which rbenv &> /dev/null; then
|
||||
rbenv=$(rbenv version-name) || return
|
||||
$(rbenv commands | grep -q gemset) && gemset=$(rbenv gemset active) && rbenv="$rbenv@${gemset%% *}"
|
||||
echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
|
@ -132,13 +143,23 @@ function rbfu_version_prompt {
|
|||
fi
|
||||
}
|
||||
|
||||
function chruby_version_prompt {
|
||||
if declare -f -F chruby &> /dev/null; then
|
||||
if declare -f -F chruby_auto &> /dev/null; then
|
||||
chruby_auto
|
||||
fi
|
||||
chruby=$(ruby --version | awk '{print $1, $2;}') || return
|
||||
echo -e "$CHRUBY_THEME_PROMPT_PREFIX$chruby$CHRUBY_THEME_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
||||
function ruby_version_prompt {
|
||||
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)"
|
||||
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
|
||||
}
|
||||
|
||||
function virtualenv_prompt {
|
||||
if which virtualenv &> /dev/null; then
|
||||
virtualenv=$([ ! -z "$VIRTUAL_ENV" ] && echo "`basename $VIRTUAL_ENV`") || return
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
virtualenv=`basename "$VIRTUAL_ENV"`
|
||||
echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Two line prompt showing the following information:
|
||||
# (time) SCM [username@hostname] pwd (SCM branch SCM status)
|
||||
# →
|
||||
#
|
||||
# Example:
|
||||
# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓)
|
||||
# →
|
||||
#
|
||||
# The arrow on the second line is showing the exit status of the last command:
|
||||
# * Green: 0 exit status
|
||||
# * Red: non-zero exit status
|
||||
#
|
||||
# The exit code functionality currently doesn't work if you are using the 'fasd' plugin,
|
||||
# since 'fasd' is messing with the $PROMPT_COMMAND
|
||||
|
||||
|
||||
PROMPT_END_CLEAN="${green}→${reset_color}"
|
||||
PROMPT_END_DIRTY="${red}→${reset_color}"
|
||||
|
||||
function prompt_end() {
|
||||
echo -e "$PROMPT_END"
|
||||
}
|
||||
|
||||
prompt_setter() {
|
||||
local exit_status=$?
|
||||
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
|
||||
else PROMPT_END=$PROMPT_END_DIRTY
|
||||
fi
|
||||
# Save history
|
||||
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) ${reset_color}\n$(prompt_end) "
|
||||
PS2='> '
|
||||
PS4='+ '
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=prompt_setter
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
||||
SCM_THEME_PROMPT_PREFIX=" ("
|
||||
SCM_THEME_PROMPT_SUFFIX=")"
|
||||
RVM_THEME_PROMPT_PREFIX=" ("
|
||||
RVM_THEME_PROMPT_SUFFIX=")"
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SHELL_SSH_CHAR="⌁ "
|
||||
SHELL_THEME_PROMPT_COLOR=32
|
||||
SHELL_SSH_THEME_PROMPT_COLOR=208
|
||||
|
||||
VIRTUALENV_CHAR="ⓔ "
|
||||
VIRTUALENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR="⎇ "
|
||||
SCM_GIT_BEHIND_CHAR="↓"
|
||||
SCM_GIT_AHEAD_CHAR="↑"
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_COLOR=238
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=231
|
||||
SCM_THEME_PROMPT_DIRTY_COLOR=220
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=52
|
||||
|
||||
function set_rgb_color {
|
||||
if [[ "${1}" != "-" ]]; then
|
||||
fg="38;5;${1}"
|
||||
fi
|
||||
if [[ "${2}" != "-" ]]; then
|
||||
bg="48;5;${2}"
|
||||
[[ -n "${fg}" ]] && bg=";${bg}"
|
||||
fi
|
||||
echo -e "\[\033[${fg}${bg}m\]"
|
||||
}
|
||||
|
||||
function powerline_shell_prompt {
|
||||
if [[ -n "${SSH_CLIENT}" ]]; then
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
|
||||
else
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) \u ${normal}"
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_virtualenv_prompt {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
virtualenv=$(basename "$VIRTUAL_ENV")
|
||||
VIRTUALENV_PROMPT="$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$virtualenv ${normal}"
|
||||
else
|
||||
VIRTUALENV_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_scm_prompt {
|
||||
scm_prompt_vars
|
||||
|
||||
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
|
||||
if [[ "${SCM_DIRTY}" -eq 1 ]]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
else
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
fi
|
||||
[[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] && SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}${SCM_GIT_BEHIND}${SCM_GIT_AHEAD}${SCM_GIT_STASH}"
|
||||
SCM_PROMPT="${SCM_PROMPT} ${normal}"
|
||||
else
|
||||
SCM_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_cwd_prompt {
|
||||
CWD_PROMPT="${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
|
||||
}
|
||||
|
||||
function powerline_last_status_prompt {
|
||||
if [[ "$1" -eq 0 ]]; then
|
||||
LAST_STATUS_PROMPT=""
|
||||
else
|
||||
LAST_STATUS_PROMPT="$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_prompt_command() {
|
||||
local LAST_STATUS="$?"
|
||||
|
||||
powerline_shell_prompt
|
||||
powerline_virtualenv_prompt
|
||||
powerline_scm_prompt
|
||||
powerline_cwd_prompt
|
||||
powerline_last_status_prompt LAST_STATUS
|
||||
|
||||
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=powerline_prompt_command
|
||||
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
THEME_PROMPT_SEPARATOR=""
|
||||
|
||||
SHELL_SSH_CHAR=" "
|
||||
SHELL_THEME_PROMPT_COLOR=32
|
||||
SHELL_SSH_THEME_PROMPT_COLOR=208
|
||||
|
||||
VIRTUALENV_CHAR="ⓔ "
|
||||
VIRTUALENV_THEME_PROMPT_COLOR=35
|
||||
|
||||
SCM_NONE_CHAR=""
|
||||
SCM_GIT_CHAR=" "
|
||||
SCM_GIT_BEHIND_CHAR="↓"
|
||||
SCM_GIT_AHEAD_CHAR="↑"
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_DIRTY=""
|
||||
SCM_THEME_PROMPT_COLOR=238
|
||||
SCM_THEME_PROMPT_CLEAN_COLOR=231
|
||||
SCM_THEME_PROMPT_DIRTY_COLOR=196
|
||||
SCM_THEME_PROMPT_STAGED_COLOR=220
|
||||
SCM_THEME_PROMPT_UNTRACKED_COLOR=033
|
||||
|
||||
CWD_THEME_PROMPT_COLOR=240
|
||||
|
||||
LAST_STATUS_THEME_PROMPT_COLOR=52
|
||||
|
||||
function set_rgb_color {
|
||||
if [[ "${1}" != "-" ]]; then
|
||||
fg="38;5;${1}"
|
||||
fi
|
||||
if [[ "${2}" != "-" ]]; then
|
||||
bg="48;5;${2}"
|
||||
[[ -n "${fg}" ]] && bg=";${bg}"
|
||||
fi
|
||||
echo -e "\[\033[${fg}${bg}m\]"
|
||||
}
|
||||
|
||||
function powerline_shell_prompt {
|
||||
if [[ -n "${SSH_CLIENT}" ]]; then
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
|
||||
LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR}
|
||||
else
|
||||
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) \u ${normal}"
|
||||
LAST_THEME_COLOR=${SHELL_THEME_PROMPT_COLOR}
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_virtualenv_prompt {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
virtualenv=$(basename "$VIRTUAL_ENV")
|
||||
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$virtualenv ${normal}"
|
||||
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
|
||||
else
|
||||
VIRTUALENV_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_scm_prompt {
|
||||
scm_prompt_vars
|
||||
local git_status_output
|
||||
git_status_output=$(git status 2> /dev/null )
|
||||
|
||||
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
|
||||
if [[ "${SCM_DIRTY}" -eq 1 ]]; then
|
||||
if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
elif [ -n "$(echo $git_status_output | grep 'Untracked files')" ]; then
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNTRACKED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
else
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
fi
|
||||
else
|
||||
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
|
||||
fi
|
||||
[[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] && SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}${SCM_GIT_BEHIND}${SCM_GIT_AHEAD}${SCM_GIT_STASH}"
|
||||
SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}"
|
||||
LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR}
|
||||
else
|
||||
SCM_PROMPT=""
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_cwd_prompt {
|
||||
CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${CWD_THEME_PROMPT_COLOR}) \w ${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
|
||||
LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR}
|
||||
}
|
||||
|
||||
function powerline_last_status_prompt {
|
||||
if [[ "$1" -eq 0 ]]; then
|
||||
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
|
||||
else
|
||||
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
|
||||
fi
|
||||
}
|
||||
|
||||
function powerline_prompt_command() {
|
||||
local LAST_STATUS="$?"
|
||||
|
||||
powerline_shell_prompt
|
||||
powerline_virtualenv_prompt
|
||||
powerline_scm_prompt
|
||||
powerline_cwd_prompt
|
||||
powerline_last_status_prompt LAST_STATUS
|
||||
|
||||
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=powerline_prompt_command
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# scm theming
|
||||
SCM_THEME_PROMPT_PREFIX="|"
|
||||
SCM_THEME_PROMPT_SUFFIX=""
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${green}✓${normal}"
|
||||
SCM_GIT_CHAR="${green}±${normal}"
|
||||
SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
|
||||
SCM_HG_CHAR="${bold_red}☿${normal}"
|
||||
|
||||
### TODO: openSUSE has already colors enabled, check if those differs from stock
|
||||
# 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:'
|
||||
|
||||
scm_prompt() {
|
||||
CHAR=$(scm_char)
|
||||
if [ $CHAR = $SCM_NONE_CHAR ]
|
||||
then
|
||||
return
|
||||
else
|
||||
echo "[$(scm_char)$(scm_prompt_info)]"
|
||||
fi
|
||||
}
|
||||
|
||||
pure_prompt() {
|
||||
ps_host="${bold_blue}\h${normal}";
|
||||
ps_user="${green}\u${normal}";
|
||||
ps_user_mark="${green} $ ${normal}";
|
||||
ps_root="${red}\u${red}";
|
||||
ps_root="${red} # ${normal}"
|
||||
ps_path="${yellow}\w${normal}";
|
||||
|
||||
# make it work
|
||||
case $(id -u) in
|
||||
0) PS1="$ps_root@$ps_host$(scm_prompt):$ps_path$ps_root_mark"
|
||||
;;
|
||||
*) PS1="$ps_user@$ps_host$(scm_prompt):$ps_path$ps_user_mark"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=pure_prompt;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
|
||||
# Screenshot: http://cloud.gf3.ca/M5rG
|
||||
# A big thanks to \amethyst on Freenode
|
||||
|
||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
|
||||
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
|
||||
fi
|
||||
|
||||
if tput setaf 1 &> /dev/null; then
|
||||
tput sgr0
|
||||
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
|
||||
MAGENTA=$(tput setaf 9)
|
||||
ORANGE=$(tput setaf 172)
|
||||
GREEN=$(tput setaf 190)
|
||||
PURPLE=$(tput setaf 141)
|
||||
WHITE=$(tput setaf 0)
|
||||
else
|
||||
MAGENTA=$(tput setaf 5)
|
||||
ORANGE=$(tput setaf 4)
|
||||
GREEN=$(tput setaf 2)
|
||||
PURPLE=$(tput setaf 1)
|
||||
WHITE=$(tput setaf 7)
|
||||
fi
|
||||
BOLD=$(tput bold)
|
||||
RESET=$(tput sgr0)
|
||||
else
|
||||
MAGENTA="\033[1;31m"
|
||||
ORANGE="\033[1;33m"
|
||||
GREEN="\033[1;32m"
|
||||
PURPLE="\033[1;35m"
|
||||
WHITE="\033[1;37m"
|
||||
BOLD=""
|
||||
RESET="\033[m"
|
||||
fi
|
||||
|
||||
parse_git_dirty () {
|
||||
[[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*"
|
||||
}
|
||||
parse_git_branch () {
|
||||
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
|
||||
}
|
||||
|
||||
function prompt_command() {
|
||||
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
|
||||
}
|
||||
|
||||
PROMPT_COMMAND=prompt_command
|
||||
Loading…
Reference in New Issue