from Hacker News

Ask HN: Do you use the bash alias feature much?

by LoveGracePeace on 5/29/22, 4:25 PM with 10 comments

I tend to forget aliases I've set up and mostly use Ctrl+R to reverse search history and find the command I want if I've used it before. Either that or "history | grep <command_used_before>" if it was some time in the past. Aliases just don't stick in my memory.
  • by eulers_secret on 5/29/22, 4:50 PM

    I don't, because I SSH into a lot of machines - many are systems I don't own so can't really change things on. Or they'll be re-imaged in a day anyways.

    I almost always prefer to use what's available by default, that way what I memorize works anywhere.

  • by dredmorbius on 5/29/22, 5:30 PM

    Somewhat less with time, as bash functions are preferred and more powerful handle arguments, multi-step processing, logic).

    But yes, for basic arguments, particularly for ls:

      alias ls='ls -F'
      alias la='ls -A'
      alias ll='ls -l'
    
    Occasionally for other commands for which the default is not ideal. w3m, for example, will read the bookmarks file if URL is passed, with '-B', but otherwise exits with an error, which is annoying.

      alias w3m='w3m -B'
    
    Git commands, as others note.
  • by rurban on 5/29/22, 6:00 PM

    Yes. And I've setup a big .bash_alias to be scp'd to my machines.

    functions only for the complicated parts. about the same number of bash aliases as .gitconfig aliases.

  • by gigatexal on 5/29/22, 4:30 PM

    I mostly use functions not aliases but I’m not that much of a power user.
  • by flaburgan on 5/29/22, 4:33 PM

    I'm using them a lot for git. I have aliases for all the git commands.
  • by twangist on 5/29/22, 11:19 PM

    > Aliases just don't stick in my memory.

    `$ alias` will show you your aliases, and it's a pretty easy command to remember ;)

  • by cpc26 on 5/29/22, 6:04 PM

    cat .bash_aliases | wc -l

          61
    
    but yes alias command when I need to work on a system I aliased prior and have not used...

    https://en.wikipedia.org/wiki/Memory_span

  • by db48x on 5/29/22, 4:51 PM

    Sometimes. My favorite is alias primetime='watch -t -n 1 "factor \$(date +%s)"'