4 ms·
Command line globbing! For the uninitiated: Let's say my pwd is `/home/projects` and i want to edit `/home/projects/a_huge_sprawling_app/940j_394/lol/flight_co
by vectorpush 13y ago
Command line globbing! For the uninitiated:
Let's say my pwd is `/home/projects` and i want to edit `/home/projects/a_huge_sprawling_app/940j_394/lol/flight_controller.rb`
`vim **/flight_controller.rb`
opens our flight_controller.rb straight away. In terms of effort, this allows you to basically omit a `find -name` when you're in a rush to edit some damn file where the hell is it again damn we need to reevaluate this directory str...
----
Double bang to re-use your last terminal entry. One great use, taking all the pain out of forgetting your sudos
`rm -rf /var/log`
rm: cannot remove `/var/log': Permission denied
`sudo !!`
All evidence of wrongdoing is now destroyed.
-----
Ok, here is an awesome one for users of the ultimate cloud IDE: Vim.
In your local ~/.ssh/config:
`ForwardX11 yes`
`SendEnv WINDOWID`
In your remote server's /etc/ssh/sshd_config:
`AcceptEnv WINDOWID`
In your vimrc:
`set clipboard=unnamedplus`
This has the effect of seamless yank and paste between local and remote vim sessions, no need for ctrl+shift+v.
I love linux.
- ilikepi 13y agoFWIW, the double-star recursive globbing was added in Bash 4.0. My reading of the manual[1] suggests it is disabled by default, and can be enabled by setting the 'globstar' shell option. I believe it's enabled by default in zsh. [1]: https://www.gnu.org/software/bash/manual/bash.html#The-Shopt-Builtin https://www.gnu.org/software/bash/manual/bash.html#The-Shopt...
- vectorpush 13y agoThanks. Sometimes I forget that zsh is not what everyone uses. I should add zsh to the list, hah!
- Typhon 13y agoI just tried it on bash 4.2.25, and it worked, even though I just learned about it. Maybe not every OS enables the same default options for Bash (I'm using Lubuntu 12.10 at the moment)
- ilikepi 13y agoYep, that is a fair point. I should have qualified my statement about bash's defaults, since many OSs include their own custom start-up files that may modify the defaults.
- parennoob 13y agoRe: command line globbing with globstar -- is there some way to get it to cache filepaths that are frequently accessed? It's quite slow for me (I usually use aliases for that, which I was contemplating getting rid of). Thanks a lot for wising me up to the new hotness offered by bash 4+ (zsh is also pretty slow for me for some reason, even though people keep telling me to switch to that. Maybe I'm more impatient than most folks).
- vectorpush 13y agoSorry for the late reply. No built in way to cache globbed filepaths as far as I know. I did a little googling but to no avail. I suspect it wouldn't be too complicated to hack something together though. Another potential option: buy an SSD.
- deleted 13y ago[deleted]