Created
March 4, 2014 22:35
-
-
Save dagolden/9357216 to your computer and use it in GitHub Desktop.
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
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