Posts Tagged ‘bash’

Simple Shell Trick

Sunday, April 19th, 2009 by atz

Here’s a file I use to get myself into the correct environment for a given Koha installation. I create one of these for each Koha I’m using or testing, then just source the file into my shell to put myself in the right directory, with the right ENV variables set.

#!/bin/bash
#
# source this file, e.g.:
# . ./standard_export.sh
export KOHA_CONF=/home/atz/koha/etc/etc/koha-conf.xml
export KOHA_LOG=/home/atz/koha/log/production-intranet-error_log
export OPAC_LOG=/home/atz/koha/log/production-opac-error_log
export PERL5LIB=/home/atz/koha/production/koha
echo KOHA_LOG  = $KOHA_LOG
echo OPAC_LOG  = $OPAC_LOG
echo KOHA_CONF = $KOHA_CONF
echo PERL5LIB  = $PERL5LIB
cd $PERL5LIB

Simple Git Trick for Bash

Friday, April 10th, 2009 by atz

Chris Cormack shared this useful trick for keeping track of what git repo you are currently using/editing. Stick it in your .bash_profile to have your prompt adapt to the repo you are in!

function parse_git_branch {
  ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
  echo "("${ref#refs/heads/}")"
}
RED    ="\[\033[0;31m\]"
YELLOW ="\[\033[0;33m\]"
GREEN  ="\[\033[0;32m\]"
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ "