-
Notifications
You must be signed in to change notification settings - Fork 0
/
e
executable file
·58 lines (50 loc) · 1.28 KB
/
e
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
#!/usr/bin/env bash
# example command
# vim $(cat /tmp/$TMUX_PANE-stack/item.1)
function editOneFile(){
if [ -e /tmp/$TMUX_PANE-stack/item.$@ ]
then
filename=$(cat /tmp/$TMUX_PANE-stack/item.$1)
# if filename has + i.e. line number
if [[ $filename == *"+"* ]]
then
# adds a space between file name and the line number
file=${filename/+/ +}
vim $file
else
vim $filename
fi
else
echo entry $@ does not exist
fi
}
if [[ $1 == *"-"* ]]
then
fileRange=($(echo "$1" | tr '-' '\n'))
st=${fileRange[0]}
en=${fileRange[1]}
#echo $st
#echo $en
for fileNum in $(seq $st $en)
do
# pause after 5 files
offset=$(($fileNum - $st))
if [[ $(($offset % 5)) == 0 ]] && [[ $fileNum != $st ]]
then
echo -n 'Press any key to continue and "q" to quit : '
read -n1 ans
if [[ $ans == 'q' ]] || [[ $ans == 'Q' ]]
then
echo
echo 'exiting'
exit -1
fi
fi
#echo $fileNum
# edit one file
editOneFile $fileNum
done
else
# no range exist, opening single file
editOneFile $1
fi