Compare commits

...

3 Commits

Author SHA1 Message Date
The Magician 631729fe09 Add script to add new scripts 2023-11-21 11:57:53 +00:00
The Magician 4d7fe9779f Add script to invoke random editor 2023-11-21 11:55:39 +00:00
The Magician c2cba29bb1 Quote "$PATH" 2023-11-21 11:54:42 +00:00
3 changed files with 44 additions and 1 deletions

20
e Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
editors=""
for editor in ed nex nvi vim; do
if command -v "$editor" >/dev/null; then
if test -z "$editors"; then
editors="$editor"
else
editors="$editors\n$editor"
fi
fi
done
random_editor="$(echo "$editors" | shuf | head -n 1)"
$random_editor "$@"

23
nx Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -e
error() {
echo "$@" 1>&2
exit 1
}
test ! -d "$HOME/code/scripts" && error "No $HOME/code/scripts/ directory found"
test -z "$1" && error "No script name given"
test -f "$1" && error "$1 already exists"
fullpath="$HOME/code/scripts/$1"
touch "$fullpath" && chmod +x "$fullpath"
test -n "$EDITOR" && $EDITOR "$fullpath"
test -n "$VISUAL" && $VISUAL "$fullpath"
if command -v vi 1>/dev/null; then
vi "$fullpath"
else
error "No editor program found (set \$EDITOR or \$VISUAL, or install \`vi\`)"
fi

2
path
View File

@ -1,3 +1,3 @@
#!/bin/sh
echo $PATH | tr ':' '\n'
echo "$PATH" | tr ':' '\n'