-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsfile.sh
executable file
·133 lines (132 loc) · 4.12 KB
/
lsfile.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/zsh
if [ -z $1 ]
then
cd ~
else
cd $1
fi
echo "\e[?1049h"
COPYIED_FILE=" "
GREEN="\e[32m"
C_DEFAULT="\e[0m"
green() {
echo "\e[32m$1\e[0m"
}
while true
do
echo "\e[32m-----------------"
echo "'lsfile' File Lookup"
echo "$(pwd)"
echo "Clipboard: ${COPYIED_FILE}\e[0m"
ls -AGF
echo
while true
do
echo -n "\e[32m:\e[0m"
read operation
if [ ${operation} = "//q" ] ;then
echo "\e[?1049l"
exit
fi
if [[ ${operation} == "//"* ]];then
command=${operation:2}
#operation
###########################################
case "${command}" in
"finder"*)
#open in finder
if [ ${command} = "finder" ]
then
open ./
else
open -R ${command:6}
fi
;;
"copy "*)
#copy a path
COPYIED_FILE=$(realpath ${command:5})
break
;;
"clear_clipbd")
#clear clipboard
COPYIED_FILE=" "
;;
"reload")
break
;;
"linkdown")
if [ ${COPYIED_FILE} = " " ];then
green "Clipboard is empty"
else
if [[ ${COPYIED_FILE} == "."* ]] || [[ ${COPYIED_FILE} == "~"* ]];then
green "'ln' don't support ./ or ~/"
else
ln -s ${COPYIED_FILE} ./$(basename ${COPYIED_FILE})
break
fi
fi
;;
"linkdown "*)
if [ ${COPYIED_FILE} = " " ];then
green "Clipboard is empty"
else
if [[ ${COPYIED_FILE} == "."* ]] || [[ ${COPYIED_FILE} == "~"* ]];then
green "'ln' don't support ./ or ~/"
else
ln -s ${COPYIED_FILE} ${command:9}
break;
fi
fi
;;
"sh "*)
zsh -c ${command:3}
;;
"rm "*)
echo -n "${GREEN}Will delete '${command:3}' permanently. Really want to remove it? [Y/any other key] ${C_DEFALUT}"
read answer
if [ ${answer} = "Y" ];then
if [ -d ${command:3} ];then
rm -r ${command:3}
else
rm ${command:3}
fi
fi
unset answer
break
;;
"paste")
if [ ${COPYIED_FILE} = " " ];then
green "Clipboard is empty"
else
if [ -d ${COPYIED_FILE} ];then
copy -R ${COPYIED_FILE} $(basename ${COPYIED_FILE})
else
copy ${COPYIED_FILE} $(basename ${COPYIED_FILE})
fi
fi
;;
"paste "*)
if [ ${COPYIED_FILE} = " " ];then
green "Clipboard is empty"
else
if [ -d ${COPYIED_FILE} ];then
copy -R ${COPYIED_FILE} ${command:6}
else
copy ${COPYIED_FILE} ${command:6}
fi
fi
;;
*)
green "Command not support: '${command}'"
;;
esac
###########################################
else
cd ${operation}
if [ $? = 0 ];then
break
fi
fi
clear
done
done