DEV Community

Discussion on: My Favorite Bash Tips, Tricks, and Shortcuts

Collapse
 
aashutoshrathi profile image
Aashutosh Rathi

Hey! Would you like to add this sorcery at github.com/aashutoshrathi/awesome-...?

Collapse
 
vonheikemen profile image
Heiker

Sure. I'll do that.

I would like to mention that I got this from the oh-my-bash repo. They have a ton of interesting things there.

Thread Thread
 
loebkes profile image
Lui

You should really have a look at github.com/junegunn/fzf

This changed my life and how I work with the command line forever.

Thread Thread
 
vonheikemen profile image
Heiker

Oh I know about fzf, I use it extensively inside vim (I would be lost without it). Sadly I don't have many use cases for it in my day to day.

But this reminds me of yet another thing you can do with bind. One can bind key sequence with a "macro", it's like simulating keystrokes.

I have these two.

# Alt + f 
bind '"\ef": "\C-e | fzf"'

# Alt + p
bind '"\ep": "\C-e | less"'
Enter fullscreen mode Exit fullscreen mode

Alt + f will append | fzf at the end of a command and Alt + p does the same but with less. This works by using the sequence \C-e (ctrl + e) which makes the cursor go to the end of the line and basically typing the rest for you.