-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
open
executable file
·35 lines (32 loc) · 1.04 KB
/
open
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
#!/bin/sh
######################################################################
# @author : Gavin Jaeger-Freeborn ([email protected])
# @file : open.sh
# @created : Tue 21 Jan 2020 02:54:56 PM MST
#
# @description : Simple command for opening files in a cli setting
######################################################################
OPENER="xdg-open"
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
# define a custom 'open' command
# This command is called when current file is not a directory. You may want to
# use either file extensions and/or mime types here. Below uses an editor for
# text files and a file opener for the rest.
case $base in
*\.blend)
blender "$file"
;;
*\.xopp)
xournalpp "$file"
;;
esac
case $(file --mime-type "$*" -b) in
# follow symlinks
inode/symlink) $0 "$(readlink "$*")" && exit;;
# open text files with vim
text/*) ${EDITOR:-vi} "$*";;
*) for f in "$@"; do setsid "${OPENER}" "${f}" > /dev/null 2> /dev/null & done;;
esac
# vim: set tw=78 ts=2 et sw=2 sr: