r/linux4noobs • u/SandvikDude • Jun 12 '26
shells and scripting Fish shell abbreviations is a godsend
Hi!
After my migration from Windows to Linux two or so months ago, I've been trying to learn how to use the terminal and be somewhat efficient and know about the basic functions like rm, mv, cp, ls, ln and such.
I've known about terminal aliases a while, but I found out about abbreviations on Fish yesterday and I absolutely love that feature.
Got any suggestions on other abbreviations/aliases I should use, or even other QoL features that I might not know about? Happy to learn!
•
u/InitHello Jun 12 '26
I have alias df='df -lThx tmpfs'
Because 89.374% of the time, I just want to df local partitions, displaying the fs type, with human readable sizes, and exclude tmpfs.
•
u/SandvikDude Jun 12 '26
I shamelessly stole this one. Thanks!
•
u/doc_willis Jun 12 '26
Also check out
pydf$ pydf Filesystem Size Used Avail Use% Mounted on composefs 48M 48M 0 100.0 [#########] / /dev/nvme1n1p2 973M 259M 647M 26.6 [##.......] /boot /dev/nvme1n1p1 599M 13M 586M 2.1 [.........] /boot/efi /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /etc /dev/sda1 3666G 2850G 630G 77.7 [#######..] /run/media/wil/moustache efivarfs 128k 45k 78k 35.0 [###......] /sys/firmware/efi/efivars /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /sysroot /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /sysroot/ostree/deploy/default/var /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /usr/share/pipewire /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /usr/share/wireplumber /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /var /dev/nvme1n1p3 3724G 1831G 1892G 49.2 [####.....] /var/home /dev/nvme0n1p2 914G 602G 265G 65.9 [######...] /var/home/wil/Drives/Steam2TB
•
u/AiwendilH Jun 12 '26 edited Jun 12 '26
alias ..="cd .." is not needed in fish (shell)...it does that already by default.
Personally I avoid alias as it hides what exact function is created....but that's just a personal preference i guess.
I also like it better to have one file per function in .config/fish/functions instead of all in fish.config, but I again I assume that's more personal preference.
Careful with wall...a command of the same name exists.
I totally agree with you on the usefulness...switching to fish is probably what improved my quality of life in linux most in the last ten years.
•
u/SandvikDude Jun 12 '26 edited Jun 12 '26
I was wondering why ".." was still working after I removed the functions file I created with funcsave the first time. Does it have that function going more than one directory back as well?
I had a few aliases created in /fish/functions at first, but found it easier to get back to them if needed, if they all were in the main config.fish file.
Thanks for the heads up on the wall command. I'll look it up.
•
u/AiwendilH Jun 12 '26
The "function" is actually that any directory name you type without anything else fish will
cdinto. Just type "Documents" in your home directory and fish will change in that directory...That's why it works with just "..". Every directory has a ".." directory in it that means the directory above. But it's also why it doesn't work with more than one level up...there is no "..." entry fish could use ;). (Hope that makes sense).
wallis probably more used on servers...but I am old enough to still know it as standard command available everywhere. It sends notifications to all connected terminals...similar to whatshutdowndoes to notify everyone. There is a good chance you will not really need it on a single user system...•
u/SandvikDude Jun 12 '26
I noticed that just a couple of days ago, that I don't have to cd into directories, which is also a fantastic feature.
But yes, it makes total sense. This is something not present in other shells like Bash or Zsh, correct?I probably wont be needing the wall command any time soon as it is (like you said) a single user system.
Could also just use Ctrl+Space if I ever needed to use it for some reason.•
u/AiwendilH Jun 12 '26
In bash you have to manually enable changing into directories by typing only the name with
shopt -s autocd(detail in bash man-page).zsh has a similar option I think...but not clue if it's enabled or disabled by default, sorry.
•
u/SandvikDude Jun 12 '26
I probably won't use neither unless it's some copy/paste POSIX stuff. But that's the reach of my knowledge as of now lol
•
u/yyg-linux Jun 12 '26
abbreviations do more harm than good because you're not learning the flag needed to pass to the argument to get the function that you're trying to do. once you swap environments or computers all those abbreviations are useless if you dont set your system up the /exact/ way as your home machine which isnt always an option.
•
u/SandvikDude Jun 12 '26
I have never touched a Linux system in my 30+ years of living until now. I do get your point, but I don't think I have to worry about doing terminal stuff on other places except my own. I appreciate your insight though!
•
u/yyg-linux Jun 12 '26
thats what you think now, but in 4 weeks youll be carrying around a raspberry pi and a mobile screen everywhere to avoid having to use windows. next week youll start keeping a flash drive in your pocket to boot into just incase.
•
u/SandvikDude Jun 12 '26
Haha, you know what? That might be true to some extent. I am planning to convert a friend of mine next week and already have Cachy loaded from when I used it myself.
But can't I just push my dots to Github and clone them when I need to? Never done it myself yet, but I plan to if it isn't all that hard and/or complicated
•
u/TanKer-Cosme Jun 12 '26
That is a nice looking fastfetch what is your config?
•
u/SandvikDude Jun 12 '26
It's a slightly stripped version of the 25.jsonc found in /usr/share/fastfetch/presets/examples/
Can preview it typing;
fastfetch --config examples/25.jsoncIf you want to set it as default, you can copy the .jsonc file and put it in your .config directory and renaming it to config.jsonc
mkdir -p ~/.config/fastfetch cp /usr/share/fastfetch/presets/examples/25.jsonc ~/.config/fastfetch/config.jsoncHope it helps
•
u/mystirc arch with sway Jun 12 '26
sudo to pls
•
u/InitHello Jun 12 '26
I have it aliased to
ffs, so I can doffs !!... but that's in zsh, never tried fish.•
u/AiwendilH Jun 12 '26
Not really necessary in fish...<alt><s> repeats the last line with a
sudoin front. (Or puts a sudo in front of your current line if you forgot to type it)•
u/mystirc arch with sway Jun 12 '26
wait fr? That's actually so fucking convenient. It takes a literal century to go all the way to the front of the command just to type sudo. You, Sir, are a real life saver.
•
u/AiwendilH Jun 12 '26
I can offer some more fish quality of life shortcuts ;) .
<alt><p> appends
&| /usr/bin/less..so pipes the output and error output to less for easier reading.<alt><h> opens the man-page for the command you have in the input...without deleting the line. You can quickly look up how you have to specify and argument and then just quit man and continue typing the command.
•
u/mystirc arch with sway Jun 12 '26
nvidia open source driver. hmmm...... uhh
I shouldn't worry I guess. But you won't be able to do graphically intensive tasks on them.
•
u/netleo Arch Linux Jun 12 '26
nvidia open-source =/= nouveau
nvidia open-source refers to the open-source kernel module version of the official nvidia driver. you can tell from the driver version that it's the official driver. it would also say nouveau otherwise.
•
u/mystirc arch with sway Jun 12 '26
ohhh, that's how it is. I don't really have an Nvidia card so I don't know much about these drivers. Thank you for clarifying. Might as well tag u/SandvikDude
•
u/SandvikDude Jun 12 '26
Appreciate the clarification. Was kinda worried I would have to mess with drivers there for a bit lol. Been close to smooth sailing ever since I migrated too haha
•
u/SandvikDude Jun 12 '26
Although, I haven't had any issues at all.
What difference would it make?•
u/mystirc arch with sway Jun 12 '26
Open source drivers are not good for gaming. Just try out the proprietary drivers in your favorite game. I literally just saw a Reddit post with the same 2080ti graphics card and he was using the open source novaeu drivers. He was getting 4 fps on the game he installed. I forgot it's name though. I'm not sure but I believe these drivers are used so that you don't get a black screen on boot. Although, work is being done to improve them but I don't think they are usable yet.
•
u/SandvikDude Jun 12 '26
Oh okay, that was news to me!
I will keep that in mind if I ever were to get any issues.
Thank you.•
u/netleo Arch Linux Jun 12 '26
you're using the right drivers, the proprietary ones aren't supported anymore
•
u/doc_willis Jun 12 '26
I think the 'open source' gets added in to the driver name in discussions when its not exactly correct, and causes some confusion.
"NVIDIA Linux open GPU kernel modules"
https://github.com/NVIDIA/open-gpu-kernel-modules
Unless they are actually talking about the nouveau drivers.
But I have not kept up on the state and naming fun of Nvidia products for the last year or two, so i may be overlooking some nuances. I thought the 'Nvidia Open' only had a part of it that was open sourced, and still used the closed source parts from the regular drivers.
Every time I try to read up on it, i get confused. :)
On some Install i did a few weeks ago, i saw it had an option between the "Nvidia Open Driver" and the "Nouveau 'open source'" driver, and some other options for that specific hardware.
•
u/netleo Arch Linux Jun 12 '26
you don't really need that alias for clear, Control + L does the same thing as the clear command (specifically 'clear -x', since by default 'clear' also clears your terminal history...so if you want that the alias is fine)
•
u/SandvikDude Jun 12 '26
That's useful information! I've always used 'clear' in the terminal, but I have retained every command I've ever used, so I'm a bit confused on that point
•
u/netleo Arch Linux Jun 12 '26
cachyos (also most other popular distros) saves your terminal history into a bash_history (or something to that effect) file, so that's probably why
•
•
u/CashRio Jun 13 '26
I've been casually using linux for about a year now and mainly use zsh for my terminal. This is the first time hearing of this feature. I will do some digging to see if this feature is present in zsh, seems like an alias on steroids.
•
u/brisbinchicken Jun 13 '26
Points for Spiritbox.
•
u/SandvikDude Jun 13 '26
It was actually the Maphra vocal cover this time, but Spiritbox is dope regardless \m/
•
u/howmuchiswhere Jun 13 '26
i have an abbr for setting abbr on the fly. a lot of times i'll be doing something as a one off so i don't want to add something to my fish config because i'll definitely forget to remove it later. creating them from the command line means they will be forgotten when the shell session ends.
abbr --add --set-cursor abbrp "abbr --add --position anywhere %"
abbr --add --set-cursor abbrc "abbr --add --set-cursor %"
and it turns out i've got a bunch that i wish i'd remembered because i'd use them all the time.
abbr --add --position anywhere devn "&> /dev/null"
abbr --add --set-cursor fh "find ./ -iname '*%*' | sort"
abbr --add --set-cursor fhf "find ./ -type f -iname '*%*' | sort"
abbr --add --set-cursor fhd "find ./ -type d -iname '*%*' | sort"
abbr --add --position anywhere --set-cursor awkp "| awk '{print %}'"
abbr --add --position anywhere --set-cursor seds "| sed 's/%/g'"
abbr --add --position anywhere wlc "| wl-copy"
abbr --add --position anywhere --set-cursor igrep "| grep -i -E '%'"
abbr --add --position anywhere --set-cursor vgrep "| grep -v -i -E '%'"
pipes are particularly handy, it's like snippets for the shell.
•
u/SandvikDude Jun 13 '26
Gonna be honest with you... This looks a bit too complicated for me at the moment lol
•
u/howmuchiswhere Jun 13 '26
ahh sorry, you seem savvy enough, but maybe what's intuitive to me is just a mess to you, and vice versa. to be honest, i think there's a reason i don't use these, and it's that it's more complicated than just doing the thing ha.
•
u/SandvikDude Jun 13 '26
I don't mind hard and complicated (lol, I know), but my brain is working overtime already with all of this new Linux stuff. I'll get there eventually, but I have to get through the basics first I think.
But yes, I do think you answered your question on why you don't use them yourself. In what scenario would you need these?
•
u/numarked Jun 13 '26
would you mind sharing the config?
•
u/SandvikDude Jun 13 '26
I haven't got Git up and running quite yet, but shoot me a msg and I'll see what I can do
•
Jun 15 '26
[removed] — view removed comment
•
u/SandvikDude Jun 15 '26
It what usecases would you need virtual environments in your terminal?
•
Jun 15 '26
[removed] — view removed comment
•
u/SandvikDude Jun 16 '26
That does sounds pretty useful (for me) to at least know about and keep that function in mind. I probably wont have a use for it at this moment in time though, but maybe in the future.
Getting everything setup just the way I like it takes some time, and then I will maybe start learning a coding language in my spare dad-time.Thank you!
•
•
u/ShitDonuts Arch Jun 29 '26
Don't really need all those cd aliases just use zoxide. Has smart history that remembers what directories you frequent. So if you changed directories to say '~/.config/helix' it would remember and you can run 'z helix' or even just 'z he' and it'll go to that directory. Just add 'zoxide init fish | source' to your config.fish so it works. As for other stuff you can use fish's complete command to make your own custom auto-completion results. Very powerful when you combine with your own functions that take arguments. I made a little function with this to switch audio outputs with nice completions for selection. Also you should switch to eza instead of using ls and add these aliases :
alias ls="eza --icons=always --group-directories-first"
alias ll="eza -lh --icons=always --git"
alias lt="eza --tree --level=2 --icons=always"
•


•
u/Dist__ Jun 12 '26
what's the difference with alias?