Created
November 4, 2011 07:21
-
-
Save frsyuki/1338843 to your computer and use it in GitHub Desktop.
individual bash history file for each `basename path` + screen window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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