mastodon.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
The original server operated by the Mastodon gGmbH non-profit

Administered by:

Server stats:

351K
active users

@nixCraft *CLICKCLICKCLICKCLICKCLICKCLICK* ”I know I typed ls recently where the heck is it” *CLICKCLICKCLICKCLICKCLICK*

@nixCraft I genuinely don't understand why this is the norm, or why people put up with this shit.

"set -o vi" is literally the first command I run when I log into a machine I haven't customized. vi-mode command line editing? Why would anyone on Linux NOT want that?

@swordgeek

@nixCraft

So you're saying we should all be pressing kkkkk instead of ⬆️⬆️⬆️⬆️⬆️⬆️ to find where we typed ls?

@benlindsay @nixCraft Nah, you hit /ls.

(Yes, ctrl-R does the same in emacs mode.)

I guess what confuses me is that I find very few people who actually use emacs these days - admins use vi(m) and developers use an IDE and vi(m) in the terminal. So why do we default to command-line in emacs mode?

@swordgeek
@nixCraft

Ohhhh interesting I never thought of that! I'm a (kind of ex-) vim user and I have set editing-mode vi in my .inputrc but rarely use vim features in the command line. Didn't realize vim style search worked there! Gonna give that a try

@benlindsay @nixCraft Yeah, it's pretty great. You get full vi-style editing; search, movement commands, editing, pretty much the works.

I've been using it since I switched from csh to ksh (ksh88 on Solaris), back in the mid-'90s, then carried it forward to bash and on Macs now, zsh.

@swordgeek @nixCraft
to be fair, it’s usually only after I hit “Esc, k” and it doesn’t do what I expect it to that I do “set -o vi”—because it’s just what I expect a properly configured shell to do

@nixCraft
Use Ctrl+R to search your command history in reverse chronological order 🥳

@natanielf I always make a typo and then hit backspace and type again and then it finds even older irrelevant stuff and have to hit Ctrl-C and start over again.

Holding down that up-arrow is much easier! 🙃

@nixCraft

@hvangalen @natanielf @nixCraft I have a feeling that allows you add more parameters to the search, especially when you have lots of similar lines in your history like so:

ping host1
ssh host1
telnet host1 80
ping host2
ssh host2
...
telnet host5 80

Searching for "ssh" might not give you the right one out 5 results. If you clear it with backspace and type "host2" it returns results with both "ssh" and "host2". I still need to confirm this.
Anyway, plenty more tips here:
digitalocean.com/community/tut

www.digitalocean.comHow To Use Bash History Commands and Expansions on a Linux VPS | DigitalOceanAs you administer servers, you will begin to spend a lot of time on the command line. Most likely, you will be using the bash shell. The bash shell include…

@georgeeyong I scanned that page and see things that I already knew.

HOWEVER I was totally unaware that one can hit Ctrl-R more than once to iterate all matches!

THAT IS A GAME CHANGER 😆

@natanielf @nixCraft

@natanielf @nixCraft Someday I'll figure out how to use arrow keys to iterate through several similar matches produced by Ctrl+R in my shell. Until then it's the old reliable: history | grep.

@ellie @natanielf @nixCraft IIRC I just keep hitting Ctrl+R and it iterates.

@natanielf @nixCraft surprised I had to go down far enough to see this

@natanielf @nixCraft Galaxy brain: Hit Ctrl+R, type the exact command you want to find in the history, then hit Enter

@natanielf I'm too stoopid to know whether you're joking.

@nixCraft

@nixCraft CTRL-R is one of the most useful, often overlooked features, that I know of in Linux. So useful for searching through previous commands.

@miyelsh @nixCraft does anyone still use ksh?
If you have
EDITOR=vi
In your shell environment you could hit esc and use vi commands to search and edit your commands in the history before execution.

@nixCraft sudo !! is also great for when i forget to sudo, especialy when its a long command with a bunch of file paths in it. 🦇 :blobfoxdead:

@ChurchHatesTucker @nixCraft I often history | grep foo | tail. 24 is never enough

@Laukidh @ChurchHatesTucker @nixCraft I use CTRL-r, which allows me to search my history.

@ljrk @Laukidh @ChurchHatesTucker @nixCraft @atuin I mostly use zsh with oh-my-zsh now, and I occasionally need to remember how to work with bash for when I ssh into a new server to debug something

@webhat @Laukidh @ChurchHatesTucker @nixCraft @atuin Back when I had to hop b/w Solaris, Linux and mac machines regularly I had all my tooling (custom scripts etc.) in ~/.local/bin be ksh83 & POSIX compliant for that reason and I ran vanilla vi :'-)

Too much hassle to mentally switch b/w bash3, bash5, ksh and zsh (and the occasional fish or csh)

@ljrk @Laukidh @ChurchHatesTucker @nixCraft @atuin that's brings way back. In ~/.local/bin I had wrapper shell scripts that would start the appropriate (custom) binaries based on the architecture and processor, so I could scp my ~/.local to the box and not need to worry about the local tools having the correct versions and run with the version I liked best. I had a cross compiler in my workflow to ensure that all the binaries stayed up to date with the latest versions of whatever tools I was working with.

My favourite one was after Solaris 7 came out and everyone was in our company was in love with pkill and pgrep, which wasn't available on the Linux versions we used at the time, I wrote a custom version that I would drag with me everywhere.

We had an assortment of devices we looked after, various flavour of Solaris, Linux, BSD and DEC UNIX.

@webhat @Laukidh @ChurchHatesTucker @nixCraft @atuin Awesome :D

Sounds like POSIX `getconf` as used in Solaris for backwards compatibility back to stone ages for importing `/usr/xpg4` or whatever was required into `$PATH`.

I also implemented a more featureful `head` and `tail` in `awk` for similar reasons. IIRC it was actually quite pleasant, surprisingly performant and of course architecture independent.

@webhat @ljrk @ChurchHatesTucker @nixCraft @atuin I had my bash profile identify the environment I was in (work, home, web tier, app tier) and set aliases based on that.

Some based on hostname, some based on checks for directories.

So for example I could always type “logs” and end up in the main log directory.

@Laukidh @webhat @ChurchHatesTucker @nixCraft @atuin Awesome! The only relevant script I currently have is a wrapper around `podman` that detects whether I'm currently in a toolbx
container or not and either spawns the binary on the host or directly... – gone are the times of weird quirks, although I still don't use bashisms in my scripts :'-)

@nixCraft surprised nobody posted this already

@blogdiva @djb @nixCraft
Teach 'em CTRL-R (reverse search) in the shell.

@phlogiston @nixCraft @blogdiva @djb I recently learned this and it’s been a huge help. I love this command!!

@djb
I'm not admitting anything except that the up arrow key on my keyboard is broken

@djb @nixCraft pro tip: type "history" scroll through the last 500 commands double click "ls" then right click, much faster and simpler!

@djb @nixCraft
I feel attacked! Why would I spend the energy typing ”npm run build” when I know my friend ⬆️ surely has it somewhere close by… :blobcataww:

@djb @nixCraft I wonder what happened to CommmitStrip. It has been ages since their last comic. Hope they are well.

@djb @nixCraft
why not $ history | grep ls ?

@djb @nixCraft Or learn about ^R and page-up for matching in your history file.

@djb @nixCraft

I'm not proud to say this but frequently use grep <term> ~/.bash_history

@djb @nixCraft I use ctrl + R on fish to look up my history, very useful

@djb @nixCraft (CRTL-r for history search incase nobody knew)

@nixCraft would be nice if you put alt text on your posts; none of them seem to have any

Anyways, #ALT4you

A man wearing a shirt that says "RUN CMD" with a 'no' gesture. Next to him, it says "Type a single command into the console"

Below that, the same man has a 'yes, this one' gesture. Next to him, it says "Press up key dozens of times until you find it."