Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Forked from dagolden/nopaste
Last active August 29, 2015 13:57
Show Gist options
  • Save ingydotnet/9357234 to your computer and use it in GitHub Desktop.
Save ingydotnet/9357234 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" -a -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