Last active
December 21, 2015 11:49
-
-
Save qwerty12/6301974 to your computer and use it in GitHub Desktop.
Set up zsh on OS X with my preferred configuration (this will remove any pre-existing .zshrc!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install my favourite coreutils: GNU's. Sorry, BSD... | |
brew rm coreutils >/dev/null 2>&1 | |
brew update | |
# Add progress bar patch | |
patch -p0 << "EOF" | |
--- /usr/local/Library/Formula/coreutils.rb.orig 2013-09-06 15:23:52.000000000 +0100 | |
+++ /usr/local/Library/Formula/coreutils.rb 2013-09-06 15:33:35.000000000 +0100 | |
@@ -8,6 +8,10 @@ | |
depends_on 'xz' => :build | |
+ def patches | |
+ "http://beatex.org/web/advcopy/advcpmv-0.5-8.21.patch" | |
+ end | |
+ | |
def install | |
system "./configure", "--prefix=#{prefix}", | |
"--program-prefix=g", | |
EOF | |
brew install coreutils findutils gnu-sed zsh-syntax-highlighting | |
brew tap homebrew/dupes | |
brew install grep --default-names | |
# Keep zsh's files in .zsh and download grml's configuration and antigen | |
/bin/mkdir ~/.zsh | |
cd ~/.zsh | |
curl -L -o .zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc | |
curl https://raw.github.com/zsh-users/antigen/master/antigen.zsh > antigen.zsh | |
# Set up things before the grml config does its stuff | |
/bin/cat > .zshrc.pre << "EOF" | |
export PATH="${HOME}/.local/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:${PATH}:/Applications/DarwinDumper.app/Contents/Resources/Tools" | |
export BROWSER=open | |
export GREP_OPTIONS="--exclude=.svn --exclude=.git" | |
alias dircolors="true" | |
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.exe=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.dmg=01;31:*.pkg=01;31:*.lha=01;31:*.sfx=01;31:*.lzop=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;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=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:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.iff=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=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:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:*.pl=00;33:*.PL=00;33:*.pm=00;33:*.tt=00;33:*.yml=00;33:*.sql=00;33:*.html=00;33:*.css=00;33:*.js=00;33:*.c=00;33:*.h=00;37:*.m=00;33:*.cpp=00;33:*.hpp=00;37:*.java=00;33:*.py=00;33:*.rb=00;33:'; | |
export LESS="-I" | |
SUBL="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | |
if [ -x $SUBL ]; then | |
subl() { | |
$SUBL "$@" | |
} | |
export EDITOR="'$SUBL' -w" | |
else | |
export EDITOR=nano | |
unset SUBL | |
fi | |
ADOTDIR="${ZDOTDIR}/.antigen" | |
source "${ZDOTDIR}/antigen.zsh" | |
ZSH="${ADOTDIR}/repos/https-COLON--SLASH--SLASH-github.com-SLASH-robbyrussell-SLASH-oh-my-zsh.git" | |
if [ ! -d $ZSH ]; then | |
DISABLE_LS_COLORS="true" | |
antigen use oh-my-zsh | |
curl https://gist.github.com/qwerty12/5997039/raw/7b44538d9454a197056e98187f2b65fdaa81335d/_brew.zsh > "${ZSH}/plugins/brew/_brew" | |
else | |
source "${ZSH}/lib/completion.zsh" | |
source "${ZSH}/lib/key-bindings.zsh" | |
fi | |
fpath=(${ZSH}/plugins/brew ${fpath}) # antigen bundle brew (and poss. apply) will be used when more than one plugin from OMZ is desired | |
EOF | |
# Things to run after the grml config has done its stuff | |
/bin/cat > .zshrc.local << "EOF" | |
export PYTHONPATH=/usr/local/lib/python2.7/site-packages # brew pip | |
setopt autocd completealiases histignoredups | |
unsetopt nobeep | |
unalias dircolors | |
alias sudo="sudo " | |
alias mkdir="mkdir -p" | |
alias nano="nano -w" | |
alias update="antigen update; mkdir -p /Library/Caches/Homebrew; brew update && brew upgrade && brew cleanup" | |
alias ldd="otool -L" | |
alias shutdown="sudo shutdown" | |
alias dmesg="sudo dmesg" | |
alias sync="sudo /bin/sync" | |
alias cp="cp -g" | |
alias mv="mv -g" | |
source "${ZSH}/lib/termsupport.zsh" | |
unset ZSH | |
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
test -d /usr/local/Cellar/findutils && alias find="gfind" | |
test -d /usr/local/Cellar/gnu-sed && alias sed="gsed" | |
cd() { | |
if builtin cd "$@" | |
then | |
if test -w "."; then | |
zstyle ':prompt:grml:*:items:path' pre '%B' | |
else | |
zstyle ':prompt:grml:*:items:path' pre '%B%F{red}' | |
fi | |
return 0 | |
else | |
return $? | |
fi | |
} | |
EOF | |
# While I use ~/.zsh for the zsh config, zsh itself still expects to find a ~/.zshrc so create it and have it just source grml's configuration | |
/bin/cat > ~/.zshrc << "EOF" | |
ZDOTDIR=${HOME}/.zsh | |
source ${ZDOTDIR}/.zshrc | |
EOF | |
# Change the shell to zsh. In Mavericks, it's the current version so just use that | |
chsh -s /bin/zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment