Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (29 sloc) 581 Bytes
#!/bin/bash
help() {
echo 'usage: vimx [params] file'
echo
echo ' create and edit executable bash script'
echo ' that has a --help command'
echo
exit 1
}
[ "$1" == "--help" ] && help
set -e
# file must be the last parameter
# http://brian.pontarelli.com/2007/11/27/the-last-positional-parameter-in-bash/
eval "thefile=\${$#}"
if [ ! -e "$thefile" ]; then
vim -c "0,0i
#!/bin/bash
help() {
echo 'usage: $thefile'
echo ' $thefile --help'
echo
exit 1
}
[ \"\$1\" == \"--help\" ] && help
" "$@"
chmod +x $thefile
else
vim "$@"
fi