-
-
Save palevell/42959a811b4326aaa0a3ca4f93ba58e1 to your computer and use it in GitHub Desktop.
Edit BASH shell script
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
#!/usr/bin/env bash | |
# edsh v1.4.27 - March 3, 2014 | |
_me="${0##*/}" | |
# Test for file name | |
[[ $# -ne 1 ]] && { echo -en "Usage:\t$_me command_name\n"; exit 1; } | |
_file=~/bin/$1 | |
# If needed, create a new command file | |
if [[ ! -e $_file ]]; then | |
_today="$(date '+%A, %B %-d, %Y')" | |
#_today=$(php -r 'echo date("M d, Y");') | |
echo -e "#!/usr/bin/env bash\n# ${_file##*/} v1.0.0 - $_today\n_me=\"\${0##*/}\"\n\n\n# Housekeeping\nunset _me" >$_file | |
chmod 700 $_file | |
fi | |
# Check for ~/Backups folder | |
[ ! -d ~/Backups ] && mkdir ~/Backups | |
[ -e "$1~" ] && mv "$1~" ~/Backups | |
# Edit the command file | |
nano -B -C ~/Backups -T 4 $_file | |
# Housekeeping | |
unset _me _file _today |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment