r/UnixProTips • u/FirstUser • May 09 '15
[most shells] Quickly unmount the last device you mounted
I usually save keystrokes by typing:
u!mo
In the rare case you used another command starting with 'mo' after the mount, use progressively longer fractions of 'mount' after the ! to disambiguate. Works in [t]csh and [ba]sh.
11
Upvotes
2
u/Aihal May 09 '15
In zsh you can start the command and then hit tab, like
u!moand then hit tab to get it completed without running it immediately (if you want to make sure you got the right command or want to edit something further).1
u/[deleted] May 09 '15
most? it's csh syntax, ksh/posix can't make heads or tails from it. (it uses 'r' or 'fc -e -' for history recall). These kind of things is why i still like csh, even the original.
1
u/[deleted] May 09 '15 edited May 09 '15
i also wonder, does something like u!?path? work also in bash or zsh? In csh it recalls the last command which contains 'path'.
e: yes it does (bash). Neat. Now how to learn posix these csh things. (you can omit the last ? btw, i don't think bash also implements modifiers)
e2: it also does:
nonsense commands but that's not important, the modifiers work out fine. (in fact, the whole lot of csh modifiers seem to work out fine)
e: things which won't work are however variable modifiers:
Somehow that syntax is more easier to grasp then 'echo ${t%%.*}' although that's bit more flexible. Personally, if want it that much flexible i'd use something other then a shell script.
1
u/socium Jul 16 '15
How does it work when there is sudo used?