Live data from Hacker News

Mastering Bash and Terminal

blockloop.io

61–70 of 186 posts

Re: Mastering Bash and Terminal

#61
post #57

About bindings, it would have been better to redirect to: LESS=+/"DEFAULT KEY BINDINGS" man readline assuming it exists on mac. About suspend, what's the benefit of suspending vim using C-z? Shouldn't you use a terminal multiplexer instead, or even terminal tabs if you don't want to learn how to use tmux or screen (which I find weird if you already spent time to learn how to use vim but alright)? I only ever suspend…

I use tmux. The benefit of using suspend is not having to move around multiple windows/tabs. I try to keep those to a minimum (usually one or two). With suspend I can stick with the same tmux window for editing and cli within the same context. It's a personal preference over managing multiple windows.

To stay on the same window I would personally use a split-window depending on the size of the display. I didn't think about the context though, good point!

Re: Mastering Bash and Terminal

#62

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

God, I really need to learn more of these little tricks. I've been using Vim for a while now, but not taking advantage of so many of it's features.

Re: Mastering Bash and Terminal

#63

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

God, I really need to learn more of these little tricks. I've been using Vim for a while now, but not taking advantage of so many of it's features.

I personally still prefer to background the process. Rarely is it ever just 1 command you want to run. For example, you want to git commit, push, oops need to rebase, oops don't have all of my files added... etc etc.

For that reason I just jump out with a ctrl+z and when I'm done I'm back in with a fg!

Re: Mastering Bash and Terminal

#64
post #27

Earlier quoted context omitted.

I didn't know about :r in combination with !. That's neat. I typically use :r for reading a file into the current buffer (instead of cp ). Thanks for sharing. I don't find myself using ! commands when I know there are multiple commands that I need to run (like your last example). That's usually when I'll suspend and then use the command line. Could you elaborate on "wreak havoc on your vim session?" I wasn't aware th…

> I didn't know about :r in combination with ! You can even use :w in combination with !. For example :w !xclip to write the vim buffer contents to the clipboard. You could visually highlight part of the buffer and do the same thing for just the text you want.

for osx peeps: `:w !pbcopy`

Re: Mastering Bash and Terminal

#65
post #26

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

Regarding the last git command you listed, I actually find it better to do :r !git status -v And at the to of the result, type my formatted git commit message, visually highlight the message I just typed, and then use the following vim command :r !git commit -F - Which reads the commit message from standard input.

That's interesting, why not just do `git commit` at the command line?

Re: Mastering Bash and Terminal

#67

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

Hmm, I always used :.!ls instead of :r!ls...

Is there a difference?

Re: Mastering Bash and Terminal

#68
I also assume you're using bash. I know there are some cool newcomers out there like zsh and fish

While there is much useful in this post, I always find comments like this one odd. bash was released back in 1989, zsh was released one year later, in 1990. One year difference in age almost thirty years ago means that you can't really call zsh a newcomer. Maybe he's talking about adoption, though.

Re: Mastering Bash and Terminal

#70

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

Hmm, I always used :.!ls instead of :r!ls... Is there a difference?

:.!ls means "filter the current line through ls". Since ls ignores stdin, the effect is that the current line gets replaced by its output. :r!ls just inserts the output, without replacing anything.
Post reply on HN