Posts Tagged ‘zsh’

$PERL5LIB and zsh

Tuesday, October 7th, 2008

in my .zsh.d/S80_perl

 
# Perl
BASE_PATH=~/code/work/rtgi
for perl_lib in $(ls $BASE_PATH); do
    if [ -f $BASE_PATH/$perl_lib/Makefile.PL ]; then
        PERL5LIB=${PERL5LIB:+$PERL5LIB:}$BASE_PATH/$perl_lib/lib
 
    fi
done
export PERL5LIB

Git branch everywhere

Thursday, June 26th, 2008

The current trend is to have the name of the current git branch everywhere. Personnaly I display it in my vim’s status bar, and in my zsh prompt.

Here is my vimrc configuration for this (I’m not the author of this function, and can’t remember where I saw it first):

set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff}%{g:gitCurrentBranch}%{']'}%y\ %F%=%l,%c%V%8P
autocmd BufEnter * :call CurrentGitBranch()
 
let g:gitCurrentBranch = ''
function! CurrentGitBranch()
let cwd = getcwd()
cd %:p:h
let branch = matchlist(system('/usr/local/git/bin/git  branch -a --no-color'), '\v\* (\w*)\r?\n')
execute 'cd ' . cwd
if (len(branch))
let g:gitCurrentBranch = '][git:' . branch[1] . ''
else
let g:gitCurrentBranch = ''
endif
return g:gitCurrentBranch
endfunction
vim statusbar

vim statusbar

and my zshrc:

local git_b
git_b='$(get_git_prompt_info '%b')'
PROMPT="%(?..%U%?%u:) $git_b %40<...<%/%(#.%U>%u.%B>%b) "

with the following script S55_git

zsh git

zsh git

keep your zshrc simple

Wednesday, June 18th, 2008

Keep your .zshrc simple. Mine looks like this :

autoload -U compinit zrecompile
zsh_cache=${HOME}/.zsh_cache
mkdir -p $zsh_cache
compinit -d $zsh_cache/zcomp-$HOST
for f in ~/.zshrc $zsh_cache/zcomp-$HOST; do
    zrecompile -p $f && rm -f $f.zwc.old
done
setopt extended_glob
for zshrc_snipplet in ~/.zsh.d/S[0-9][0-9]*[^~] ; do
    source $zshrc_snipplet
done
function history-all { history -E 1 }

and then, in my .zsh.d directory, i’ve got:

S10_zshopts
S20_environment
S30_binds
S40_completion
S50_aliases
S60_prompt
S71_ssh
S72_git

All my aliases are in the same file, it’s much easier to search/find/add