Live data from Hacker News

Shell Tricks That Make Life Easier (and Save Your Sanity)

blog.hofstede.it

121–130 of 287 posts

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#121
post #111

Earlier quoted context omitted.

This reminds me of an excerpt from an old Emacs manual: . . . if you forget which commands deal with windows, just type @b[ESC-?]@t[window]@b[ESC]. This weird command is presented with such a benevolent innocence as if it's the simplest thing in the world. I think the better advice for command-line editing would be to set up the mouse.

> This weird command is presented with such a benevolent innocence as if it's the simplest thing in the world. I think it's a question of context and familiarity. To a vim user, like me and, I assume, ahmedfromtunis, their examples do indeed seem simple and natural. Presumably, to an emacs user, the example you quote (if it's quoted literally—I don't use emacs and can't even tell) is just as natural, and assuming som…

> assuming some comfort with emacs is presumably OK in a manual for the software!

How do you get familiar with the software, if the manual expects you to be an expert in it already?

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#122

Earlier quoted context omitted.

And once you want to one-up this look into fzf.

And once you get tired of fzf and want something better, you reach for https://atuin.sh . Completely transformed all of my workflows

From the atuin.sh website

> Sync your shell history to all of your machines

I think of my shell history as very machine specific. Can you give some insights on how you benefit from history sync? If you use it.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#123
post #116

I'd advise against using sudo !! though since it adds the command to history and then it's very easy to accidentally trigger, running some undesired command as root without any prior confirmation. IMO pressing up, Ctrl-A and typing "sudo " isn't much longer but saves you from running unknown commands as root by accident

i never found !! useful at all when i can just use up arrow to get the entry i want. it becomes more interesting when you can recall older commands, but then too i prefer search because i want to verify what command i am going to run. and i only use sudo to open a root shell. never to run anything directly. i don't want normal and root commands mixed in the same history. i could keep sudo commands out of the history,…

> i want to verify what command i am going to run.

shopt -s histverify

shopt -s histreedit

i dont know why they are not the default.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#125
post #122

Earlier quoted context omitted.

And once you get tired of fzf and want something better, you reach for https://atuin.sh . Completely transformed all of my workflows

From the atuin.sh website > Sync your shell history to all of your machines I think of my shell history as very machine specific. Can you give some insights on how you benefit from history sync? If you use it.

That feature is entirely optional and disabled by default. Atuin stores your shell history locally in a sqlite db regardless of whether you choose to sync it. I thought fzf was fast, but atuin makes it look slow by comparison.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#126

Earlier quoted context omitted.

I've been a (n)vim user for 20+ years now, but I hate vi-mode in the shell. However if I feel that I need to do a complex command, I just do ctrl-x+e to open up in neovim (with EDITOR=nvim set). I find it a good middle ground.

Huh. I don’t use vi-mode for more than jumping to the beginning or end of a line, which I like a lot.

It really shines for navigating history. / searches history the same way as the editor search function

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#127
post #122

Earlier quoted context omitted.

And once you get tired of fzf and want something better, you reach for https://atuin.sh . Completely transformed all of my workflows

From the atuin.sh website > Sync your shell history to all of your machines I think of my shell history as very machine specific. Can you give some insights on how you benefit from history sync? If you use it.

Same, I find shared history not very useful.

However what I do find useful is eternal history. It's doable with some .bashrc hacks, and slow because it's file based on every command, but:

- never delete history

- associate history with a session token

- set separate tokens in each screen, tmux, whatever session

- sort such that backward search (ctrl-R) hits current session history first, and the rest second

Like half my corporate brain is in a 11M history file at this point, going back years.

What I would love is to integrate this into the shell better so it's using sqlite or similar so it doesn't feel "sluggish." But even now the pain is worth the prize.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#128
post #121
post #111

Earlier quoted context omitted.

> This weird command is presented with such a benevolent innocence as if it's the simplest thing in the world. I think it's a question of context and familiarity. To a vim user, like me and, I assume, ahmedfromtunis, their examples do indeed seem simple and natural. Presumably, to an emacs user, the example you quote (if it's quoted literally—I don't use emacs and can't even tell) is just as natural, and assuming som…

> assuming some comfort with emacs is presumably OK in a manual for the software! How do you get familiar with the software, if the manual expects you to be an expert in it already?

Not sure if it did at the time, but today emacs comes with a tutorial. You’re not expected to learn it by starting on page 1 of the manual.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#129

Earlier quoted context omitted.

I've been a (n)vim user for 20+ years now, but I hate vi-mode in the shell. However if I feel that I need to do a complex command, I just do ctrl-x+e to open up in neovim (with EDITOR=nvim set). I find it a good middle ground.

Huh. I don’t use vi-mode for more than jumping to the beginning or end of a line, which I like a lot.

C-a and C-e are your friend.

Re: Shell Tricks That Make Life Easier (and Save Your Sanity)

#130
post #2

Not a fan of the LLM-flavoured headings, and the tips seem like a real mixed bag (and it'd be nice to give credit specifically to the readline library where appropriate as opposed to the shell), but there are definitely a few things in here I'll have to play around with. One thing I dislike about brace expansions is that they don't play nicely with tab completion. I'd rather have easy ways to e.g. duplicate the last…

Readline is close enough to being part of bash that it’s not really inaccurate to call these all shell features imo.
Post reply on HN