Last active
September 11, 2015 22:44
-
-
Save davidhq/f37ac87bc77f27c5027e 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
# Example: | |
# | |
# $ find . | grep core_ext | |
# ./config/initializers/core_ext.rb | |
# ./spec/lib/core_ext_spec.rb | |
# | |
# $ grab 2 | |
# ./spec/lib/core_ext_spec.rb ===> (also copied on clipboard) | |
# | |
# Without arguments the default is to grab the first line | |
grab() { | |
local num=1 | |
if [ -n "$1" ]; then | |
num=$1 | |
fi | |
local line=`$(history | tail -2 | head -1 | cut -d" " -f4-) | sed "${num}q;d"` | |
echo $line | |
echo $line | tr -d "\n" | pbcopy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment