this post was submitted on 30 Dec 2024
49 points (100.0% liked)

Programming

17705 readers
255 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
top 14 comments
sorted by: hot top controversial new old
[–] nous@programming.dev 21 points 3 days ago (6 children)

I seem to be one of very few people that does not use shell aliases. I much prefer just using the reverse history search for previous commands instead. That way I don't have to remember what letter I picked for different things, just ctrl+r then partially type out the command and I can see what it will execute. Bonus that I don't need to set them up before hand and that I can edit them before executing them for those times when I need to do something slightly different.

[–] salmoura 9 points 3 days ago (1 children)

I'm also in that camp. FZF is a life saver.

[–] jbrains@sh.itjust.works 4 points 3 days ago

Yes! I raise you atuin.

[–] SwordInStone@lemmy.world 5 points 3 days ago (1 children)

you might want to take a look into shell abbreviations

e. g.

https://github.com/olets/zsh-abbr

[–] nous@programming.dev 2 points 3 days ago (1 children)

TBH, not quite the same. You have to know which one you want. If you don't quite or get it wrong you need to clear the line and start again. I quite like that I can reverse search and keep typing, or undo what I had typed and still see a list of the most recent things and can select from that list once I see what I want. This works for any command I have previously typed and dont need to setup specific key sequences for it - just any part of that command will find it again. Also works for complex chains of commands or pipes which I do not think aliases do work for.

[–] asret@lemmy.zip 3 points 3 days ago

I quite like adding a fuzzy finder to the history search - helps when I can only remember part of the command line I was using. Have just started using atuin.sh which seems okay.

[–] atzanteol@sh.itjust.works 5 points 3 days ago (1 children)

No, I'm the same. I started down that road but found myself too dependent on a lot of custom scripts and aliases. It became a pain when I used unix and Linux systems at work, or work in containers, etc.

[–] nous@programming.dev 5 points 3 days ago

I used to know a guy that would put everything into aliases or scripts in order to avoid remembering them. It worked well most of the time but when something went wrong or was not covered by his scripts he would struggle a lot. He avoided learning the underlying commands and what they did and so could not adapt to things when circumstances changed even a little - which does happen quite a lot.

Which is probably another reason I don't use them. I don't like to set them up straight away while I am learning the tool and once I am comfortable with it a reverse history search is good just as good/quick as a true alias anyway and means I never forget what I am doing and can edit it on the fly easily when needed.

[–] bad_news@lemmy.billiam.net 5 points 3 days ago (3 children)

I make ~/bin scripts that can be saved, then you have a backlog of real, backed up scripts you can add to path anywhere

[–] MajorHavoc@programming.dev 5 points 3 days ago

I'm an apprentice to both your ways.

I create a tidy backed up script in ~/bin, and then I only ever evoke it from my bash history, because otherwise I don't remember I had it.

[–] syklemil@discuss.tchncs.de 1 points 3 days ago

Yeah, that's what I do for complex stuff. Aliases are pretty handy too, but I use them for stuff like "v=nvim" and "vd=nvim -d". Also one function for fd to "nvim $(rf -l $1)"

[–] nous@programming.dev 1 points 3 days ago

I do use scripts for more complex things. But even then I have a few very frequent one liners in my history that are 3-4 commands chained together that I have not bothered to convert. It tends to only be when they start to have logic in them that I will write a script for. Or more one off commands that are easier to edit in a multi line editor then trying to get everything right in the shells prompt.

[–] MonkderVierte@lemmy.ml 3 points 3 days ago* (last edited 3 days ago)

I do use aliases, though differently too. For example, i use multiple distros. Instead of "uh, what was the xbps command to find what package contains this file?" i just have it automatically set to a bunch of aliases in a case switch based on package manager. Another one; some tools that follow XDG only optionally via parameter.

[–] dinckelman@lemmy.world 1 points 3 days ago

Any time a shell alias would be useful, i have to setup an equivalent of a makefile anyway. My current setup has no aliases active, for the same reasons as you