These auto-completions are dependent on having the corresponding completions information installed and enabled. Which it is with most modern distros, but more bare-bones setups won't have it.
I have two Linux VMs, one Fedora, the other Arch. I'm guessing tab autocompletes are built into those as well?
In case of Arch, for bash, you have the bash-completions package, apart from which some program packages install their own bash completions.
Then there is also zsh-completions for zsh.
I remember having to install them separately, but maybe you know some package group that did it for you.
Arch has the packages, but it won't be installed by default.
oh yeah, arch is for nerds who wanna customize everything themselves. i'm new to arch so i forget sometimes
Man, fish has me spoiled
The spirit of the 1990s is alive and well!
i need to get familiar with fish. syntax is super basic compared to zsh/bash. those two have so many fucking {\\/\^/\asdf$$(dog)}
interesting, didn't know that... Will try!
Finding out about "Ctrl-r" also was a gamechanger.
What does CTRL+R do?
Lets you easily and interactively search your command history.
Half the stuff I do is usually preceded by that, it's really useful!
Oh that is nice, I usually use ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
That’s part of the natural progression. Can’t remember if that comes before or after “history | grew command.”
"I knew I had an ls somewhere in my history"
Adding fzf to the mix makes Ctrl+r even better.
Yeah standard bash Ctrl+r is just so painful. I much rather use "history | grep searchtearm" than that awfull search. fzf is a whole other level. But nowadays I just use fish shell which IMO has even better search than fzf
Just wait until you discover fish/zsh autosuggestions.
As annoying as using a non-posix compatible shell sometimes is, fish saves me so much time
I have been suggested alternative programs to install to work with Ctrl+r, which are supposed to work better, but I just end up using kwrite ~/.bash_history when Ctrl+r fails.
I accidentally stumbled across Ctrl+r over a decade ago and I still don't understand properly how it works. So I usually egrep -e someInsaneRegex ~/.bash_history
The part of the tech stack that handles all these command editing and navigation shortcuts is the readline library. Check out man readline. There's an entire section on searching. readline is used for lots of other interpreters, too.
Ctrl+r is cool, but atuin is oh my gosh great
isn't that just fzf with ctrl-R binding
I used fzf before atuin, and it works pretty similar, but atuin has a few additional features, as it tracks more information than the normal shell history. For example, you can also search only for commands that you executed in the current directory (great for stuff that is project specific). Or, if you use the history syncing feature, you can toggle search for commands you executed on either any or only the current machine.
dude holy shit that is AWESOME! i had something similar, but it was a custom function.
srch() { cat ~/.bash_history | grep -Ein "$@"}
Did you know that grep can take the name of the file(s) you want it to search as the final arguments?
For example:
grep -Ein "$@" ~/.bash_history
Look at Carapace for even better completions
i got carapace installed with homebrew. looks pretty sweet! i'll be making use of the tab button a lot more now
Anyone who is learning new stuff in this thread should really try fish, it makes using the command line so much nicer.
Finally, a command line shell for the 90s
😄
I started out with bash, then eventually realized that I was using zsh because I'm a macbro. I'm a little slow :(
To be fair, they only switched to zsh in 2019, so a lot of tutorials probably still assume bash
I usually use --help as it also gives descriptions for the command, though some programs may only accept -h or no argument to show the help menu.
In zsh, you can configure the completion to also show descriptions.
Does it depend on some shell or shell extension? My bare bones Debian installs don't do this. Powershell does but I'd like it on Linux too.
zsh does this with oh-my-zsh, as well as many other "extra" completions
ZSH still needs the completion data files to be installed. It won't just magically know the completions.
Ah you're right, my bad. I automatically install oh-my-zsh so I forget how much functionality is bundled into it. Edited
You can install powershell on Linux if you're feeling masochistic
I take PowerShell ForEach-Object any day over the unholy contraptions of awk, xargs and friends in bash.
for $variable in $(collection command); do
other-command $variable;
done
Hm TIL, fair enough. Thanks.
But chaining still seems harder than CommandA | ForEach-Object { DoSomethingWith $_ } | CommandB
Yeah, it does tend to be hard to determine when to use () {} [] etc.
Even after I RTFM and used those in scripts multiple times, I tend to forget it by the time I need to implement something next.
TIL
I'd like something like on Cisco equipment.
Tab completes a command
? prints possible options with brief descriptions, filtered by starting letters if you already typed anything
if there is just one option left, you can just use it directly, so you can write shortened commands (similar to ip commands on Linux)
That would be the dream indeed. It's so fluid after you learn it. Other networking equipment often has good configuration CLIs as well (like juniper and vyos), but Cisco is probably the best in my experience. It's also nice how consistent they are across generations.
You can get about as close as it's possible in a normal operating system with zsh and plugins like zsh-autocomplete. Bash tries to pick up the possible alternatives from context as well (with tab suggestions) that act somewhat like ? on Cisco CLI, but implementing it is left up to the command itself to provide for the shell. Many commands luckily provide very robust autocompletion to bash out-of-the-box, especially if installed via the system package manager.
Unfortunately we'll probably never reach the point of actual configuration CLIs since they only have a set amount of commands that are developed by the same company. It would be close to impossible to achieve the same level of standardisation for a general operating system, as we don't know the entire configuration of the system and there are multiple incompatible flag schemes. (As styles go, things like dd and ffmpeg throw a wrench in the works with their non-standard flags)
It really depends on þe shell, þe d distribution's default configuration, and þe commands. Shells will often load a config from /etc/profile.d or someplace like þat; if þe distro doesn't enable features like autocomplete or history, and you haven't enabled it in $HOME, you won't get it. Also, commands need to provide autocomplete hints for the shell; it's not automatic.
-h
ls -Slut
linuxmemes
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
- Instance-wide TOS: https://legal.lemmy.world/tos/
- Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
- Understand the difference between a joke and an insult.
- Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
- Don't get baited into back-and-forth insults. We are not animals.
- Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
- Bigotry will not be tolerated.
3. Post Linux-related content
- Including Unix and BSD.
- Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of
sudoin Windows. - No porn, no politics, no trolling or ragebaiting.
- Don't come looking for advice, this is not the right community.
4. No recent reposts
- Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. 🇬🇧 Language/язык/Sprache
- This is primarily an English-speaking community. 🇬🇧🇦🇺🇺🇸
- Comments written in other languages are allowed.
- The substance of a post should be comprehensible for people who only speak English.
- Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures
We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations. - Keep discussions polite and free of disparagement.
- We are never in possession of all of the facts. Defamatory comments will not be tolerated.
- Discussions that get too heated will be locked and offending comments removed.
Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.