Shell Tricks That Make Life Easier (and Save Your Sanity)
201–210 of 287 posts
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#202If I do something the slow way it's usually because I don't do the operation enough to burn it into my memory, or I got burned by accidentally hitting something close but incorrect once and closed the tab or something.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#203If only somebody had a lifehack for making me remember all these awesome commands. If I do something the slow way it's usually because I don't do the operation enough to burn it into my memory, or I got burned by accidentally hitting something close but incorrect once and closed the tab or something.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#204If only somebody had a lifehack for making me remember all these awesome commands. If I do something the slow way it's usually because I don't do the operation enough to burn it into my memory, or I got burned by accidentally hitting something close but incorrect once and closed the tab or something.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#205Earlier 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.
2. clone it on host_bar in /home/user/src/myproject
If you set filter_mode = "directory", you can recall project specific commands from host_foo for use on host_bar even though you're working on different machines and the search space won't be cluttered with project specific commands for other projects.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#206Its almost ironical that we still use the Terminal - and many use it like in the eighties using Bash - and seem to have forgotten that we should invent a better terminal & shell than doing all the workarounds to handle the quirks of the current systems.
A Terminal + Bash/ZSH is soooo sticky because they are VERY good at what they do once you learn the basics and quirks. And now with LLMs, CLIs are even better because LLMs talk in text and CLIs talk in text.
Microsoft tried with PowerShell to design a better system; it "technically" is better, but not "better enough" to justify the cost of switching (on Linux). The same is true of nushell; it is "better", but not better enough to justify switching for most people.
I believe we're at "peak input method" until someone invents BrainComputer interfaces.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#207Earlier quoted context omitted.
Wow I hate* that. I use bracket comments. They're cool cause they are bracket comments, so I use it in scripts to document pipelines. They are annoying cause they are bracket comments, in an interactive shell I have to type more and in TWO places. It's fun to reason-out how it works ;) $ echo foo | tr fo FO | sed 's/FOO/BAR/' BAR $ echo foo | ${IFS# tr fo FO | } sed 's/FOO/BAR/' foo It's nice to have a way to both /*…
for multiline pipes, it's WAY better to format like foo | bar | baz You don't have to use backquotes, AND, it allows you to comment line by line, because there's no backslash messing with the parser. I also use a last `|\ncat` so you can delete any line and you don't have to worry about the last line being a bit different than the rest I created a list of similar tricks in https://github.com/kidd/scripting-field-guid…
$ {
> echo foo \
> && echo bar \
> || echo baz ;
> }
foo
bar
$IFS
${IFS# echo foo && echo bar || echo baz ; }
$ _
There's good and bad to both approaches. I like how I can use () and {} to bracket things and otherwise every line that end in \ is continued. I line-up on the left with the operator, you with indentation. When you use a # style comment, you have to look up and back and forward to see what the operator is you are continuing over to the next line: $ foo |
bar | # ?Do? *the* $bar$ && [do] {it!}
baz
Which only takes an extra neuron or so, but then history...
$ foo | bar | # ?Do? *the* $bar$ && [do] {it!}
bazRe: Shell Tricks That Make Life Easier (and Save Your Sanity)
#208One trick I use all the time: You're typing a long command, then before running it you remember you have to do some stuff first. Instead of Ctrl-C to cancel it, you push it to history in a disabled form. Prepend the line with # to comment it, run the commented line so it gets added to history, do whatever it is you remembered, then up arrow to retrieve the first command. $ long_command $ #long_command $ stuff_1 $ stu…
With zsh, I prefer to use alt-q which does this automatically (store the current line, display a new prompt, then, after the new command is sent, restore the stored line). It can also stack the paused commands, e.g.:
$ cp foo/bar dest/
$ wcurl -o foo/bar "$URL"
$ mkdir foo
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#209Not 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…
Not just the heading is LLM-flavoured. So is the writing, e.g. "The shell is a toolbox, not an obstacle course."