Skip to content

Instantly share code, notes, and snippets.

@yonchu
Created November 19, 2012 12:55
Show Gist options
  • Save yonchu/4110493 to your computer and use it in GitHub Desktop.
Save yonchu/4110493 to your computer and use it in GitHub Desktop.
$vim `which command` を手軽に
#!/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