I am currently looking for a way to easily store and run commands, usually syncing files between two deeply nested directories whenever I want.

So far I found these projects:

Other solutions:

  • Bash history using ^+r
  • Bash aliases
  • Bash functions

What do you guys use?

  • tumulus_scrolls@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    Obvious things I don’t see mentioned:

    • Bash scripts kept in the home directory or another place that’s logical for them specifically.
    • history | grep whatever (or other useful piping), though your older commands are forgotten eventually. You can mess with the values of HISTSIZE and HISTFILESIZE environment variables in your system.
  • SymbolicLink@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    I wouldn’t install a program for this. You will end up relying on it when there are already some built in tools that can accomplish these things.

    1. Bash scripts placed in ~/bin or ~/.local/bin
    • Can have simple or complex scripts setup to do whatever you want
    • Easily called from terminal or automated through cron or systemd
    1. Environment variables set in -/.bashrc
    • Great for storing common paths, strings, etc.
    • Can be easily incorporated into bash scripts
    1. Aliases set in ~/.bashrc
    • Ideal (IMO) for common commands with preferred options
    • for example you could setup your most used rsync command to an alias: alias rsync-cust=“rsync -avuP”
  • jakoma02@czech-lemmy.eu
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    I did not know any of the programs mentioned in the post, but some of them seem really nice. Can someone who thinks aliases are a better solution please explain why they think so and what is their advantage over these projects? Do they have any pitfalls that you are aware of?

    I believe that if I use a command sparsely enough, I will forget the created alias name just a few days later than the actual command.

  • guacho@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    Fish shell. Out of the box it autocompletes taking into account in which directory you are. It’s like bash Ctrl+r but without actually invoking it before. Really ergonomic.

  • Scraft161@iusearchlinux.fyi
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    I have a file in my ~ called .alias and it is sourced by any shell I might use (currently just zsh) in it are common aliases like s => sudo and “sudo” => "sudo " (just put this as an alias if you use them a lot, you’ll thank me when you’re trying to use them with sudo)

    • jsveiga@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      I vi as the command line editor, so fetching history commands is quick:

      ESC /searchstring

      But if it’s something really frequent or may benefit from parameters, I usually throw a perl or bash script in /usr/local/bin.

  • codanaut@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    An alias file is what I’ve found to be the simplest. Just have to add one line to either .zshrc or .bashrc that links to the file. I store the alias file and some custom scripts that a few aliases call in a git repo so it’s literally just a matter of git pull, add one line to the rc file and then close and reopen the terminal and everything is ready to go.

    • WretchedRefrigerator@lemmy.zip
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Fish shell is great, but the more I’ve used it, the more incompatibilities I’ve found:

      • Can’t use subshells
      • Can’t use bash syntax (it would help if bass would process all commands by default)
      • Can’t use bash completions (there’s a script to do that, but it makes start very slow)

      Other than that, it just works by default (unlike zsh) and it works even better with an easy-to-install Tide

      • nlm@beehaw.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Yeah, it has its downsides. zsh with some addons is probably better overall. Or if you’re at least aware of it’s differences from bash and can work with that.

  • jsveiga@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    I use vi as the command line editor, so fetching history commands is quick:

    ESC /searchstring

    But if it’s something really frequent or may benefit from parameters, I usually throw a perl or bash script in /usr/local/bin.

  • beeng@lemmy.fmhy.ml
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    .zsh aliases to bash functions.

    Thanks for the list though, gonna take a look at a few!