mirror of https://github.com/bjeanes/dotfiles.git
Major refactoring of ZSH and Bash dot-files.
* Theme is now set for both shells from same file so they should always be as similar as possible. * Removed terminal functions (for doing silly things like moving/resizing the Terminal.app window) which I never used * Not using ZSH color module (so that I can have some level of compatibility with bash for prompt etc)pull/2/head
parent
43424d97e9
commit
db5739614e
|
@ -1,16 +1,4 @@
|
||||||
alias reload="source ~/.bashrc"
|
[[ -f /etc/bash_completion ]] && source /etc/bash_completion
|
||||||
|
|
||||||
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
|
# readline settings
|
||||||
bind "set completion-ignore-case on"
|
bind "set completion-ignore-case on"
|
||||||
|
@ -22,4 +10,6 @@ shopt -s histappend
|
||||||
shopt -s cdable_vars
|
shopt -s cdable_vars
|
||||||
shopt -s globstar 2>/dev/null # Bash 4 and above only
|
shopt -s globstar 2>/dev/null # Bash 4 and above only
|
||||||
|
|
||||||
complete -C $DOT_FILES/bash/rake-completion.rb -o default rake}
|
complete -C $DOT_FILES/bash/rake-completion.rb -o default rake}
|
||||||
|
|
||||||
|
alias reload="source ~/.bashrc"
|
|
@ -1,47 +0,0 @@
|
||||||
# Minimise terminal window to Dock
|
|
||||||
function mintw() { printf "\e[2t"; return 0; }
|
|
||||||
|
|
||||||
# Send Terminal window to background
|
|
||||||
function bgtw() { printf "\e[6t"; return 0; }
|
|
||||||
|
|
||||||
function hidetw() {
|
|
||||||
/usr/bin/osascript -e 'tell application "System Events" to set visible of some item of ( get processes whose name = "Terminal" ) to false'
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# positive integer test (including zero)
|
|
||||||
function positive_int() { return $(test "$@" -eq "$@" > /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; }
|
|
|
@ -67,27 +67,4 @@ function extract() {
|
||||||
else
|
else
|
||||||
echo "'$1' is not a valid file"
|
echo "'$1' is not a valid file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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'`
|
|
||||||
echo $PWD|sed -e 's-.*/\.\{0,1\}[^/]\([^/]*$\)-\1-'
|
|
||||||
else
|
|
||||||
echo '~'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
else # defined two for diff systems because Fish did (not entirely sure why)
|
|
||||||
function prompt_pwd() {
|
|
||||||
case "$PWD" in
|
|
||||||
$HOME)
|
|
||||||
echo '~'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf "%s" `echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g'`
|
|
||||||
echo $PWD|sed -n -e 's-.*/\.\{0,1\}.\([^/]*\)-\1-p'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
fi
|
|
|
@ -1,11 +1,12 @@
|
||||||
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
|
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:${PATH}"
|
||||||
CDPATH=".:${HOME}"
|
CDPATH=".:${HOME}"
|
||||||
|
VCPROMPT="${HOME}/.config/misc/vcprompt.py"
|
||||||
|
|
||||||
|
source $DOT_FILES/$CURRENT_SHELL/config.*sh
|
||||||
source $DOT_FILES/shell/exports.sh
|
source $DOT_FILES/shell/exports.sh
|
||||||
source $DOT_FILES/shell/aliases.sh
|
source $DOT_FILES/shell/aliases.sh
|
||||||
source $DOT_FILES/shell/save-directory.sh
|
source $DOT_FILES/shell/save-directory.sh
|
||||||
|
source $DOT_FILES/shell/prompt.sh
|
||||||
source $DOT_FILES/git/git.sh
|
source $DOT_FILES/git/git.sh
|
||||||
|
|
||||||
[[ `uname -s` == 'Darwin' ]] && source $DOT_FILES/shell/osx.sh
|
[[ `uname -s` == 'Darwin' ]] && source $DOT_FILES/shell/osx.sh
|
||||||
|
|
||||||
VCPROMPT=~/.config/misc/vcprompt.py
|
|
|
@ -2,7 +2,8 @@ export PATH="/usr/local/mysql/bin/:$PATH"
|
||||||
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
|
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
|
||||||
export PATH="$PATH:/usr/local/jruby/bin"
|
export PATH="$PATH:/usr/local/jruby/bin"
|
||||||
|
|
||||||
# Use single quotes here to lazy evaluate the $EDITOR variable
|
# Use single quotes here to lazy evaluate the $EDITOR variable (as it changes later if on OS X)
|
||||||
|
export EDITOR='nano -w'
|
||||||
export GEM_OPEN_EDITOR='$EDITOR'
|
export GEM_OPEN_EDITOR='$EDITOR'
|
||||||
export GIT_EDITOR='$EDITOR'
|
export GIT_EDITOR='$EDITOR'
|
||||||
export VISUAL='$EDITOR'
|
export VISUAL='$EDITOR'
|
||||||
|
@ -10,27 +11,8 @@ export VISUAL='$EDITOR'
|
||||||
export IRBRC="$HOME/.irbrc"
|
export IRBRC="$HOME/.irbrc"
|
||||||
export JEWELER_OPTS="--rspec --gemcutter --rubyforge --reek --roodi"
|
export JEWELER_OPTS="--rspec --gemcutter --rubyforge --reek --roodi"
|
||||||
|
|
||||||
export COLOR_NC='\e[0m' # No Color
|
|
||||||
export COLOR_WHITE='\e[1;37m'
|
|
||||||
export COLOR_BLACK='\e[0;30m'
|
|
||||||
export COLOR_BLUE='\e[0;34m'
|
|
||||||
export COLOR_LIGHT_BLUE='\e[1;34m'
|
|
||||||
export COLOR_GREEN='\e[0;32m'
|
|
||||||
export COLOR_LIGHT_GREEN='\e[1;32m'
|
|
||||||
export COLOR_CYAN='\e[0;36m'
|
|
||||||
export COLOR_LIGHT_CYAN='\e[1;36m'
|
|
||||||
export COLOR_RED='\e[0;31m'
|
|
||||||
export COLOR_LIGHT_RED='\e[1;31m'
|
|
||||||
export COLOR_PURPLE='\e[0;35m'
|
|
||||||
export COLOR_LIGHT_PURPLE='\e[1;35m'
|
|
||||||
export COLOR_BROWN='\e[0;33m'
|
|
||||||
export COLOR_YELLOW='\e[1;33m'
|
|
||||||
export COLOR_GRAY='\e[0;30m'
|
|
||||||
export COLOR_LIGHT_GRAY='\e[0;37m'
|
|
||||||
|
|
||||||
export TERM=xterm-color
|
export TERM=xterm-color
|
||||||
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
|
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
|
||||||
export CLICOLOR=1
|
export CLICOLOR=1
|
||||||
|
|
||||||
export HISTSIZE=1000000
|
export HISTSIZE=1000000
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ alias o='open .'
|
||||||
|
|
||||||
# replacement netstat cmd to find ports used by apps on OS X
|
# replacement netstat cmd to find ports used by apps on OS X
|
||||||
alias netstat="sudo lsof -i -P"
|
alias netstat="sudo lsof -i -P"
|
||||||
alias pubkey='pubkey | pbcopy && echo "Keys copied to clipboard"'
|
alias pubkey="cat $HOME/.ssh/*.pub | pbcopy && echo 'Keys copied to clipboard'"
|
||||||
|
|
||||||
|
|
||||||
alias hidefile='/usr/bin/SetFile -a "V"'
|
alias hidefile='/usr/bin/SetFile -a "V"'
|
||||||
alias showfile='/usr/bin/SetFile -a "v"'
|
alias showfile='/usr/bin/SetFile -a "v"'
|
||||||
|
@ -21,8 +20,6 @@ function osinfo() {
|
||||||
echo "${x1} - ${x2} - ${x3} - ${x4}"
|
echo "${x1} - ${x2} - ${x3} - ${x4}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function tab() {
|
function tab() {
|
||||||
osascript 2>/dev/null <<EOF
|
osascript 2>/dev/null <<EOF
|
||||||
tell application "System Events"
|
tell application "System Events"
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
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'`
|
||||||
|
echo $PWD|sed -e 's-.*/\.\{0,1\}[^/]\([^/]*$\)-\1-'
|
||||||
|
else
|
||||||
|
echo '~'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
else # defined two for diff systems because Fish did (not entirely sure why)
|
||||||
|
function prompt_pwd() {
|
||||||
|
case "$PWD" in
|
||||||
|
$HOME)
|
||||||
|
echo '~'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "%s" `echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g'`
|
||||||
|
echo $PWD|sed -n -e 's-.*/\.\{0,1\}.\([^/]*\)-\1-p'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# colors
|
||||||
|
function color {
|
||||||
|
local reset='\e[0m'
|
||||||
|
local white='\e[1;37m'
|
||||||
|
local black='\e[0;30m'
|
||||||
|
local blue='\e[0;34m'
|
||||||
|
local light_blue='\e[1;34m'
|
||||||
|
local green='\e[0;32m'
|
||||||
|
local light_green='\e[1;32m'
|
||||||
|
local cyan='\e[0;36m'
|
||||||
|
local light_cyan='\e[1;36m'
|
||||||
|
local red='\e[0;31m'
|
||||||
|
local light_red='\e[1;31m'
|
||||||
|
local purple='\e[0;35m'
|
||||||
|
local light_purple='\e[1;35m'
|
||||||
|
local brown='\e[0;33m'
|
||||||
|
local yellow='\e[1;33m'
|
||||||
|
local gray='\e[0;30m'
|
||||||
|
local light_gray='\e[0;37m'
|
||||||
|
|
||||||
|
local chosen="$(eval echo \$$1)"
|
||||||
|
|
||||||
|
if [ $CURRENT_SHELL = 'zsh' ]; then
|
||||||
|
echo "%{$chosen%}"
|
||||||
|
else
|
||||||
|
printf "$chosen"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function prompt_char {
|
||||||
|
git branch >/dev/null 2>/dev/null && echo '±' && return
|
||||||
|
hg root >/dev/null 2>/dev/null && echo '☿' && return
|
||||||
|
# echo '○'
|
||||||
|
echo '♪'
|
||||||
|
}
|
||||||
|
|
||||||
|
function prompt_color() {
|
||||||
|
if [ "$USER" = "root" ]; then
|
||||||
|
echo red
|
||||||
|
else
|
||||||
|
if [ -n "$SSH_TTY" ]; then
|
||||||
|
echo blue
|
||||||
|
else
|
||||||
|
echo green
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function prompt_vcs_if_bash() {
|
||||||
|
if [ $CURRENT_SHELL = 'bash' ]; then
|
||||||
|
local vcs="$(eval echo $RPS1)"
|
||||||
|
[[ "$vcs" != "" ]] && echo " $vcs"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
RPS1='$(${VCPROMPT} -f $(color red)‹%b:%h›$(color reset))'
|
||||||
|
PS1="\$(color blue)\$(prompt_pwd)\$(prompt_vcs_if_bash) \$(color \$(prompt_color))\$(prompt_char)\$(color reset) "
|
|
@ -1,26 +0,0 @@
|
||||||
function prompt_color() {
|
|
||||||
if [ "$USER" = "root" ]; then
|
|
||||||
echo "red"
|
|
||||||
else
|
|
||||||
if [ -n "$SSH_TTY" ]; then
|
|
||||||
echo "blue"
|
|
||||||
else
|
|
||||||
echo "green"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_char {
|
|
||||||
git branch >/dev/null 2>/dev/null && echo '±' && return
|
|
||||||
hg root >/dev/null 2>/dev/null && echo '☿' && return
|
|
||||||
# echo '○'
|
|
||||||
echo '♪'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prompts
|
|
||||||
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}"
|
|
||||||
|
|
||||||
PS1='%{$fg[blue]%}$(prompt_pwd)%{$reset_color%} %{$fg[$(prompt_color)]%}$(prompt_char)%{$reset_color%} '
|
|
||||||
RPS1='$(${VCPROMPT} -f ${ZSH_THEME_VCS_PROMPT_FORMAT})'
|
|
12
zsh/zshrc
12
zsh/zshrc
|
@ -1,14 +1,11 @@
|
||||||
export CURRENT_SHELL=`which zsh`
|
export CURRENT_SHELL="zsh"
|
||||||
export DOT_FILES=$HOME/.config
|
export DOT_FILES=$HOME/.config
|
||||||
|
|
||||||
# Common functionality between Zsh and Bash
|
|
||||||
source $DOT_FILES/shell/common.sh
|
|
||||||
|
|
||||||
# Install and load oh-my-zsh
|
# Install and load oh-my-zsh
|
||||||
source $DOT_FILES/zsh/oh-my-zsh.zsh
|
source $DOT_FILES/zsh/oh-my-zsh.zsh
|
||||||
|
|
||||||
# Extra ZSH configuration
|
# Common functionality between Zsh and Bash
|
||||||
source $DOT_FILES/zsh/config.zsh
|
source $DOT_FILES/shell/common.sh
|
||||||
|
|
||||||
# Rake completion
|
# Rake completion
|
||||||
source $DOT_FILES/zsh/completions.zsh
|
source $DOT_FILES/zsh/completions.zsh
|
||||||
|
@ -16,8 +13,5 @@ source $DOT_FILES/zsh/completions.zsh
|
||||||
# Rake completion
|
# Rake completion
|
||||||
source $DOT_FILES/zsh/rake_completion.zsh
|
source $DOT_FILES/zsh/rake_completion.zsh
|
||||||
|
|
||||||
# My custom theme
|
|
||||||
source $DOT_FILES/zsh/theme.zsh
|
|
||||||
|
|
||||||
# RVM
|
# RVM
|
||||||
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
|
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
|
Loading…
Reference in New Issue