From 3bad87fac8ecac2f3dac0ba5ab4531d76ed09c59 Mon Sep 17 00:00:00 2001 From: Bodaniel Jeanes Date: Sun, 27 Jun 2010 01:12:01 +1000 Subject: [PATCH] A lot more refactoring including ZSH prompt improvements and making the `m` function more intelligent --- README | 7 ++++++- bash/aliases | 23 +++++++++++++++-------- bash/bashrc | 8 ++++++-- bash/common | 5 +++++ bash/exports | 2 +- misc/inputrc | 8 +++++--- zsh/config | 1 + zsh/oh-my-zsh | 8 ++------ zsh/theme | 19 +++++++++++++++---- zsh/zshrc | 10 ++++++++-- 10 files changed, 64 insertions(+), 27 deletions(-) diff --git a/README b/README index 488ce69..c2028ea 100755 --- a/README +++ b/README @@ -1,4 +1,9 @@ -Copyright (c) 2008-2009 Bodaniel Jeanes +# TODO + +* Make ZSH/Bash PATH dynamically figured out (via globbing) like fish + + +Copyright (c) 2008-2010 Bodaniel Jeanes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/bash/aliases b/bash/aliases index 1ef735d..03e8ec7 100644 --- a/bash/aliases +++ b/bash/aliases @@ -1,4 +1,4 @@ -alias gem='sudo gem' # sick of always forgetting sudo +alias gi='sudo gem install' alias ls='ls -FG' alias ll='ls -lah' alias ..='cd ..;' # can then do .. .. .. to move up multiple directories. @@ -7,10 +7,11 @@ alias g='grep -i' #case insensitive grep alias h='history|g' alias ducks='du -cks * | sort -rn|head -11' # Lists the size of all the folders alias top='top -o cpu' -alias m='mate .' alias o='open .' alias et="m" +alias sprof="reload" + alias home='cd ~' # the tilda is too hard to reach alias systail='tail -f -n0 /var/log/system.log' alias aptail='tail -f -n0 /var/log/apache*/*log' @@ -19,8 +20,6 @@ alias b='cd -' alias c='clear' # shortcut to clear your terminal -alias sprof='source ~/.bash_profile' - # useful command to find what you should be aliasing: alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr" @@ -28,9 +27,7 @@ alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' alias log='tail -f -0 ./log/*.log' alias ss='ruby ./script/server' alias sc='ruby ./script/console' -alias cdm='cap deploy deploy:migrate' -alias model='script/generate model' -alias controller='script/generate controller' +alias gen='script/generate' alias migration='script/generate migration' alias migrate='rake db:migrate' alias rollback='rake db:rollback' @@ -45,6 +42,17 @@ alias netstat="sudo lsof -i -P" alias colorslist="set | egrep 'COLOR_\w*'" # lists all the colors function f() { find * -name $1; } +function p() { + cd $* && m +} +function m() { + if [ -n "$*" ]; then + files=$* + else + files=. + fi + mate -l1 $files 2>/dev/null +} function extract() { if [ -f $1 ] ; then @@ -78,7 +86,6 @@ if [ $system_name = 'Darwin' ]; then } alias ls='ls -G' alias pubkey='pubkey | pbcopy && echo "Keys copied to clipboard"' - alias m='mate .' alias et="m" alias o='open .' alias eprof="mate ~/.config" diff --git a/bash/bashrc b/bash/bashrc index 9c99720..1b93c4a 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -1,10 +1,14 @@ export CURRENT_SHELL=`which bash` export DOT_FILES=$HOME/.config -source $DOT_FILES/bash/common # All things that are both ZSH and Bash compatible -source $DOT_FILES/git/git-completion +# All things that are both ZSH and Bash compatible +source $DOT_FILES/bash/common source $DOT_FILES/bash/save-directory +source $DOT_FILES/git/git-completion +alias reload="source ~/.bashrc" + +export PS1="\w ♪ " if [ $system_name == 'Darwin' ]; then source $DOT_FILES/bash/terminal diff --git a/bash/common b/bash/common index 4d3816e..3deaf80 100644 --- a/bash/common +++ b/bash/common @@ -1,3 +1,6 @@ +export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/mongodb/bin:/usr/local/pgsql/bin:/usr/X11/bin:/opt/local/bin +export CDPATH=".:~" + system_name=`uname -s` # Sets 'Darwin' or 'Linux' etc # Common functionality between Zsh and Bash @@ -5,4 +8,6 @@ source $DOT_FILES/bash/exports source $DOT_FILES/git/gitrc source $DOT_FILES/bash/aliases +export VCPROMPT=~/.config/misc/vcprompt.py + if [ -f ~/.rvm/bin/rvm ] ; then source ~/.rvm/bin/rvm ; fi diff --git a/bash/exports b/bash/exports index 509be32..10eb71d 100644 --- a/bash/exports +++ b/bash/exports @@ -2,7 +2,7 @@ if [ $system_name = 'Darwin' ]; then export EDITOR='mate -w' export PATH="/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/:$PATH" export PATH="/Library/PostgreSQL8/bin/:$PATH" - export CDPATH='.:~:~/Projecs:~/Sites' + export CDPATH="$CDPATH:~/Code/*:~/Sites/*" export GEM_OPEN_EDITOR='mate' else export EDITOR='nano -w' diff --git a/misc/inputrc b/misc/inputrc index d2d8a4d..b3621df 100644 --- a/misc/inputrc +++ b/misc/inputrc @@ -1,5 +1,7 @@ -# from http://www.pixelbeat.org/settings/.inputrc - +set meta-flag on +set input-meta on +set output-meta on +set convert-meta off # By default up/down are bound to previous-history # and next-history respectively. The following does the @@ -12,7 +14,7 @@ # "\e[B": history-search-forward "\e[A": history-search-backward - + $if Bash # F10 toggles mc on and off # Note Ctrl-o toggles panes on and off in mc diff --git a/zsh/config b/zsh/config index fb8ca09..491d938 100644 --- a/zsh/config +++ b/zsh/config @@ -1 +1,2 @@ +alias reload="source ~/.zshrc" setopt extendedglob \ No newline at end of file diff --git a/zsh/oh-my-zsh b/zsh/oh-my-zsh index 09320cd..710d00d 100644 --- a/zsh/oh-my-zsh +++ b/zsh/oh-my-zsh @@ -1,6 +1,6 @@ export ZSH=$HOME/.oh-my-zsh export ZSH_THEME="risto" -plugins=(rails git textmate ruby osx) +plugins=(rails git ruby osx) if [ -d "$ZSH" ]; then source $ZSH/oh-my-zsh.sh @@ -8,8 +8,4 @@ else echo "Cloning Oh My Zsh..." /usr/bin/env git clone git://github.com/robbyrussell/oh-my-zsh.git "$ZSH" source $ZSH/oh-my-zsh.sh -fi - - - - +fi \ No newline at end of file diff --git a/zsh/theme b/zsh/theme index b167617..f197d3f 100644 --- a/zsh/theme +++ b/zsh/theme @@ -1,6 +1,17 @@ -PROMPT='%{$fg[green]%}%n@%m:%{$fg_bold[blue]%}%2~ %{$reset_color%}%(!.#.$) ' +function prompt_color() { + if [ "$(whoami)" = "root" ]; then + echo "red" + else + echo "green" + fi +} -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹" -ZSH_THEME_GIT_PROMPT_SUFFIX="›%{$reset_color%}" +ZSH_THEME_VCS_PROMPT_PREFIX="%{$fg[red]%}‹" +ZSH_THEME_VCS_PROMPT_SUFFIX="›%{$reset_color%}" +ZSH_THEME_VCS_PROMPT_FORMAT="${ZSH_THEME_VCS_PROMPT_PREFIX}%b:%h${ZSH_THEME_VCS_PROMPT_SUFFIX}" -RPROMPT='$(~/.config/misc/vcprompt.py -f "${ZSH_THEME_GIT_PROMPT_PREFIX}%b:%h${ZSH_THEME_GIT_PROMPT_SUFFIX}")' +# Prompts +# PS1='%{$fg[green]%}%n@%m:%{$fg_bold[blue]%}%2~ %{$reset_color%}%(!.#.$) ' + +PS1='%~ %{$fg[$(prompt_color)]%}♪%{$reset_color%} ' +RPS1='$(${VCPROMPT} -f ${ZSH_THEME_VCS_PROMPT_FORMAT})' diff --git a/zsh/zshrc b/zsh/zshrc index e80e22d..1862d08 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,8 +1,14 @@ export DOT_FILES=$HOME/.config export CURRENT_SHELL=`which zsh` -export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/mongodb/bin:/usr/local/pgsql/bin:/usr/X11/bin:/opt/local/bin +# Include some ZSH-compatible config from bash (such as aliases, etc) +source $DOT_FILES/bash/common + +# Install and load oh-my-zsh source $DOT_FILES/zsh/oh-my-zsh + +# Extra ZSH configuration source $DOT_FILES/zsh/config + +# My custom theme source $DOT_FILES/zsh/theme -source $DOT_FILES/bash/common \ No newline at end of file