Last active
August 16, 2018 18:21
-
-
Save RaghavRao/a08146cbc37ac246f6428e7c6b54d3c7 to your computer and use it in GitHub Desktop.
Create a new script by executing "which".
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/bash | |
# Append to ~/.bashrc | |
# Usage: | |
# Default editor from /etc/alternatives/editor: $ nf python ~/scripy.py | |
# Custom editor: $ nf python ~/script.py vi | |
nf() { | |
STR=$( echo "#!"`which "$1"` ) | |
if [ ! -f "$2" ]; then | |
echo $STR > "$2" | |
echo "" >> "$2" | |
if [ -z ${3+x} ]; then EDT="/etc/alternatives/editor +2"; else EDT="$3 +2"; fi | |
$EDT "$2" | |
chmod +x "$2" | |
else | |
echo "File already exists!" | |
fi | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment