Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created March 4, 2014 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dagolden/9357216 to your computer and use it in GitHub Desktop.
Save dagolden/9357216 to your computer and use it in GitHub Desktop.
hack is a function
hack ()
{
local dir;
if [[ -d $1 ]]; then
dir=$1;
else
dir=$(perl -MPIR -wE 'my $iter=PIR->new->skip_vcs->directory->iname(shift)->iter("$ENV{HOME}/git"); say $iter->()' $1);
fi;
if [[ -n $dir && -d $dir ]]; then
tmux new-window -c $dir -n $(basename $dir);
else
if [[ -n $dir ]]; then
local shortest=$(perl -wE '($first)=sort{ length($a) <=> length($b) } @ARGV; say $first' $dir);
tmux new-window -c $shortest -n $(basename $shortest);
else
echo "$1 not found";
fi;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment