show more git info on zsh prompt
[ link: zsh-git-prompt | tags: git zsh shell | updated: Fri, 09 May 2008 14:26:56 ]
This is my third post on the topic. I have harshly assimulated MadCoder's configuration. Here is my new zsh prompt:

show current git branch on zsh prompt (2)
[ link: zsh-git-branch2 | tags: git zsh shell | updated: Sat, 10 May 2008 08:25:24 ]
NOTE: This post has been updated (again).
I previously wrote about showing the git branch name on the zsh prompt. Caio Marcelo pointed out that
it didn't work very well because the git branch was being queried before the command was executed, and it should
be after to catch git commands that change the branch, like git branch and git checkout.
He was right, here is a repost.
screen -c relative path bug
[ link: screen-relative-path-bug | tags: screen bug zsh | updated: Mon, 07 Jan 2008 16:16:47 ]
I must have recently upgraded to a new screen. My screenrc file was using the chdir directive
so that the windows started inside would have a PWD I wanted them to. As soon as I tried
to reconnect the screen session would die.
screen -x
Unable to open "screenrc"
I was able to find the bug on savannah that described the symptom quite well.
I then wrote a wrapper zsh function which fixes the problem:
REAL_SCREEN=$(which screen)
# convert the path passed via the -c parameter to an absolute one
screen() {
local max=$((${#argv}-1))
for (( x=1 ; x<=$max ; x++ )) ; do
local flag="${argv[$x]}"
if [[ "x$flag" = "x-c" ]] ; then
local y=$(($x+1))
local word="${argv[$y]}"
if [[ "x${word[1]}" != 'x/' ]] ; then
argv[$y]="$PWD/$word"
fi
fi
done
echo ${REAL_SCREEN} ${1+"$argv"}
${REAL_SCREEN} ${1+"$@"}
}
show current git branch in zsh
[ link: zsh-git-branch | tags: git zsh shell | updated: Fri, 04 Apr 2008 11:26:24 ]
NOTE: This post has been updated.
Earlier today I saw a blog post titled "Git in your prompt"
which showed how to get the current git branch to display in zsh and bash. I tried it on my setup and found it really slow, probably due
having $HOME on NFS or having big git repos or maybe not enough ram.
Anyway, after looking at some zsh docs and blog posts, I had
added caching to the idea. Now the git-branch is only queried on a directory change or on a command that matches *git*.
zsh tip of the day - global aliases
[ link: zsh-global-alilases | tags: zsh | updated: Sun, 30 Sep 2007 11:04:02 ]
Most shells have aliases. Last week I started using a new (to me) feature in zsh aliases. Zsh lets you create arbitrary substitutions for the command line, not just the executable.
The simple example of a alias would create a new command that acts like another with some parameters added to it:
alias ll='ls -l'
You can also alias other common patterns in zsh. Say, you noticed that you used | tail -n10 a lot in your
shell. You can alias it like so:
alias -g TT10='| tail -n10"
history TT10
(10 lines follow)
You can also make this tail macro a bit more useful by not fixing it to use 10 lines:
alias -g TT='| tail -n'
history TT 10
(10 lines follow)
Of course you need to pick alias names that will not conflict with normal usage.
zsh tab completion awesomeness
[ link: zsh-tab-completion | tags: zsh shell | updated: Sat, 08 Sep 2007 12:17:22 ]
I have been using zsh for a few months. I love it. The best part of zsh is the tab completion.
Here are a few examples (note that you don't actually type in the <tab>):
forwarding ssh and X through screen
[ link: screen-with-ssh-and-x | tags: screen ssh desktop x zsh | updated: Thu, 18 Oct 2007 14:10:27 ]
I have an update to my previous article on forwarding ssh-agent
through screen. I've since switched to zsh and am now forwarding
the X DISPLAY environment variable through to the screen shell.
You can grab my ~/.zsh.d/S51_screen, ~/.zsh.d/S60_prompt, and ~/.screenrc or read below.
zsh fun
[ link: zsh-fun | tags: zsh shell | updated: Wed, 18 Apr 2007 16:03:16 ]
I have been playing with zsh a bit today. Here is the outcome:
use vim to view man pages; this requires manpageview.vim vim plugin.
function vman() { vim -c ":RMan ${*}" ; }these function store the current directory in X clipboard and then restore the path from the clipboard, which is handy when you want to restore the path in another xterm...
function xpwd () { pwd | xclip -i ; xclip -o ; } function xcd () { cd `xclip -o` ; }
vimgrep alias
[ link: vimgrep-alias | tags: vim shell zsh | updated: Wed, 18 Apr 2007 09:46:28 ]
I've been using Solaris recently... since yesterday. First reactions: How can anyone use their command line tools!?
Fortunately the system I was on had zsh and vim.
Here is a macro I use to avoid Solaris grep:
function vimgrep () { tmp="$@" ; vim -c "vimgrep $tmp | copen" ; }
(I could not figure out a way to do it w/o the tmp variable)
Now you can do things like:
vimgrep pattern 'dir/**/*.c'
