Skip to content

Instantly share code, notes, and snippets.

@frsyuki
Created November 4, 2011 07:21
Show Gist options
  • Save frsyuki/1338843 to your computer and use it in GitHub Desktop.
Save frsyuki/1338843 to your computer and use it in GitHub Desktop.
individual bash history file for each `basename path` + screen window
if [ -n "$PROJECT" ];then
if [ -n "$WINDOW" ];then
export HISTFILE="$HOME/.bash_history.d/$PROJECT.$WINDOW"
else
export HISTFILE="$HOME/.bash_history.d/$PROJECT"
fi
if [ ! -f "$HISTFILE" ];then
cp "$HOME/.bash_history" "$HISTFILE"
fi
fi
function p() {
if [ -z "$1" -o -n "$2" ];then
echo "usage: p <session name>" 1>&2
return 1
else
local proj
if [ "$1" == "." ];then
proj="$(pwd)"
else
proj="$1"
fi
local name="$(basename "$proj")"
export PROJECT="$name"
if [ -d "$proj" ];then
cd "$proj"
fi
screen -S "$name" -xRR
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment