Live data from Hacker News

Linux Terminal Goods

diego-pacheco.blogspot.com

11–20 of 65 posts

Re: Linux Terminal Goods

#11
I spend loads of time in a shell. One day I'll push my full dotfiles publicly, but until then here's a few snippets I've found super handy. I'd advise against using them verbatim but there's a few things in there that took some time to figure out. Beware they can be somewhat buggy / break things though.

Highlights include:

- Bind C-c/C-v to Copy/Paste, bind C-g to sigterm (Note: Breaks docker interactive unless you mount bashrc into /etc/bashrc or similar!)

- Autorun tmux on SSH session

- Syntax/colour highlighting in zsh interactive, I think there's some diff/less/man magic in there too!

- Log all shell activity to .shell_logs (Be _super_ careful with this one, breaking it could prevent you opening an interactive shell

- Useful grep defaults, particularly relevant when using .shell_logs

Bashrc: https://gist.github.com/YoloClin/f4c82a6e693000a2da20e8029a4...

Zshrc: https://gist.github.com/YoloClin/ffd82f441d292ccc5f25c62a80c...

One thing I've lost love for is Powerline9k - Right-aligned data breaks copy/paste functionality, and patching fonts to get UI-arrows is fiddly for little functional value. If I ever need to fiddle with that stuff again, I'll configure a regular theme to do similar and go without the UI-arrow breaks.

I was considering hiding history-relevant log data (such as current system time) to behind a carriage return, something like PS1="$(date)\r$PS1".

I'm interested in hearing others' cool, non-standard hacks!

Re: Linux Terminal Goods

#13
post #6

I prefer my terminals dumb and without much color, as the UNIX gods intended them to be. This being said, I'm in love with `fzf`, my workflow improved markedly after scripting (on mac) `ggvi() { git grep "$@" | fzf | sed \"s/:/ +/\" | cut -d \":\" -f 1 | gxargs -r -o vim }`

You can also combine it with ripgrep. Much faster than git grep.

Re: Linux Terminal Goods

#14
post #7

I've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) bu…

Its simplicity is an important part of the offering. Bash is perfect when you need predictable executions. When you use Bash, you benefit from an entire ecosystem that also uses it. That same ecosystem is not motivated to drastically change the shell, and therefore it remains stable and predictable. Bash typically isn't like Python or JavaScript, where certain features are introduced at a particular version and you h…

I don't disagree with your points but I think your following comment is a little misleading:

> Bash typically isn't like Python or JavaScript, where certain features are introduced at a particular version and you have to constantly check for them, or not use them outright, or maintain which binary you have installed at all times. One Bash binary typically contains the same feature set as another binary.

While you're right about shell builtins (a lot of which are defined by POSIX anyway), to do anything useful in POSIX shells requires forking out to sed, awk, grep, as well as many other coreutils and CLI tools. Thus you then need to not only confirm whether those tools are also installed but sometimes also which version or even implementation they are (eg GNU extends on POSIX in quite a number of ways from supported features through to how you order and group flags. Sometimes it can be a little jarring jumping from Linux to OSX if you're used to GNU).

That said, I do working in shells. For "getting shit done" very little even comes close to shells in terms of productivity. However shells are generally optimised to the "write many read once" end of development rather than "write once read many".

As an aside, I suspect GP meant to post this comment on https://news.ycombinator.com/item?id=21013150 (Pure Bash Bible - also on the front page) rather than here?

Re: Linux Terminal Goods

#15
post #7

I've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) bu…

I guess it's like anything programming related. Things don't make sense until they make sense.

Bash's syntax is a bit rough at times and I often find myself having to Google things even though I know what I want to do at a conceptual level.

But the real magic isn't just Bash alone. It's combining it with Unix tools to pipe together programs to solve problems.

I guess at the end of the day no one has tried to fix it because they don't see it as a problem. Despite the syntax weirdness at times it's a pretty concise language which meshes well with writing ad-hoc things on the command line.

IMO Bash is often the best tool to use for a ton of different problems. Sometimes it's good for a final result and sometimes it's good to flesh out a prototype because you can hack something together so fast.

Re: Linux Terminal Goods

#17
some vim enthousiast here scalded me for sending him spacevim linkand told me to use neovim. i don't use vim so i wouldn't know, and vim people seem easily offended :D. anyhow, just thought i'd not his input.

Re: Linux Terminal Goods

#18
post #6

I prefer my terminals dumb and without much color, as the UNIX gods intended them to be. This being said, I'm in love with `fzf`, my workflow improved markedly after scripting (on mac) `ggvi() { git grep "$@" | fzf | sed \"s/:/ +/\" | cut -d \":\" -f 1 | gxargs -r -o vim }`

have to agree that colours often disctract more than are of use. they stop you critically reading imo. but i guess that's also a matter of taste or something like that.

Re: Linux Terminal Goods

#19
post #15
post #7

I've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) bu…

I guess it's like anything programming related. Things don't make sense until they make sense. Bash's syntax is a bit rough at times and I often find myself having to Google things even though I know what I want to do at a conceptual level. But the real magic isn't just Bash alone. It's combining it with Unix tools to pipe together programs to solve problems. I guess at the end of the day no one has tried to fix it b…

The real advantage it has is simply that it’s there, always. It enjoyed a network effect a long time ago and is now so entrenched that challengers have a mountain to climb - entire generations of professionals know how to get stuff done with it and expect it to be there from the start, so any system that goes with an alternative is at an immediate disadvantage. A few OSes are trying to push what are effectively incremental updates (like ksh on OpenBSD), but it’s a daring proposition. I like OpenBSD but still the first thing I do is switch back to bash, because there are so many other things on the todo list that dealing with an unfamiliar shell is both incredibly low priority and the first thing I’m forced to do - a perfect “demotivational” combo.

I fear it would take a massive coordinated switch, systemd-like, where an entire ecosystem moves to an alternative, to actually see any change in this area.

Post reply on HN