Live data from Hacker News

Mastering Bash and Terminal

blockloop.io

101–110 of 186 posts

Re: Mastering Bash and Terminal

#101
> Now that we know we don't need the up and down arrow keys, what about the left and right? Unfortunately, these keys are still needed for single character movements

Don't ctrl-f and ctrl-b work?

Re: Mastering Bash and Terminal

#102
post #42

Earlier quoted context omitted.

I wasn't so much commenting on the release date when I said "newcomers." Mostly commenting on my personal experience. I've been using bash for a long time and only recently have I seen zsh get so popular. It's entirely possible that only the people I know have only recently taken an interest in it. I would have to run zsh again to remember the pieces that I didn't like. I might have been able to configure my way arou…

When I started using Unix in the early '90s, zsh was more popular than bash by a long way. And tcsh was more popular still. You had to be a GPL purist or something to want to use bash. Its success is really down to its status as the Linux default. If you try zsh again, you'll find the mailing list and IRC are full of helpful people if some things aren't as you expect.

Any ideas why tcsh was so popular and bash was considered oddball? A lot of the big old vfx houses I would work for came from Unix, so they still default everyone to tcsh. A lot of their tooling is based around it, so you're kind of required to use tcsh.

I like to come up with one-liners when doing stuff as a challenge and not being able to do a for-loop as a single line drove me nuts (keeping it one line is really useful when you're iterating over a command and using history). I also find subshells very handy in bash.

Re: Mastering Bash and Terminal

#103
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.

Though I understand that this is just an example of the power of `!r`, readers should know that VIM in fact can copy to the system clipboards natively.

    "*y
    "+y

Re: Mastering Bash and Terminal

#104
post #20

Earlier quoted context omitted.

I wasn't so much commenting on the release date when I said "newcomers." Mostly commenting on my personal experience. I've been using bash for a long time and only recently have I seen zsh get so popular. It's entirely possible that only the people I know have only recently taken an interest in it. I would have to run zsh again to remember the pieces that I didn't like. I might have been able to configure my way arou…

zsh was quite popular when I first went spelunking in *NIX-land (2005). oh-my-zsh, which was a decent boost to zsh popularity, seems to have been around since 2009 ( http://ohmyz.sh/ ). zsh has always been held back by the "default browser"-syndrome: Linux and Mac OS both come with "good enough" default shells, so few people actually want to go through the effort of switching. Especially since there is a bit of a lea…

The problem with installing zch on my desktop is that I won't have it on the servers I SSH into. I need to know the proper spells and incantations that will work on a wide variety of distros and versions, many of which I don't personally maintain. Therefore, bash.

Re: Mastering Bash and Terminal

#105
post #27

Earlier quoted context omitted.

> 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.

Though I understand that this is just an example of the power of `!r`, readers should know that VIM in fact can copy to the system clipboards natively. "*y "+y

Only if it's compiled with clipboard support. I don't know about in other places, but in the default Arch package it's not. So this command is a perfect solution for me.

Re: Mastering Bash and Terminal

#106
post #27

Earlier quoted context omitted.

> 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.

Though I understand that this is just an example of the power of `!r`, readers should know that VIM in fact can copy to the system clipboards natively. "*y "+y

That requires that vim be compiled with the xterm-clipboard feature enabled. On my Fedora 24 desktop, vim doesn't have it enabled, but gvim does (according to the output of the :version command).

One advantage of the method you describe is that it can be limited to just part of a line. Piping output to xclip is limited to complete lines of text due to the nature of :w !.

Re: Mastering Bash and Terminal

#107
I've tried bash, zsh, and fish. After trying all three, I'm staying with fish. bash and zsh don't have sensible defaults, and configuring them is tedious. fish works great out of the box, and it's really fast. When I picked up zsh I used oh-my-zsh and later prezto, but it was slow and figuring out what everything all the framework did was complicated.

With fish I have a setup.fish script that defines all my universal exports, for when I setup a new computer. This is for private tokens, like HOMEBREW_GITHUB_API_TOKEN. For aliases and utilities, I wrote a fisherman [0] plugin. It has a functions folder and a fishfile for the few other plugins I use.

[0] https://github.com/fisherman/fisherman

Re: Mastering Bash and Terminal

#108

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…

Interesting. Your use of `git commit -am` resounded with me. I can't stand doing `git add .` ; `git commit -m "message"`; `git push`. I aliased "commit" to "ci" in git-config, and then do `git ci -am "message" && git push`. I'm sure at some point I will add a hook to have the push done automatically (though sometimes I prefer to do it manually, so I will have to make a decision.) I am an avid emacs user though. I rea…

As an Emacs user, why not use magit? Staging, committing and pushing would be just a few key presses ('C-x g S c c p P' assuming magit bound to 'C-x g'). You also get to view the status and diffs along the way.

Re: Mastering Bash and Terminal

#109
post #43
post #25

Earlier quoted context omitted.

On my version of zsh I was not able to do the following which is available on bash: http://unix.stackexchange.com/a/203075

Binding the vi widget in emacs mode works: bindkey '^]' vi-find-next-char

Oh, it does? Cool. I didn't think that you could use a widget from one mode in another.

Re: Mastering Bash and Terminal

#110
post #97

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…

tmux is a good alternative to the whole paradigm of 'running shell commands within a text editor like vim'. Why run a shell command within vim when one can run the shell command in an actual shell? It seems to me that running a shell command in vim is using vim outside of its intended scope. It might be able to do it but it won't be able to do it well, which is where something like tmux comes in. I might be in the mi…

If only tmux loaded my environment and not purify it by design
Post reply on HN