Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

FlapYoJacks posted:

literally every single embedded Linux system I have ever worked on since 2005 has had tab completion.

how nice for you

Adbot
ADBOT LOVES YOU

Progressive JPEG
Feb 19, 2003

Poopernickel posted:

aliases are a workaround for lovely defaults, and tab-completion isn't all that common on the embedded Linux stuff that I have to janitor

eh idk i like the idea of single-letter commands being available for me to use as aliases

alias l=journalctl or smth

Sapozhnik
Jan 2, 2005

Nap Ghost
are there really people who have to use kubectl on a regular basis who don't immediately alias it to k

FlapYoJacks
Feb 12, 2009

Poopernickel posted:

how nice for you

Ash supports tab completion. What shell are you using?

outhole surfer
Mar 18, 2003

FlapYoJacks posted:

Ash supports tab completion. What shell are you using?

probably busybox


but if you're regularly doing cli janitor work on a system with only busybox, you done hosed up and landed yourself in one of three situations

1) you're working on an embedded device so incompetently designed by someone else that it doesn't expose sane configuration and debugging interfaces
2) you've designed an embedded device so incompetently that it doesn't expose sane configuration and debugging interfaces
3) you're working on an embedded device you don't actually understand how to configure or debug, so you figure you can use your server janitor skills to hack it into submission

if you're on a busybox system and find yourself running journalctl or kubectl, you're probably in situation three

FlapYoJacks
Feb 12, 2009
Ash is the shell Busybox provides, which supports tab completion.

BattleMaster
Aug 14, 2000

speaking of tab completion, modern bash (though I don't know how modern since I stopped paying attention to linux for more than a decade until last year) has some magical tab completion that is aware of switches and arguments of various commands and can autocomplete those

for instance, I have a file text indexer, recoll, running on my document repository as a service, and I have a systemd unit file for it called recoll.service placed in /etc/systemd/system. If I want to stop it, I can type systemctl stop rec<tab> and it autocompletes the filename, even if I'm not currently in /etc/systemd/system where the unit file is located - it's aware of where the unit files are and that this is the argument where I'd be entering a unit file filename

again I don't know how new and impressive that is but I thought it was pretty cool when I found it

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Sapozhnik posted:

are there really people who have to use kubectl on a regular basis who don't immediately alias it to k

it comes pre-aliased out of the box for me as oc

MononcQc
May 29, 2007

I have the full length command so that when I write doc I never accidentally rely on undocumented local config

Rufus Ping
Dec 27, 2006





I'm a Friend of Rodney Nano

BattleMaster posted:

speaking of tab completion, modern bash (though I don't know how modern since I stopped paying attention to linux for more than a decade until last year) has some magical tab completion that is aware of switches and arguments of various commands and can autocomplete those

for instance, I have a file text indexer, recoll, running on my document repository as a service, and I have a systemd unit file for it called recoll.service placed in /etc/systemd/system. If I want to stop it, I can type systemctl stop rec<tab> and it autocompletes the filename, even if I'm not currently in /etc/systemd/system where the unit file is located - it's aware of where the unit files are and that this is the argument where I'd be entering a unit file filename

again I don't know how new and impressive that is but I thought it was pretty cool when I found it

Unsurprisingly it's all rigged up using horrific shell scripts https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

BattleMaster posted:

speaking of tab completion, modern bash (though I don't know how modern since I stopped paying attention to linux for more than a decade until last year) has some magical tab completion that is aware of switches and arguments of various commands and can autocomplete those

for instance, I have a file text indexer, recoll, running on my document repository as a service, and I have a systemd unit file for it called recoll.service placed in /etc/systemd/system. If I want to stop it, I can type systemctl stop rec<tab> and it autocompletes the filename, even if I'm not currently in /etc/systemd/system where the unit file is located - it's aware of where the unit files are and that this is the argument where I'd be entering a unit file filename

again I don't know how new and impressive that is but I thought it was pretty cool when I found it

It's actually not part of bash. Tab completion scripts are almost always packaged separately and aren't part of Bash at all. Bash knows how to execute an entry script function in response to a tab, and that's it. The rest is all external.

There's a standard bash-completion package on most distros. Systemd's completion scripts are managed separately. They're an optional component when building systemd from source.

Poopernickel fucked around with this message at 08:06 on Apr 9, 2022

sb hermit
Dec 13, 2016





I'm ok with tab completion but I don't use aliases because I write a lot of documentation and it's easier to dump history if I need to document stuff. My typing speed is fast enough and auto complete helps enough that aliases aren't worth the effort.

Also, modern tab completion sometimes doesn't let you tab-complete files for certain programs depending on what's going on and I have to then copy and paste a long rear end filename because I'm tired of typing out some long thing to get an error later.

sb hermit
Dec 13, 2016





I have to admit, systemd init files are pretty good.

Progressive JPEG
Feb 19, 2003

speaking of kubectl and tab completion heres the part of my bashrc that sets up tab completion for "k" as an alias for kubectl, or tells me what to run if the kubectl tab completion config is missing:
code:
  if [ -n "$BASH_COMPLETIOND_PATH" ]; then
      if [ -f $BASH_COMPLETIOND_PATH/kubectl ]; then
          complete -o default -o nospace -F __start_kubectl k
      else
          echo "Run this: sudo mkdir -p $BASH_COMPLETIOND_PATH && kubectl completion bash | sudo tee $BASH_COMPLETIOND_PATH/kubectl"
      fi
  fi

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Poopernickel posted:

aliases are a workaround for lovely defaults, and tab-completion isn't all that common on the embedded Linux stuff that I have to janitor

why not?

remember even an original raspberry pi is about 7x the performance of a circa-1995 SPARCstation 20, and that was a fast system compared to the mainframes, minis, and workstations of the 70s and 80s on which tab completion was developed

I’ve used tab completion on a Sun-3/60 and an HP 9000-340, each with a 16MHz 68020 and 16MB of RAM, and on each it was tolerable, while on a 25MHz 68040 with 32MB of RAM it was perfectly usable—and all of those were netbooted with root and swap on NFS

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Rufus Ping posted:

Unsurprisingly it's all rigged up using horrific shell scripts https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html

yeah heaven forbid there be a well-defined mechanism for specifying commands and their parameters and arguments, especially in a way that integrates with a systemwide help mechanism

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

eschaton posted:

why not?

remember even an original raspberry pi is about 7x the performance of a circa-1995 SPARCstation 20, and that was a fast system compared to the mainframes, minis, and workstations of the 70s and 80s on which tab completion was developed

I’ve used tab completion on a Sun-3/60 and an HP 9000-340, each with a 16MHz 68020 and 16MB of RAM, and on each it was tolerable, while on a 25MHz 68040 with 32MB of RAM it was perfectly usable—and all of those were netbooted with root and swap on NFS

it's not a performance thing - just not something I see included in people's designs very often.

Maybe because the bash-completion packages in Buildroot and Yocto both depend on Bash, and Bash is hard to ship in consumer goods because it's GPLv3.

The "unmet-but-actually-OK" dependency issue is a problem that can be solved by an engineer who cares to do it. Most folks don't though, at least not at any of the places where I've done embedded Linux work. So the result is that bash-completion is rarely included.

BlankSystemDaemon
Mar 13, 2009



FlapYoJacks posted:

Ash supports tab completion. What shell are you using?

FlapYoJacks posted:

Ash is the shell Busybox provides, which supports tab completion.
Does busybox use some other Almquist shell than the BSDs? Because command completion based on $PATH has only worked as of recently.

Kazinsal
Dec 13, 2011



BlankSystemDaemon posted:

Does busybox use some other Almquist shell than the BSDs? Because command completion based on $PATH has only worked as of recently.

there's a "debian almquist shell" (dash) that I know a number of linux-adjacent OSes use because it's both a fairly featureful shell and much more portable than bash

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

BlankSystemDaemon posted:

Does busybox use some other Almquist shell than the BSDs? Because command completion based on $PATH has only worked as of recently.

Busybox uses ash, but it's a version that's maintained in the Busybox tree. Busybox ash has a bunch of hacks that make it look more bash-like, so it's definitely not the same as BSD ash.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Kazinsal posted:

there's a "debian almquist shell" (dash) that I know a number of linux-adjacent OSes use because it's both a fairly featureful shell and much more portable than bash

when ubuntu switched to dash as the default for scripts it threw our product for a loop because they had tons of bashisms in all the shellscripts involved with managing the appserver.

and their solution was a config action on install/profile creation that would go through and replace the shabangs with bin/bash on ubuntu only.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

i've come to like fish's command and file name completion, especially since it will display what the completion would be if invoked right there. unfortunately it doesn't integrate with bash completions.

BlankSystemDaemon
Mar 13, 2009



a command completion system that i can't add things to on the fly because the system is incomprehensible is pointless to me

that's why i love tcsh so much, it just uses regular expressions - so if you find a new command you want to add completions for, it's a tiny bit of effort to add it instead of having to work with some completely bonkers syntax that expects you to be a programmer and possibly work in a third language

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

regex is incomprehensible

Cybernetic Vermin
Apr 18, 2005

Captain Foo posted:

regex is incomprehensible

nah.

i mean, any given regex is incomprehensible, and as a collective thing they are not well understood by anyone, but they are somehow still easy to write.

Radia
Jul 14, 2021

And someday, together.. We'll shine.
wait do y'all just memorize every hostname you have to SSH into or the stupidly long chain of commands to connect to random containers in k8s or your local docker cluster??? genuinely confused as to why y'all hate aliases like this

mystes
May 31, 2006

Lady Radia posted:

wait do y'all just memorize every hostname you have to SSH into or the stupidly long chain of commands to connect to random containers in k8s or your local docker cluster??? genuinely confused as to why y'all hate aliases like this
for ssh hostnames you can just define them in your ssh config file which is different from shell aliases

Radia
Jul 14, 2021

And someday, together.. We'll shine.
but what if they dont use the same private/public keypairs?!?!

AnimeIsTrash
Jun 30, 2018

Lady Radia posted:

wait do y'all just memorize every hostname you have to SSH into or the stupidly long chain of commands to connect to random containers in k8s or your local docker cluster??? genuinely confused as to why y'all hate aliases like this

yes

BlankSystemDaemon
Mar 13, 2009



Lady Radia posted:

wait do y'all just memorize every hostname you have to SSH into or the stupidly long chain of commands to connect to random containers in k8s or your local docker cluster??? genuinely confused as to why y'all hate aliases like this
From my .tcshrc
pre:
if ( -r "$HOME/.ssh/known_hosts" ) then
        set hosts = ($hosts `cut -w -f1 "$HOME/.ssh/known_hosts" | cut -d, -f1`)
endif
complete ssh            'p/1/$hosts/' \
                        'c/-/(l n)/' \
                        'n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/'
complete scp            "c,*:/,F:/," \
                        "c,*:,F:$HOME," \
                        'c/*@/$hosts/:/'

Radia
Jul 14, 2021

And someday, together.. We'll shine.
oh my god. just loving. write a quick alias. it takes half a second to loving copy paste the command, write "echo alias buildmacssh=pasted_command >> .zshrc", and be done with it. ahhh

sb hermit
Dec 13, 2016





Lady Radia posted:

but what if they dont use the same private/public keypairs?!?!

you can specify the private key you want to use in your ~/.ssh/config file

Radia
Jul 14, 2021

And someday, together.. We'll shine.
im so unreasonably upset right now.

Nitrousoxide
May 30, 2011

do not buy a oneplus phone



sb hermit posted:

you can specify the private key you want to use in your ~/.ssh/config file

When I discovered this I literally spent about 5 minutes logging in and out of my server via ssh giddily.

BlankSystemDaemon
Mar 13, 2009



Lady Radia posted:

oh my god. just loving. write a quick alias. it takes half a second to loving copy paste the command, write "echo alias buildmacssh=pasted_command >> .zshrc", and be done with it. ahhh
how short is your .ssh/known_hosts, op???

sb hermit posted:

you can specify the private key you want to use in your ~/.ssh/config file
this combined with a controlmaster directive set to autoask for every host, and/or using the proxyjump directive in ssh_config(5) is loving awesome

BlankSystemDaemon fucked around with this message at 22:11 on Apr 9, 2022

AnimeIsTrash
Jun 30, 2018


excuse me

AnimeIsTrash
Jun 30, 2018

more like fsh, because it's fail

Radia
Jul 14, 2021

And someday, together.. We'll shine.

BlankSystemDaemon posted:

how short is your .ssh/known_hosts, op???
it's single digits most of the time because i dont custodian the servers the clusters live on, op.

Mr. Crow
May 22, 2008

Snap City mayor for life
I mean aliases are great but why would you use them for ssh'ing to boxes lol

Adbot
ADBOT LOVES YOU

BlankSystemDaemon
Mar 13, 2009



i don't think i will

Lady Radia posted:

it's single digits most of the time because i dont custodian the servers the clusters live on, op.
i don't custodian servers either, and i have like a hundred servers in there

Mr. Crow posted:

I mean aliases are great but why would you use them for ssh'ing to boxes lol
right, having that many aliases would lead to namespace overload

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply