-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathfloaterm
executable file
·31 lines (28 loc) · 1.08 KB
/
floaterm
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
#!/bin/sh
absolute_path() {
local result=""
if [ -x "$(which realpath 2> /dev/null)" ]; then
result="$(realpath -s """$1""" 2> /dev/null)"
fi
if [ -z "$result" ] && [ -x "$(which perl 2> /dev/null)" ]; then
result="$(perl -MCwd -e 'print Cwd::realpath($ARGV[0])' """$1""")"
fi
if [ -z "$result" ] && [ -x "$(which python 2> /dev/null)" ]; then
result="$(python -c 'import sys, os;sys.stdout.write(os.path.abspath(sys.argv[1]))' """$1""")"
fi
if [ -z "$result" ] && [ -x "$(which python3 2> /dev/null)" ]; then
result="$(python3 -c 'import sys, os;sys.stdout.write(os.path.abspath(sys.argv[1]))' """$1""")"
fi
if [ -z "$result" ] && [ -x "$(which python2 2> /dev/null)" ]; then
result="$(python2 -c 'import sys, os;sys.stdout.write(os.path.abspath(sys.argv[1]))' """$1""")"
fi
if [ -z "$result" ] && [ -x "$(which realpath 2> /dev/null)" ]; then
result="$(realpath """$1""")"
fi
if [ -z "$result" ]; then
result="$1"
fi
echo $result
}
name="$(absolute_path """$1""")"
eval $FLOATERM $name