return to OCLUG Web Site
A Django site.
February 25, 2010

Bart Trojanowski
jukie
Bart's Blog
» pimped out zsh prompt

Here is yet another update to the series. I've updated my git prompt again, now using the zsh 4.3.7 built in vcs_info module. This time the motivation came from Zsh Prompt Magic article. Here is what it looks like now:

zsh git prompt

Everything is now self contained in one file: S60_prompt. Grab it and source it into your zsh config.

The features are:

  • name of current branch,
  • git repo state (rebase, am, bisect, merge, etc),
  • markers indicating staged/unstaged changes,
    • little 1 after branch name indicates dirty working tree,
    • little 2 after branch name indicates staged changes,
  • highlight depth decended into the repository on the right,
  • show failure of commands via prompt background change,
  • show command/insert mode when using vi mode (set -o vi).

[Read More]

January 16, 2010

Bart Trojanowski
jukie
Bart's Blog
» running really nice

Everyone that uses the shell eventually learns about nice -- the tool that runs a process at a reduced priority. Well, there is also ionice that allows you to tweak processes from taking over all disk IO.

I added a vnice() function into my ZSH config so I can run or mark processes for lower priority for both nice and ionice levels.

[Read More]

June 10, 2009

Bart Trojanowski
jukie
Bart's Blog
» how would you read a file into an array of lines

I was working on a shell script that needed to look at some lines in a bunch of files and perform some data mining. I started it in bash, so I am writing it in bash even though dave0 notes that I should have started in in perl. Point taken... I suffer for my mistake.

After a quick google I learned that a nice way to do what the topic of this post describes can be done using

    IFS='
    '
    declare -a foo=( $(cat $file) )

Which is great! Right?

[Read More]

June 9, 2009

Bart Trojanowski
jukie
Bart's Blog
» tiding up the PATH

I have previously noticed that loading up the list of application available in $PATH took a long time in wmii-lua. I recently found out that it was related to me having multiple duplicates in my zsh environment.

To clean this up I added the following to my zsh configuration:

    typeset -U path cdpath manpath fpath

This removes duplicates from the PATH, CDPATH, MANPATH, and FPATH environment variables.

Well, technically it removes duplicates from the path, cdpath, manpath, and fpath arrays; but these are treated special and updating them automatically generates their respective :-delimited environment variables.

Zsh rocks!

May 10, 2008

Bart Trojanowski
jukie
Bart's Blog
» show current git branch on zsh prompt (2)

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.

[Read More]

May 9, 2008

Bart Trojanowski
jukie
Bart's Blog
» show more git info on zsh prompt

This is my third post on the topic. I have harshly assimulated MadCoder's configuration. Here is my new zsh prompt:

zsh git prompt

[Read More]

March 21, 2008

Pythian
pythian
» Saying What You Mean

Ah, the perils of working in a shared, client environment. One client has us using a login that is not exclusive to us. I prefer using bash; the client is set to use zsh. This is not a problem in and of itself.

However, there is a section in the .profile that is causing me issues:

if [ -f /usr/bin/ksh ]; then
        /usr/bin/ksh -o vi
        exit
fi

So, “If ksh exists, run it with some options to edit history with vi-like commands”. Except what we really want is “If you’re using the ksh as a shell, . . . .”

So I added a modification, and now all is fine.

if [ -f /usr/bin/ksh ]; then
        if [ "$SHELL" = "/usr/bin/ksh" ]; then
                /usr/bin/ksh -o vi
                exit
        fi
fi

(not all my problems are MySQL related!)

January 7, 2008

Bart Trojanowski
jukie
Bart's Blog
» screen -c relative path bug

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+"$@"}
    }