#!/usr/bin/env nash # Simple init script for you base your own # For a more complete and organized .nash see: # https://github.com/tiago4orion/dotnash # PROMPT is a special variable used by nash command line to # setup your prompt. var RED = "" var GREEN = "" var RESET = "" var PROMPTSYM = "λ> " var DEFPROMPT = $RED+$PROMPTSYM+$RESET setenv PROMPT = $DEFPROMPT # cd overrides built-in cd # Add the current branch before prompt (if current directory is a git repo) fn cd(path) { var branch = "" var prompt = "" if $path == "" { path = $HOME } chdir($path) var _, status <= test -d ./.git if $status != "0" { prompt = $DEFPROMPT } else { branch <= git rev-parse --abbrev-ref HEAD | xargs echo -n prompt = "("+$GREEN+$branch+$RESET+")"+$DEFPROMPT } setenv PROMPT = $prompt } bindfn cd cd # syntax sugar to cd into go project fn gocd(path) { cd $GOPATH+"/src/"+$path } bindfn gocd gocd