I created a shell app that started out as aliases and got out of hand.

The "app" provides shell functions that call yt-dlp, a video downloader, and organizes the downloads in a solid directory structure.

I currently load the app with one line in bash.bashrc, the .bashrc equivalent in Termux (terminal emulator for Android).

The one line in bash.bashrc that loads the shell app

. /path/to/main

main loads up the rest and its contents looks like this

. "$bin_dir/vars"
. "$bin_dir/common"
. "$bin_dir/logger"
. "$bin_dir/history"
. "$bin_dir/files"
. "$bin_dir/dlv"
. "$bin_dir/fvid"

These are all bash scripts that expose functions and variables to the terminal, making them available to the user. The loading order is important, dlv depends on stuff in common for example.

Now I'd like to open source the project and make it easy to install. I wonder if I can load the shell app without an entry in bash.bashrc.

I thought about putting the scripts in $PREFIX/bin/ but then if someone calls dlv, all other dependencies haven't loaded.

I could throw everything in one file but my intention was to create these modules to keep the code tidy.

I guess without a more elegant solution, I could write an install.sh that does echo ". /path/to/main" >> ~/bash.bashrc... Thoughts?

Edit: I put main (loader) in $PREFIX/bin but when I run the command, none of the functions and variables are available in my shell. I did not expect that.

  • Adding this to .bashrc will start your "app" everytime a shell is started - I don't think that's what you want, is it?
    – Panki
    Aug 20, 2022 at 12:55
  • @Panki It is what I want because it only loads functions and variables to be used by the user. It doesn't actually do work at load time.
    – progonkpa
    Aug 20, 2022 at 12:59
  • But as a user of your app, do I want this to happen? Do I want this to run every time I start a new shell? Wouldn't it be more sensible to have the user run something like app-init first?
    – Panki
    Aug 20, 2022 at 13:00
  • That's probably a good idea. Put main under bin and have main load the rest of the scripts in /opt perhaps? One can still add main to .bashrc if they want.
    – progonkpa
    Aug 20, 2022 at 13:06
  • 1
    Are you using the Termux widget add on? If so, you could create a launcher script in ~/.shortcuts that runs bash -i --rcfile /path/to/main and you should get an interactive bash prompt with the functions in those files pre-sourced, without modifying the default Termux settings. (BTW, please learn what the word "boot" means.) Don't mess up the default .bashrc.
    – frabjous
    Aug 20, 2022 at 13:27

1 Answer 1


The solution I came up with was to drop the need to be able to run main and run source main instead.

It's not clear to me why just running main, which contains source commands, doesn't work but this workaround is not too bad.

By putting main in $PREFIX/bin, the OS can find main in $PATH. This will work on all Termux installs as $PREFIX/bin is in Termux $PATH by default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .