Merge branch 'master' of git://github.com/revans/bash-it

pull/28/head
Florian Baumann 2010-11-22 11:42:02 +01:00
commit 27ea8b29c1
15 changed files with 271 additions and 57 deletions

View File

@ -1,27 +1,27 @@
# Open the root of your site in your vim or cd to it # Open the root of your site in your vim or builtin cd to it
if [[ $EDITOR = "vim" ]] if [[ $EDITOR = "vim" ]]
then alias newentry="cd $JEKYLL_LOCAL_ROOT && $EDITOR ." then alias newentry="builtin cd $JEKYLL_LOCAL_ROOT && $EDITOR ."
else alias newentry="cd $JEKYLL_LOCAL_ROOT" else alias newentry="builtin cd $JEKYLL_LOCAL_ROOT"
fi fi
# Open the _posts/ directory for making a new blog post (seperate from above alias because not everyone uses jekyll for a blog) # Open the _posts/ directory for making a new blog post (seperate from above alias because not everyone uses jekyll for a blog)
# if [ $editor = "vim" ] # if [ $editor = "vim" ]
# then # then
# alias newpost="cd $jekyll_local_root/_posts && $editor ." # alias newpost="builtin cd $jekyll_local_root/_posts && $editor ."
# else # else
# alias newpost="cd $jekyll_local_root" # alias newpost="builtin cd $jekyll_local_root"
# fi # fi
# Build and locally serve the site # Build and locally serve the site
alias testsite="cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto" alias testsite="builtin cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto"
# Build but don't locally serve the site # Build but don't locally serve the site
alias buildsite="cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll" alias buildsite="builtin cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll"
# Rsync the site to the remote server # Rsync the site to the remote server
alias deploysite="cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT" alias deploysite="builtin cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT"

View File

@ -6,12 +6,9 @@ alias reload='source ~/.bash_profile'
# Load the framework # Load the framework
# Themes # Load colors first so they can be use in base theme
THEMES="${BASH}/themes/*.bash" source "${BASH}/themes/colors.theme.bash"
for config_file in $THEMES source "${BASH}/themes/base.theme.bash"
do
source $config_file
done
# Library # Library
LIB="${BASH}/lib/*.bash" LIB="${BASH}/lib/*.bash"

View File

@ -1,4 +1,4 @@
if [ `which brew` ]; then if which brew >/dev/null 2>&1; then
if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then if [ -f `brew --prefix`/Library/Contributions/brew_bash_completion.sh ]; then
. `brew --prefix`/Library/Contributions/brew_bash_completion.sh . `brew --prefix`/Library/Contributions/brew_bash_completion.sh
fi fi

View File

@ -30,6 +30,10 @@ pri() {
ri -T "${1}" | open -f -a $PREVIEW ri -T "${1}" | open -f -a $PREVIEW
} }
quiet() {
$* &> /dev/null &
}
banish-cookies() { banish-cookies() {
rm -r ~/.macromedia ~/.adobe rm -r ~/.macromedia ~/.adobe
ln -s /dev/null ~/.adobe ln -s /dev/null ~/.adobe

View File

@ -1,13 +1,55 @@
#!/bin/bash
newpost() { newpost() {
# 'cd' into the local jekyll root # 'builtin cd' into the local jekyll root
cd "$JEKYLL_LOCAL_ROOT/_posts" builtin cd "$JEKYLL_LOCAL_ROOT/_posts"
# Get the date for the new post's filename # Get the date for the new post's filename
FNAME_DATE=$(date "+%Y-%m-%d") FNAME_DATE=$(date "+%Y-%m-%d")
# If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr.
OPTIONS="Text Quote Image Audio Video"
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
done
fi
# Get the title for the new post # Get the title for the new post
read -p "Enter title of the new post: " POST_TITLE read -p "Enter title of the new post: " POST_TITLE
@ -50,6 +92,68 @@ newpost() {
echo "---" >> $FNAME echo "---" >> $FNAME
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 "<html><audio src=\"/path/to/audio/file\" controls=\"controls\"></audio></html>" >> $FNAME
fi
if [[ $POST_TYPE = "Video" ]]
then
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $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 "&mdash; Author" >> $FNAME
fi
if [[ $POST_TYPE = "Image" ]]
then
echo "!url(alt text)" >> $FNAME
fi
if [[ $POST_TYPE = "Audio" ]]
then
echo "<html><audio src=\"/path/to/audio/file\" controls=\"controls\"></audio></html>" >> $FNAME
fi
if [[ $POST_TYPE = "Video" ]]
then
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $FNAME
fi
fi
# Open the file in your favorite editor # Open the file in your favorite editor
$EDITOR $FNAME $EDITOR $FNAME

View File

@ -0,0 +1,50 @@
#!/bin/bash
_vagrant()
{
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version"
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0
fi
if [ $COMP_CWORD == 2 ]
then
case "$prev" in
"box")
box_commands="add help list remove repackage"
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
return 0
;;
"help")
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0
;;
*)
;;
esac
fi
if [ $COMP_CWORD == 3 ]
then
action="${COMP_WORDS[COMP_CWORD-2]}"
if [ $action == 'box' ]
then
case "$prev" in
"remove"|"repackage")
local box_list=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ')
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
return 0
;;
*)
;;
esac
fi
fi
}
complete -F _vagrant vagrant

View File

@ -1,27 +1,82 @@
#!/bin/bash #!/bin/bash
# Stolen from Steve Losh SCM_THEME_PROMPT_DIRTY=' ✗'
function prompt_char { SCM_THEME_PROMPT_CLEAN=' ✓'
git branch >/dev/null 2>/dev/null && echo -e '±' && return SCM_THEME_PROMPT_PREFIX=' |'
hg root >/dev/null 2>/dev/null && echo -e '☿' && return SCM_THEME_PROMPT_SUFFIX='|'
echo -e '○'
}
function parse_git_dirty { GIT='git'
if [[ -n $(git status -s 2> /dev/null) ]]; then SCM_GIT_CHAR='±'
echo -e "$GIT_THEME_PROMPT_DIRTY"
else HG='hg'
echo -e "$GIT_THEME_PROMPT_CLEAN" SCM_HG_CHAR='☿'
SVN='svn'
SCM_SVN_CHAR='⑆'
SCM_NONE_CHAR='○'
RVM_THEME_PROMPT_PREFIX=' |'
RVM_THEME_PROMPT_SUFFIX='|'
function scm {
if [[ -d .git ]]; then SCM=$GIT
elif [[ -d .hg ]]; then SCM=$HG
elif [[ -d .svn ]]; then SCM=$SVN
else SCM='NONE'
fi fi
} }
function git_prompt_info() { function scm_char {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return if [[ -z $SCM ]]; then scm; fi
echo -e "$GIT_THEME_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$GIT_THEME_PROMPT_SUFFIX" [[ $SCM == $GIT ]] && echo $SCM_GIT_CHAR && return
[[ $SCM == $HG ]] && echo $SCM_HG_CHAR && return
[[ $SCM == $SVN ]] && echo $SCM_SVN_CHAR && return
echo $SCM_NONE_CHAR
} }
function scm_prompt_info {
if [[ -z $SCM ]]; then scm; fi
[[ $SCM == $GIT ]] && git_prompt_info && return
[[ $SCM == $HG ]] && hg_prompt_info && return
[[ $SCM == $SVN ]] && svn_prompt_info && return
}
function rvm_version_prompt() { # Stolen from Steve Losh
# left in for backwards-compatibility
function prompt_char {
char=$(scm_char);
echo -e "$char"
}
function git_prompt_info {
if [[ -n $(git status -s 2> /dev/null) ]]; then
state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo -e "$prefix${ref#refs/heads/}$state$suffix"
}
function svn_prompt_info {
if [[ -n $(svn status 2> /dev/null) ]]; then
state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return
[[ -z $ref ]] && return
echo -e "$prefix$ref$state$suffix"
}
function rvm_version_prompt {
if which rvm &> /dev/null; then if which rvm &> /dev/null; then
rvm=$(rvm tools identifier) || return rvm=$(rvm tools identifier) || return
echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX" echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX"

View File

@ -1,6 +1,12 @@
#!/bin/bash #!/bin/bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |"
SCM_THEME_PROMPT_SUFFIX="${green}|"
PROMPT="\[${bold_blue}\]\[\$(scm_char)\]\[${green}\]\[\$(scm_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt)\] \[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[\n\[${green}\]→\[${reset_color}\] "
PROMPT="\[${bold_blue}\]\[\$(prompt_char)\]\[\$(git_prompt_info)\]\[${blue}\]\[\$(rvm_version_prompt) \]\[${orange}\]\h \[${reset_color}\]in \[${green}\]\w \[${reset_color}\]\[→ "
# git theming # git theming
GIT_THEME_PROMPT_DIRTY=" ${red}" GIT_THEME_PROMPT_DIRTY=" ${red}"
@ -10,3 +16,4 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"
RVM_THEME_PROMPT_PREFIX=" |" RVM_THEME_PROMPT_PREFIX=" |"
RVM_THEME_PROMPT_SUFFIX="|" RVM_THEME_PROMPT_SUFFIX="|"

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(git_prompt_info)\]${blue}${bold_blue} \$${reset_color} " PROMPT="${green}\u@\h ${blue}\T ${reset_color}${white}\w${reset_color}\[\$(scm_prompt_info)\]${blue}${bold_blue} \$${reset_color} "

View File

@ -1,6 +1,6 @@
if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi
PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(git_prompt_info)\]$ " PROMPT="${no_color}\u${reset_color}:${blue}\W/${reset_color} \[\$(scm_prompt_info)\]$ "
RPROMPT='[\t]' RPROMPT='[\t]'

View File

@ -7,3 +7,5 @@ prompt_setter() {
} }
PROMPT_COMMAND=prompt_setter PROMPT_COMMAND=prompt_setter
export PS3=">> "

View File

@ -5,16 +5,16 @@ prompt_setter() {
history -a history -a
history -c history -c
history -r history -r
PS1="(\t) $(prompt_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(git_prompt_info)$(rvm_version_prompt) $\[$reset_color\] " PS1="(\t) $(scm_char) [\[$blue\]\u\[$reset_color\]@\[$green\]\H\[$reset_color\]] \[$yellow\]\w\[$reset_color\]$(scm_prompt_info)$(rvm_version_prompt) $\[$reset_color\] "
PS2='> ' PS2='> '
PS4='+ ' PS4='+ '
} }
PROMPT_COMMAND=prompt_setter PROMPT_COMMAND=prompt_setter
GIT_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_DIRTY=" ✗"
GIT_THEME_PROMPT_CLEAN=" ✓" SCM_THEME_PROMPT_CLEAN=" ✓"
GIT_THEME_PROMPT_PREFIX=" (" SCM_THEME_PROMPT_PREFIX=" ("
GIT_THEME_PROMPT_SUFFIX=")" SCM_THEME_PROMPT_SUFFIX=")"
RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_PREFIX=" ("
RVM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_SUFFIX=")"

View File

@ -11,16 +11,11 @@ case $TERM in
TITLEBAR="" TITLEBAR=""
;; ;;
esac esac
PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(git_prompt_info)\]${reset_color} " PROMPT="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${reset_color} "
# git themeing # scm themeing
# GIT_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_DIRTY=" ✗"
# GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_CLEAN=" ✓"
# GIT_THEME_PROMPT_PREFIX=" ${green}|" SCM_THEME_PROMPT_PREFIX="("
# GIT_THEME_PROMPT_SUFFIX="${green}|" SCM_THEME_PROMPT_SUFFIX=")"
GIT_THEME_PROMPT_DIRTY=" ✗"
GIT_THEME_PROMPT_CLEAN=" ✓"
GIT_THEME_PROMPT_PREFIX="("
GIT_THEME_PROMPT_SUFFIX=")"

View File

@ -2,11 +2,11 @@ PROMPT='\[${green}\]\u\[${normal}\]@\[${green}\]\h\[${normal}\]:\[${blue}\]\w\[$
# git themeing # scm themeing
GIT_THEME_PROMPT_DIRTY="×" SCM_THEME_PROMPT_DIRTY="×"
GIT_THEME_PROMPT_CLEAN="✓" SCM_THEME_PROMPT_CLEAN="✓"
GIT_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_SUFFIX=""
# TODO: need a check for OS before adding this to the prompt # TODO: need a check for OS before adding this to the prompt
# ${debian_chroot:+($debian_chroot)} # ${debian_chroot:+($debian_chroot)}

View File

@ -17,4 +17,4 @@ GIT_THEME_PROMPT_SUFFIX=""
## ls colors ## ls colors
# thanks a lot to http://geoff.greer.fm/lscolors/ # thanks a lot to http://geoff.greer.fm/lscolors/
export LSCOLORS="Gxfxcxdxbxegedabagacad" export LSCOLORS="Gxfxcxdxbxegedabagacad"
export LS_COLORS="no=00:fi=00:di=01;97:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"