-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbashrc
More file actions
56 lines (53 loc) · 1.3 KB
/
bashrc
File metadata and controls
56 lines (53 loc) · 1.3 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
#put this script into your .bashrc/.profile/xxx
# --> fcd
alias cs='pcs() { cd `cat ~/.fastcd.pwd` && ls -l; }; pcs '
alias csm='echo `pwd`" [path]" > ~/.fastcd.pwd'
alias fcd=pfastcd
pfastcd() {
app=`echo ~`"/tools/fcd.app"
conf=`echo ~`"/.fastcd"
tmpf=`echo ~`"/.fastcd.tmp"
pwdf=`echo ~`"/.fastcd.pwd"
vimf=`echo ~`"/.fastcd.vim"
if [ $# -lt 1 ] ;
then
echo ". [path]" > $pwdf ; $app ;
res=(`cat $pwdf | grep "path" | wc -l`)
if [ $res -eq 1 ];then cd `cat $pwdf`;
else
str=`cat $pwdf`; file=`echo ${str##*/}`; path=`echo ${str%$file}`;
echo "$path [path]" > $pwdf; vim $str;
fi
return 0;
fi
case $1 in
"l" | "ls" | "list" | "p" | "h" | "-" | "-"* )
$app $@
;;
"flash")
$app $@ > $conf
;;
[1-9] | [1-9][0-9]*)
$app p $1 > $pwdf && cd `cat $pwdf`;
;;
*)
grep -n $1 $conf | grep "\[path\]" > $tmpf
if [ $# -eq 2 ];then
cd `head -n $2 $tmpf | tail -n +$2 | awk -F: '{print $2}' | awk '{print $1}'`
else
line_index=1
cat $tmpf | while read line ; do
echo -e "\033[33m $line [$line_index] \033[0m" ;
let "line_index = $line_index + 1"
done;
res=(`wc -l $tmpf`)
echo -e "\033[33m ========$res matched======== \033[0m"
if [ $res -eq 1 ] ; then
cd `awk -F: '{print $2}' $tmpf | awk '{print $1}'` ;
fi
fi
return 0;
;;
esac
};
# <-- fcd