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?

  • meow
    link
    fedilink
    12 years ago

    I’d say aliases and functions are your friends here.

    • @[email protected]
      link
      fedilink
      English
      2
      edit-2
      2 years 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
        link
        fedilink
        English
        22 years 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.

  • @[email protected]
    link
    fedilink
    4
    edit-2
    2 years 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.
  • jsveiga
    link
    fedilink
    12 years 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.

  • @[email protected]
    link
    fedilink
    12 years ago

    Try fzf. The default hooks will launch fuzzy finders for

    • C-r: history search
    • Alt-c: change directory
    • C-t: fill in argument for a nested path

    All seem pretty good for your use case.

  • @[email protected]
    link
    fedilink
    4
    edit-2
    2 years ago

    I wouldn’t install a program for this if your use case is simple. You will end up relying on it when there are already some built in tools that can get you 99% of the way there.

    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”

    Edit: rephrased to not discount the tools shared. I am sure if you had a specific reason to use them they could be helpful. But I think for many users the above options are more than enough and are supported pretty universally.

    • @[email protected]OP
      link
      fedilink
      22 years ago

      I more or less was just looking for a general survey of what other people used.

      I agree installing a binary for this small kind of thing might be excessive.

      • @[email protected]
        link
        fedilink
        12 years ago

        Yeah, potentially overkill, but all the power to anyone who wants to try them out. Freedom of choice is one of the best parts of Linux.

        And sorry for the long response. It’s hard to gauge the proficiency that someone might have with Linux, so I tend to lean towards detailed explanations just in case

  • @[email protected]
    link
    fedilink
    32 years 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.

  • @[email protected]
    link
    fedilink
    22 years 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
      link
      fedilink
      12 years 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.