aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/qedit
blob: 44cfa18b2367d32c4e712efc65322430cd4c5ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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