Posts for: #Shell

show current git branch on zsh prompt (2)

NOTE: This post has been [updated]{zsh-git-prompt} (again).

I previously wrote about [showing the git branch name on the zsh prompt]{zsh-git-branch}. 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.

Read more →

show current git branch in zsh

NOTE: This post has been [updated]{zsh-git-branch2}.

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*.

Read more →

comparing two directories

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?

Read more →

zsh tab completion awesomeness

I have been using [zsh]{tag/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>):

Read more →

less, colourful

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.

Read more →

urxvt mouseless url yanking

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.

Read more →

zsh fun

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` ; }
    
Read more →

pipe to pastey.net

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
Read more →

vimgrep alias

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:

Read more →