dotfiles/bin/open-editor

22 lines
458 B
Plaintext
Raw Normal View History

#!/bin/env bash
VSCODE_PATH=$(command -v code)
NANO_PATH=$(command -v nano)
VI_PATH=$(command -v vi)
if [[ $2 == "--use-nano" ]]; then
nano $1
elif [[ $2 == "--use-code" ]]; then
vscode --wait $1
elif [[ $2 == "" ]] && [[ $1 != "" ]]; then
if [[ $VSCODE_PATH != "" ]]; then
code --wait $1
elif [[ $NANO_PATH != "" ]]; then
nano $1
else
vi $1
fi
else
echo "Usage: $0 </path/to/file> [--use-nano|code]"
fi