Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created October 31, 2011 20:21
Show Gist options
  • Save KirinDave/1328789 to your computer and use it in GitHub Desktop.
Save KirinDave/1328789 to your computer and use it in GitHub Desktop.
More ZSH rprompt help
export PAGER=less
export MANPAGER="less -r"
alias lesr='less -r'
# Git commands
alias gb='git branch -a --color -v'
alias gr="gitk --all --since='last week' &"
# Helpful
alias pu=pushd
alias p=popd
alias ..="cd .."
alias d='dirs -v'
alias h=history
alias ll='ls -l'
alias la='ls -a'
# List only file beginning with "."
alias lsa='ls -ld .*'
alias grep='grep --color'
alias cgrep='grep --color=always'
function lcgrep() {
grep --color=always "$@" | less -r
}
# ZSH spelling correction avoidance
alias mv='nocorrect mv' # no spelling correction on mv
alias cp='nocorrect cp' # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias rm='nocorrect rm' # no spelling correction on rm
# ZSH options
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_DUPS
setopt AUTO_NAME_DIRS
setopt HIST_REDUCE_BLANKS
HISTFILE=~/.zhistory
HISTSIZE=100000
SAVEHIST=100000
bindkey -e
bindkey '\eq' push-line-or-edit
# ZSH History trick
bindkey "\e[A" history-beginning-search-backward
bindkey "\e[B" history-beginning-search-forward
bindkey "\eOA" history-beginning-search-backward
bindkey "\eOB" history-beginning-search-forward
# Setting up the prompt
setopt PROMPT_SUBST
setopt ALWAYS_LAST_PROMPT
PROMPT='%~ %B%# 〕%b'
RPROMPT='%B←%b %? [%25>..>$(~/bin/chef_env)] %B%20>..>$(~/bin/git_current_branch)%b'
cdpath=(~/Projects/CrowdFlower)
# SSH Complete
KNOWN_SSH_COMPLETE=( $(cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e 's/,.*//g' | \
uniq | \
egrep -v '[0123456789]') )
DEFINED_SSH_COMPLETE=( $( cat ~/.ssh/config | egrep '^Host' | cut -f 2 -d ' ') )
# Zsh builtins
namedir () { eval $1=$PWD ; eval : ~$1 }
function lst() {
if [ "$1" ]; then
prefix="$1/"
else
prefix=
fi
print -l $prefix**/* | xargs ls -d $ls_opt
}
# Some of Brendano's options
setopt autopushd pushdminus pushdtohome autocd pushdignoredups
autoload -U compinit
compinit
setopt clobber
setopt correctall
setopt equals
setopt extendedglob
setopt interactive_comments
setopt longlistjobs
setopt nohup
setopt nonomatch # echo not-here* actually gets the *
#setopt nullglob # echo not-here* expands to no args
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# Some emacs automation
alias retags="etags --regex='/[ \t]+def[ ]+\(.+?\)(/\1/\/'"
# And the most important things:
export NETHACKOPTIONS='male,!autopickup,DECgraphics,color,extmenu,name:Elrohir,race:elf,role:wizard,pettype:dog'
#!/usr/bin/env runhaskell
import System.IO
import System.Environment
import Data.List
isQuote x = x == '"' || x == '\''
isntQuote x = not . isQuote
linesWith = filter . isInfixOf
dotChefLines = do
floc <- (++"/.chef/knife.rb") `fmap` getEnv "HOME"
cH <- openFile floc ReadMode
lines `fmap` hGetContents cH
getQuotedValue string = takeWhile isntQuote start
where start = drop 1 $ dropWhile isntQuote string
userString user env = user ++ "@" ++ env
main = do
chefLines <- dotChefLines
let chefLinesWith = flip linesWith $ chefLines
user = getQuotedValue (head $ chefLinesWith "node_name")
env = getQuotedValue (head $ chefLinesWith "builder_cluster") in
putStrLn $ userString user env
#!/bin/zsh
RESULT=`git branch 2>&1 | grep '^\*' | cut -c 3-`
if [[ $? -eq 0 ]] ; then
echo $RESULT
else
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment