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.
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*.
comparing two directories
[ link: comparing-two-directories | tags: shell linux | updated: Thu, 13 Sep 2007 14:07:51 ]
In one of the project I am working on we have the build environment tarred up and stored in tgz files and committed in SVN. To avoid updating the same 300M tarball we decided to added incremental tarballs each time that we add new software to the build environment. But that's not the important bit...
I wanted to figure out what software was installed since the last tarballs were extracted. To do this I need to compare two directories and create a new tarball with all the new files. How do you diff two directories pro grammatically?
I came up with this...
cp -ax orig-dir new-dir
... do whatever in new-dir ...
diff -u <(find orig-dir -printf "%p %t\n" | cut -d / -f 2-) \
<(find new-dir -printf "%p %t\n" | cut -d / -f 2-) \
| grep -v '^[+-]'
And then I found out that I can do it with rsync...
rsync -a orig-dir/ new-dir/
... do whatever in new-dir ...
rsync -av --dry-run orig-dir/ new-dir/
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>):
less, colourful
[ link: less-colours | tags: linux shell | updated: Sun, 22 Jul 2007 00:29:10 ]
Make your less more pretty with these environment variables...
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
You can put these in your .zshrc or .bashrc.
urxvt mouseless url yanking
[ link: urxvt-url-yank | tags: urxvt shell desktop | updated: Thu, 10 Jan 2008 09:18:54 ]
In the quest for a completely mouse free desktop, I wanted to be able to yank URLs from the termial without using the mouse. This happens often enough in IRC when I would want to grab the most recent URL and run it in firefox.
I talked to the author of vimperator and he suggested that I look at urxvt (packaged as rxvt-unicode). So I did.
A few hours later and I have a perl plug-in for urxvt that does just want I wanted.
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` ; }
pipe to pastey.net
[ link: pipe-to-pastey.net | tags: shell mouse-free | updated: Wed, 18 Apr 2007 14:37:44 ]
Here is a little script that lets me post to pastey.net from a shell prompt
#!/bin/bash
set -e
AUTHOR=bartman
SUBJECT=pipe
LANGUAGE=c
w3m -post <( echo -n -e "language=$LANGUAGE&author=$AUTHOR&subject=$SUBJECT&tabstop=4&text=" ; sed 's/%/%25/g' | sed 's/&/%26/g' ) \
-dump http://pastey.net/submit.php
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'
