Created
November 19, 2012 12:55
-
-
Save yonchu/4110493 to your computer and use it in GitHub Desktop.
$vim `which command` を手軽に
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
#!/bin/sh | |
# | |
# Edit command source | |
# | |
if [ $# -lt 1 ]; then | |
echo 'Should specify commands you want to edit' 1>&2 | |
exit 1 | |
fi | |
cmds=() | |
while [ $# -gt 0 ]; do | |
cmds+=($(which "$1" 2> /dev/null)) | |
[ $? -ne 0 ] && echo "Command not found: $1" 1>&2 | |
shift | |
done | |
if [ ${#cmds[@]} -lt 1 ]; then | |
exit 1 | |
fi | |
exec ${EDITOR:-vim} "${cmds[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment