-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickcmd.sh
More file actions
executable file
·62 lines (55 loc) · 1.58 KB
/
quickcmd.sh
File metadata and controls
executable file
·62 lines (55 loc) · 1.58 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
qc_script_path=$(cd "$(dirname "$0")" || exit; pwd)
qc_python_script="$qc_script_path/src/quickcmd.py"
if [ ! -e "$qc_python_script" ]; then
qc_script_path=$(readlink "$0")
qc_python_script="$qc_script_path/src/quickcmd.py"
fi
qc_echo()
{
msg=$1
if [ -t 1 ]; then
echo -e "\033[35m${msg}\033[0m"
else
echo ${msg}
fi
}
qc()
{
#setopt localoptions noautonamedirs
# do quickcmd
if [ -e "$qc_python_script" ]; then
if [ -x "$(which python 2> /dev/null)" ]; then
python "$qc_python_script" "$@"
elif [ -x "$(which python3 2> /dev/null)" ]; then
python3 "$qc_python_script" "$@"
elif [ -x "$(which python2 2> /dev/null)" ]; then
python2 "$qc_python_script" "$@"
elif [ -x "/usr/bin/python" ]; then
/usr/bin/python "$qc_python_script" "$@"
elif [ -x "/usr/bin/python3" ]; then
/usr/bin/python3 "$qc_python_script" "$@"
elif [ -x "/usr/bin/python2" ]; then
/usr/bin/python2 "$qc_python_script" "$@"
else
qc_echo "Error: not found python"
return 1
fi
else
qc_echo "Error: not found quickcmd.py"
return 1
fi
ret=$?
if [ $ret -ne 0 ]; then
qc_echo "quickcmd error. Try \`quickcmd --help\` for more information."
return $ret
fi
# do cd cmd
qc_cd_file="$qc_script_path/.qc.cd.path"
if [ -f "$qc_cd_file" ]; then
cd_path=$(cat "$qc_cd_file")
# qc_echo "cd $cd_path"
cd "$cd_path"
rm -f "$qc_cd_file"
fi
}