Last active
June 26, 2019 23:56
-
-
Save jayers99/39bb45c1109e3b5c128479c89c7b0538 to your computer and use it in GitHub Desktop.
copy the last command to a file
This file contains 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
snipit() { | |
[ ! -z "${1}" ] && snip_file="${1}" || snip_file='snippets.sh' | |
echo "" >> $snip_file | |
read -p "Enter comment: " comment | |
[ ! -z "${comment}" ] && echo "# ${comment}" >> $snip_file | |
fc -ln -1 | sed '1s/^[[:space:]]*//' >> $snip_file | |
[ ! -z "${comment}" ] && tail -n 2 $snip_file || tail -n 1 $snip_file | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment