Follow

“Moving efficiently in the CLI”

clementc.github.io/blog/2018/0

This is a *very* handy graphic. I’m still stuck on arrow keys too because I don’t remember the shortcuts

(Caveat, these do depend on your particular shell and distro so do check that they work the same)

mastodon.social/media/K8MxRyVL

@cypnk most shells can also be set to vi mode, where it works like vi if you prefer modal editing

@troubleMoney I think this is what most people who extensively tweak their setups do. Don’t have learn another command set

@cypnk I'd like to say I use vi mode for the shell because I prefer modal editing, but really it's because I can't be bothered to learn another command set

@cypnk

From the point of view of a non-technical person, that looks incredibly non-intuitive. If not outright intimidating.

Sometimes you use CTRL. Sometimes you use ALT. Why does ALT-B go to the end of the word in one direction, but the other is ALT-F? It seems like there's no particular logic to it and it's all very complicated.

I have to assume it looks much different to someone with experience and skill.

@Nezchan I can see how that can be an issue. Some of these commands originated back when there wasn’t a lot of consistency in command placement and when they were shared with now extinct programs and systems. If you were used to those, it’s a tad easier, but today’s computing really is very different

@Nezchan @cypnk It's F for forward and B for backwards. Ctrl skips characters, alt skips words.

I think it dates back to before you had cursor keys on keyboards, or long-established key combinations, so they did what they could with what they had.

@D_ @Nezchan My DIY computer doesn’t have arrow keys either so I expect these sorts of conversations to pop up again

@Nezchan @cypnk I'm a programmer who knew some of these already and i picked up the same thing... it seems silly to not have any consistency when it is so easy to be consistent

but as @cypnk mentions, history dictates a lot on computers

@tcql @cypnk Yeah, a lot of this seems to be legacy and "I learned it this way and got used to it, therefore my current self sees it as natural". And so they get carried on.

Plus, redesigning them means all the people who have been using them so far would have to learn a new paradigm, which isn't appealing either.

@Nezchan @cypnk its funny becuase there's ALMOST logic. As @Efi points out B for Backward, F for Forward. And A could be "the letter before B, because we're going farther backward", but with that logic, the same function for the opposite direction should be G, not E, because you're going farther forward

🤷‍♂️

@tcql @Nezchan @cypnk E is for End, A is for... french àpres, which means before???

@Siphonay @Efi @tcql @cypnk

'It's not so much an afterlife' Said Arthur, 'more a sort of après vie'

@tcql @cypnk @Efi

G would work for "further forward" on a standard keyboard too, since it's set one forward of the F key. But that would make V the natural "further back" and that seems awkward. Better stuff to use V for anyway.

@Nezchan @cypnk
It might be easier to memorize them by noticing that:
- F/B shortcuts are used to move Forwards and Backwards,
- Ctrl moves by a single unit, Meta (Alt) by larger / logical units,
- Ctrl-K just Kills a line of text,
- Cltr-A goes to the beginning of the line because that's where A is in alphabet,
- Ctrl-E goes to the End of the line.

@Nezchan @cypnk i definitely wouldn't describe it as _intuitive_, but it's part of a larger set of conventions and patterns that make a lot of it predictable once you know some other stuff (or other stuff predictable once you know it).

specifically, it uses readline:

gist.github.com/jottr/a2351377

...which is common to a bunch of different interfaces, and uses shortcuts originally from emacs and common to a bunch of other text editors. i think they might even work in macos text inputs.

@cypnk @Nezchan it _is_ complicated, but at least speaking for myself, it's one of those things where you learn some mnemonics (ctrl-f for forward, ctrl-b for back, that kind of thing) and eventually they're just kinda muscle memory that you can apply all over the place.

most technical people i know seem to have a favored subset of things like this, and ignore the rest.

@brennen @cypnk

I think the operative word there is "technical people". You get used to this stuff through use, muscle memory, whatever it may be. It's something that, as you say, you use in a few different interfaces so it's your standard.

But the other side is that this kind of diagram, especially when presented as the "efficient" way, that I think scares folks not comfortable with CLI stuff. I can manage a few things, and there was a day I used it a lot more. But that was a long time ago.

@Nezchan @cypnk yeah, there may be better ways to convey this sort of info. i've spent time working on materials theoretically for a less technical audience like this stuff:

learn.adafruit.com/series/lear
p1k3.com/userland-book/

...and though i'm not totally ashamed of the cartoon penguins and such, i think i've mostly failed. it's a hard problem.

i guess one thing i've learned is that what clicks for one person is often very different for others, and many approaches are needed.

@cypnk @Nezchan and there are also certainly very many ways that things like command-line UX could be improved for everyone and made less painful for new users. i'm afraid it's often not as active an area of research as it could be because there's a pervasive belief that these environments are only for power users, as opposed to being environments where more people can _learn_ to be a power user.

@brennen @cypnk Cartoon penguins or no, it's good that there are people making guides that recognize how this stuff can be kinda scary to the uninitiated. Or at least forbiddingly complicated.

I think one thing that acts as a barrier to people switching to Linux is the belief that "oh shit, I'm gonna have to learn to use the terminal and that's difficult". Which is less and less true all the time, but the belief is still out there.

@cypnk @brennen Sometimes people are surprised that I, as a pretty non-technical person, prefer Linux. But as I said, the GUI for most distros is a hell of a lot easier and more flexible than the old days, and there's very little I need to do via CLI.

And what little there is, I can do a search on the internet and find a copy-paste solution to almost anything. It's great!

@Nezchan @cypnk @brennen

I think it's great that you prefer Linux. I'm glad the tools are getting to a point there knowing how to do sysadmin stuff is helpful but not necessary.

@starbreaker @cypnk @brennen

Linux for me is...comfortable. I need to maintain stuff once in a while, and occasionally use tools designed without the non-technical in mind, but overall it's an OS that feels good.

It's not shiny (but it can be), but it's good.

@Nezchan @brennen There’s a down side to being a “technical person” too

You get comfortable with the “efficient way” or the “right way” (whatever that means) and any UI change, or worse,” a change to a GUI, feels jarring and in some ways frightening. Ironically, your proclivity to customize your programs and even your CLI makes you a less flexible person and prone to nostalgia and stubbornness

At least that’s been my experience

@cypnk @brennen Oh, for sure. And I imagine that's a big reason why there's so many "legacy" ways to do things, because overhauling things really puts a lot of people out. Especially established people who don't really see need for a change.

@Nezchan @cypnk

I'm kinda a technical person and I find this completely non-intuitive. That's typically the kind of thing I'm unabled to remember T_T

@cypnk the shell keyboard shortcut mystery is solved. I could never figure out or remember `vimode'...

@cypnk Mostly the Emacs keys, which are also usable in Mac text widgets.

Cool Keys in Emacs is the go-to reference, not all will be supported but many will:
math.uh.edu/~bgb/emacs_keys.ht

I'm a vi, not an emacs, but it's not the keys' fault they got stuffed into half a broken LISP environment.

@cypnk thank you, that made my life better! alt-b/f is really nice to know!

Also, may I introduce "<meta>.", which on most systems translates to "<esc>(tiny pause)." and pastes the last command's last argument? Really useful with git, or when erroneously using ls with a directory...

@cypnk and Terminal / OS, not all accept passing Alt to the tty.

@cypnk
$ bindkey -v
(vim bindings for zsh).

Then you cannot exit shell, but you have awkward & complicated, yet efficient, one key shortcuts to move around 😜

@cypnk thank you for sharing this. Made a little paper clue for myself. :tux:

@cypnk it would be more accurate to say that those are Emacs keybindings. It just happens that Bash and other shells use the same bindings by default.

@loke Yup. Almost identical to many of them. That betrays how old Emacs actually is since many of these predate proper arrow keys

@cypnk I'm mad at this CLI because it wants me to use emacs shortcuts and I already learned vim! So instead I got a plugin that lets me just use vim movement keys

Sign in to participate in the conversation
Mastodon

Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. This server is run by the main developers of the Mastodon project. Everyone is welcome as long as you follow our code of conduct!