forked from Worldie-com/pen.el
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-interpreter-for-file
More file actions
executable file
·39 lines (34 loc) · 946 Bytes
/
get-interpreter-for-file
File metadata and controls
executable file
·39 lines (34 loc) · 946 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
export TTY # shopt -s nullglob # use for 'for' loops but not for 'ls', 'grep'
# This is based on the extension, which is not nice
last_arg="${@: -1}"
fp="$last_arg"
rp="$(realpath "$fp")"
dn="$(dirname "$rp")"
cd "$dn"
bn="$(basename "$fp")"
ext="${fp##*.}"
fn="${fp%.*}"
case "$ext" in
# hackett|hkt) { printf -- "%s\n" "$(which racket) -I hackett"; } ;;
hackett|hkt) { which racket; } ;;
rkt) { which racket; } ;;
hs) { which runhaskell; } ;;
R) { which Rscript ; } ;;
sh) { which sh ; } ;;
hy) { which hy3.6; } ;;
js) { which node || which nodejs; } ;;
rb) { which ruby; } ;;
wls) { which wolframscript; } ;;
scrbl) { which scribble; } ;;
py) {
ver="$(vermin "$fp")"
awk1 <<HEREDOC
python$ver
HEREDOC
} ;;
tcl) { which tclsh; } ;;
pl) { which perl; } ;;
sh) { which bash; } ;;
*) { notify-send "$0 : create an entry for $ext here"; }
esac