diff --git a/bash/bashrc b/bash/bashrc index c3ab99a..663b6ee 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -2,34 +2,10 @@ export CURRENT_SHELL=`which bash` export DOT_FILES=$HOME/.config # All things that are both ZSH and Bash compatible -source $DOT_FILES/bash/common -source $DOT_FILES/bash/save-directory +source $DOT_FILES/shell/common.sh + +# Git completion support in bash source $DOT_FILES/git/git-completion -alias reload="source ~/.bashrc" - -export PS1="\w ♪ " - -if [ $system_name == 'Darwin' ]; then - source $DOT_FILES/bash/terminal -fi - -if [ -f /etc/bash_completion ]; then - . /etc/bash_completion -# else - # . $DOT_FILES/bash/bash_completion -fi - -# readline settings -bind "set completion-ignore-case on" -bind "set bell-style none" # No bell, because it's damn annoying -bind "set show-all-if-ambiguous On" # this allows you to automatically show completion without double tab-ing - -shopt -s checkwinsize -shopt -s histappend -shopt -s globstar 2>/dev/null # Bash 4 and above only - -complete -C $DOT_FILES/bash/rake-completion.rb -o default rake} - # RVM [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm diff --git a/bash/common b/bash/common deleted file mode 100644 index 74bad2c..0000000 --- a/bash/common +++ /dev/null @@ -1,11 +0,0 @@ -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=".:${HOME}" - -system_name=`uname -s` # Sets 'Darwin' or 'Linux' etc - -# Common functionality between Zsh and Bash -source $DOT_FILES/bash/exports -source $DOT_FILES/git/gitrc -source $DOT_FILES/bash/aliases - -export VCPROMPT=~/.config/misc/vcprompt.py \ No newline at end of file diff --git a/bash/config.sh b/bash/config.sh new file mode 100644 index 0000000..8e0af7f --- /dev/null +++ b/bash/config.sh @@ -0,0 +1,25 @@ +alias reload="source ~/.bashrc" + +export PS1="\w ♪ " + +if [ $system_name == 'Darwin' ]; then + source $DOT_FILES/bash/terminal +fi + +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +# else + # . $DOT_FILES/bash/bash_completion +fi + +# readline settings +bind "set completion-ignore-case on" +bind "set bell-style none" # No bell, because it's damn annoying +bind "set show-all-if-ambiguous On" # this allows you to automatically show completion without double tab-ing + +shopt -s checkwinsize +shopt -s histappend +shopt -s cdable_vars +shopt -s globstar 2>/dev/null # Bash 4 and above only + +complete -C $DOT_FILES/bash/rake-completion.rb -o default rake} \ No newline at end of file diff --git a/bash/save-directory b/bash/save-directory deleted file mode 100644 index 8d25e29..0000000 --- a/bash/save-directory +++ /dev/null @@ -1,10 +0,0 @@ -if [ ! -f ~/.dirs ]; then - touch ~/.dirs -fi - -alias show='cat ~/.dirs' -save (){ - command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ; -} -source ~/.dirs # Initialization for the above 'save' facility: source the .dirs file -shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility \ No newline at end of file diff --git a/bash/terminal b/bash/terminal index 819d5d6..7f864b6 100644 --- a/bash/terminal +++ b/bash/terminal @@ -1,8 +1,3 @@ -# From http://codesnippets.joyent.com/posts/show/1516 - -declare -x PROMPT_COMMAND='printf "\e]0;$(/bin/pwd | /usr/bin/tr -d "[[:cntrl:]]") \a"' - - # Minimise terminal window to Dock function mintw() { printf "\e[2t"; return 0; } @@ -49,13 +44,4 @@ function maxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; } function maxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; } # show number of lines & columns -function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; } - -# open a new Terminal window in same location as current directory -unset -f newin -function newin() { - /bin/pwd | /usr/bin/pbcopy - /usr/bin/open -a Terminal - /usr/bin/osascript -e 'tell application "Terminal" to do script with command "cd \"$(/usr/bin/pbpaste)\"; echo \" \" | /usr/bin/pbcopy; /usr/bin/clear"' - return 0 -} \ No newline at end of file +function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; } \ No newline at end of file diff --git a/git/gitrc b/git/git.sh similarity index 100% rename from git/gitrc rename to git/git.sh diff --git a/ruby/gemrc b/ruby/gemrc index 803b8f4..d853f01 100644 --- a/ruby/gemrc +++ b/ruby/gemrc @@ -2,7 +2,7 @@ :benchmark: false :verbose: true :update_sources: true -gem: --no-ri +gem: --no-ri --no-rdoc :sources: - http://gemcutter.org :backtrace: false diff --git a/bash/aliases b/shell/aliases.sh similarity index 67% rename from bash/aliases rename to shell/aliases.sh index d07ac8a..fec7fd0 100644 --- a/bash/aliases +++ b/shell/aliases.sh @@ -1,18 +1,16 @@ alias gi='sudo gem install' -alias ls='ls -FG' alias ll='ls -lah' alias ..='cd ..;' # can then do .. .. .. to move up multiple directories. alias ...='.. ..' 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 ducks='du -cks * | sort -rn |head -11' # Lists the size of all the folders alias top='top -o cpu' -alias o='open .' -alias et="m" +alias et="$EDITOR ." alias sprof="reload" -alias home='cd ~' # the tilda is too hard to reach +alias home="cd $HOME" # the tilde is too hard to reach alias systail='tail -f -n0 /var/log/system.log' alias aptail='tail -f -n0 /var/log/apache*/*log' alias l='ls' @@ -34,11 +32,7 @@ alias rollback='rake db:rollback' alias r='rake' alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"' -alias pubkey='cat ~/.ssh/*.pub' - -# replacement netstat cmd to find ports used by apps on OS X -alias netstat="sudo lsof -i -P" - +alias pubkey="cat $HOME/.ssh/*.pub" alias colorslist="set | egrep 'COLOR_\w*'" # lists all the colors function f() { find * -name $1; } @@ -75,7 +69,7 @@ function extract() { fi } -if [ `uname` = "Darwin" ]; then +if [ `uname -s` = "Darwin" ]; then function prompt_pwd() { if [ "$PWD" != "$HOME" ]; then printf "%s" `echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g'` @@ -96,28 +90,4 @@ else # defined two for diff systems because Fish did (not entirely sure why) ;; esac } -fi - - - -if [ $system_name = 'Darwin' ]; then - function manpdf() { man -t $@ | open -f -a Preview; } - function osinfo() { - x1="$(/usr/bin/sw_vers -productName)" - x2="$(/usr/bin/sw_vers -productVersion)" - x3="$(/usr/bin/sw_vers -buildVersion)" - x4="$(/usr/bin/arch)" - echo "${x1} - ${x2} - ${x3} - ${x4}" - } - alias ls='ls -G' - alias pubkey='pubkey | pbcopy && echo "Keys copied to clipboard"' - alias et="m" - alias o='open .' - alias eprof="mate ~/.config" - alias hidefile='/usr/bin/SetFile -a "V"' - alias showfile='/usr/bin/SetFile -a "v"' - alias startpg='sudo /Library/StartupItems/PostgreSQL/PostgreSQL start' - alias readrails="mate `ruby -rubygems -e "puts( ['rails', 'activerecord', 'activeresource', 'actionpack', 'activesupport'].collect { |gem| gems = Gem.source_index.find_name(gem); gems.last.full_gem_path; }.join(' '))"`" -else - alias ls='ls --color=auto' -fi +fi \ No newline at end of file diff --git a/shell/common.sh b/shell/common.sh new file mode 100644 index 0000000..05c6db7 --- /dev/null +++ b/shell/common.sh @@ -0,0 +1,11 @@ +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 +CDPATH=".:${HOME}" + +source $DOT_FILES/shell/exports.sh +source $DOT_FILES/shell/aliases.sh +source $DOT_FILES/shell/save-directory.sh +source $DOT_FILES/git/git.sh + +[[ `uname -s` == 'Darwin' ]] && source $DOT_FILES/shell/osx.sh + +VCPROMPT=~/.config/misc/vcprompt.py \ No newline at end of file diff --git a/bash/exports b/shell/exports.sh similarity index 61% rename from bash/exports rename to shell/exports.sh index 97a2bde..c984101 100644 --- a/bash/exports +++ b/shell/exports.sh @@ -1,24 +1,14 @@ -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" - CDPATH="${CDPATH}:${HOME}/Code/Mocra/:${HOME}/Code/Personal:${HOME}/Sites/Mocra/:${HOME}/Sites/Personal/" - export GEM_OPEN_EDITOR='mate' -else - export EDITOR='nano -w' -fi - export PATH="/usr/local/mysql/bin/:$PATH" export PATH="/opt/local/bin:/opt/local/sbin:$PATH" export PATH="$PATH:/usr/local/jruby/bin" +export GEM_OPEN_EDITOR=$EDITOR +export GIT_EDITOR=$EDITOR +export VISUAL=$EDITOR export IRBRC="$HOME/.irbrc" export JEWELER_OPTS="--rspec --gemcutter --rubyforge --reek --roodi" -export GIT_EDITOR=$EDITOR -export VISUAL=$EDITOR - export COLOR_NC='\e[0m' # No Color export COLOR_WHITE='\e[1;37m' export COLOR_BLACK='\e[0;30m' @@ -41,9 +31,5 @@ export TERM=xterm-color export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32' export CLICOLOR=1 -# sets title of window to be user@host -export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*} ${PWD}"; echo -ne "\007"' - -# export HISTCONTROL=erasedups # I actually want duplicates because of profileme export HISTSIZE=1000000 diff --git a/shell/osx.sh b/shell/osx.sh new file mode 100644 index 0000000..0a6e077 --- /dev/null +++ b/shell/osx.sh @@ -0,0 +1,84 @@ +export EDITOR='mate -w' +export PATH="/Library/PostgreSQL8/bin/:$PATH" +CDPATH="${CDPATH}:${HOME}/Code/Mocra/:${HOME}/Code/Personal:${HOME}/Sites/Mocra/:${HOME}/Sites/Personal/" + +alias o='open .' + +# replacement netstat cmd to find ports used by apps on OS X +alias netstat="sudo lsof -i -P" +alias pubkey='pubkey | pbcopy && echo "Keys copied to clipboard"' + + +alias hidefile='/usr/bin/SetFile -a "V"' +alias showfile='/usr/bin/SetFile -a "v"' + +function manpdf() { man -t $@ | open -f -a Preview; } +function osinfo() { + x1="$(/usr/bin/sw_vers -productName)" + x2="$(/usr/bin/sw_vers -productVersion)" + x3="$(/usr/bin/sw_vers -buildVersion)" + x4="$(/usr/bin/arch)" + echo "${x1} - ${x2} - ${x3} - ${x4}" +} + + + +function tab() { + osascript 2>/dev/null < /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); } + +# move the Terminal window +function mvtw() { + if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then + printf "\e[3;${1};${2};t" + return 0 + fi + return 1 +} + +# resize the Terminal window +function sizetw() { + if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then + printf "\e[8;${1};${2};t" + /usr/bin/clear + return 0 + fi + return 1 +} + +# full screen +function fullscreen() { printf "\e[3;0;0;t\e[8;0;0t"; /usr/bin/clear; return 0; } + +# default screen +function defaultscreen() { printf "\e[8;35;150;t"; printf "\e[3;300;240;t"; /usr/bin/clear; return 0; } + +# max columns +function maxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; } + +# max rows +function maxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; } + +# show number of lines & columns +function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; } \ No newline at end of file diff --git a/shell/save-directory.sh b/shell/save-directory.sh new file mode 100644 index 0000000..c59885c --- /dev/null +++ b/shell/save-directory.sh @@ -0,0 +1,11 @@ +if [ ! -f ~/.dirs ]; then + touch ~/.dirs +fi + +alias show='cat ~/.dirs' +save (){ + command sed "/!$/d" ~/.dirs > ~/.dirs1 + mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs + source ~/.dirs +} +source ~/.dirs # Initialization for the above 'save' facility: source the .dirs file diff --git a/zsh/completions b/zsh/completions.zsh similarity index 100% rename from zsh/completions rename to zsh/completions.zsh diff --git a/zsh/config b/zsh/config.zsh similarity index 100% rename from zsh/config rename to zsh/config.zsh diff --git a/zsh/oh-my-zsh b/zsh/oh-my-zsh.zsh similarity index 100% rename from zsh/oh-my-zsh rename to zsh/oh-my-zsh.zsh diff --git a/zsh/rake_completion b/zsh/rake_completion.zsh similarity index 100% rename from zsh/rake_completion rename to zsh/rake_completion.zsh diff --git a/zsh/theme b/zsh/theme.zsh similarity index 100% rename from zsh/theme rename to zsh/theme.zsh diff --git a/zsh/zshrc b/zsh/zshrc index 03e2f1b..d1bf23c 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,23 +1,23 @@ -export DOT_FILES=$HOME/.config export CURRENT_SHELL=`which zsh` +export DOT_FILES=$HOME/.config -# Include some ZSH-compatible config from bash (such as aliases, etc) -source $DOT_FILES/bash/common +# Common functionality between Zsh and Bash +source $DOT_FILES/shell/common.sh # Install and load oh-my-zsh -source $DOT_FILES/zsh/oh-my-zsh +source $DOT_FILES/zsh/oh-my-zsh.zsh # Extra ZSH configuration -source $DOT_FILES/zsh/config +source $DOT_FILES/zsh/config.zsh # Rake completion -source $DOT_FILES/zsh/completions +source $DOT_FILES/zsh/completions.zsh # Rake completion -source $DOT_FILES/zsh/rake_completion +source $DOT_FILES/zsh/rake_completion.zsh # My custom theme -source $DOT_FILES/zsh/theme +source $DOT_FILES/zsh/theme.zsh # RVM [[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm \ No newline at end of file