Skip to content

Commit c409df8

Browse files
committed
- use "~" instead of "$HOME"
- use mount to list devices for remountmenu instead of lsblk - change history menu display - add white background to menu title
1 parent 905dcb5 commit c409df8

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

mnttools/mnttools

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
COMMENT
1717

18-
version="mnttools v0.4.1"
19-
blue='\e[0;34m'; green='\e[0;32m'; red='\e[0;31m'; yellow='\e[0;33m'; bold='\e[1m';none='\e[0m'
18+
version="mnttools v0.4.2"
19+
blue='\e[1;34m\e[47m'; green='\e[0;32m'; red='\e[0;31m'; yellow='\e[0;33m'; bold='\e[1m';none='\e[0m'
2020
function menu {
2121
n=0
2222
choices=("$@")
23-
echo -e "$blue$bold$version - $menutitle"
23+
echo -e "$blue$version - $menutitle$none"
2424
for i in "${choices[@]}"; do
2525
echo -e "$none$((n++))) $yellow$i"
2626
done
@@ -231,11 +231,10 @@ function smbbrowse {
231231
}
232232

233233
function histmenu {
234-
IFS=$'\n'
235-
recent=(`cat "$history_file" 2>/dev/null`)
234+
recent=(`cat "$history_file" | cut -d'|' -f1`)
236235
menutitle="Mount History"
237236
menu ${recent[@]} "Edit history" "Main Menu"
238-
IFS=$oIFS
237+
l=$(($?+1))
239238
case $choice in
240239
Main*) mainmenu ;;
241240
Edit*)
@@ -247,16 +246,12 @@ function histmenu {
247246
fi
248247
histmenu ;;
249248
*)
250-
fs=; mntopts=; DEVNAME=; mntpoint=
251-
IFS='|'; n=0
252-
for i in $choice; do
253-
[[ $i = -t* ]] && fs=$i
254-
[[ $i = -o* ]] && mntopts=$i
255-
[[ $n -eq 0 ]] && DEVNAME=$i
256-
[[ $n -eq 1 ]] && mntpoint=$i
257-
((n++))
258-
done
259-
IFS=$oIFS
249+
unset fs mntopts DEVNAME mntpoint
250+
data=`grep -n $choice "$history_file" | grep ^$l:`
251+
DEVNAME=$choice
252+
mntpoint=`echo $data | cut -d'|' -f2`
253+
fs=`echo $data | cut -d'|' -f3`
254+
mntopts=`echo $data | cut -d'|' -f4`
260255
_mount ;;
261256
esac
262257
}
@@ -281,7 +276,7 @@ function mainmenu {
281276
*NFS) nfsmenu ;;
282277
*history) histmenu ;;
283278
Unmount) unmountmenu ;;
284-
*conkyfc) modconkyrc removeall ;;
279+
*conkyrc) modconkyrc removeall ;;
285280
Remount*) remountmenu ;;
286281
esac
287282
}
@@ -318,12 +313,12 @@ function remountmenu {
318313
eval "`lsblk -P -o NAME,MOUNTPOINT | grep ${1##*/}`"
319314
else
320315
IFS=$'\n'
321-
d=(`lsblk -P -o NAME,MOUNTPOINT | grep $mntroot`)
316+
d=(`mount | grep $mntroot | cut -d' ' -f1-3`)
322317
menutitle="Remount Device Menu"
323318
menu ${d[@]} "Main Menu"
324319
IFS=$oIFS
325320
if [[ $choice = "Main Menu" ]]; then mainmenu; return; fi
326-
eval "$choice"
321+
eval "`lsblk -P -o NAME,MOUNTPOINT ${choice[0]}`"
327322
fi
328323
unmount "$MOUNTPOINT"
329324
sleep 1
@@ -441,13 +436,13 @@ oIFS=$IFS
441436
if [[ $1 = --config ]]; then
442437
cfg=$2; action=$3
443438
fi
444-
[[ -f ${cfg:=$HOME/.mnttools} ]] && source "$cfg"
439+
[[ -f ${cfg:=~/.mnttools} ]] && source "$cfg"
445440
gid=`cat /etc/group | grep ^users: | cut -d':' -f3`
446441
[[ $USER && $USER != root ]] && runasroot=sudo
447442
run=yes
448443
mntroot=${mntroot:=/media}
449444
save_history=${save_history:=true}
450-
history_file=${history_file:=$HOME/.mnttools_history}
445+
history_file=${history_file:=~/.mnttools_history}
451446
general_mntopts=${general_mntopts:=noatime}
452447
winfs_mntopts=${winfs_mntopts:=gid=$gid,umask=002,flush}
453448
sshfs_mntopts=${sshfs_mntopts:=reconnect,compression=yes,workaround=rename,gid=$gid,umask=002}

0 commit comments

Comments
 (0)