Generates a temp file (with your choice of extension) which you can then write code in immediately.
26 lines
333 B
Bash
Executable File
26 lines
333 B
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
if [ $# -eq 0 ] || [ $# -gt 2 ]
|
|
then
|
|
printf "Usage: $0 <extension> [editor]\n"
|
|
exit 1
|
|
fi
|
|
|
|
name=$(mktemp --suffix=".$1")
|
|
editor=""
|
|
|
|
if [ $# -eq 1 ]
|
|
then
|
|
if [ -z "$EDITOR" ]
|
|
then
|
|
editor="vim";
|
|
else
|
|
editor="$EDITOR";
|
|
fi
|
|
elif [ $# -eq 2 ]
|
|
then
|
|
editor="$2"
|
|
fi
|
|
|
|
$editor $name
|