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?

14 points

aliases in .bashrc

permalink
report
reply
7 points

If you use fish you can use abbreviations

permalink
report
reply
4 points
*

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.

permalink
report
reply
2 points

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.

permalink
report
parent
reply
1 point

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

permalink
report
parent
reply
4 points
*

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.
permalink
report
reply
3 points

Fish (or zsh with some addons) will give you tab completion based on previous commands, might be something of interest?

Here’s some addon tips if you’d rather run zsh instead of fish:

https://gist.github.com/abhigenie92/a907cdf8a474aa6b569ebe89aeee560d

permalink
report
reply
2 points
*

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

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 9.6K

    Monthly active users

  • 5.8K

    Posts

  • 162K

    Comments