hello friends,

I am looking for a way to do what I described in the title. When running command command, I dont want to have to type SOME_ENV_VAR=value command every time, especially if there are multiple.

I am sure youre immediately thinking aliases. My issue with aliases is that if I do this for several programs, my .bashrc will get large and messy quickly. I would prefer a way to separate those by program or application, rather than put them all in one file.

Is there a clean way to do this?

  • Kajika@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    You can add a new executable in your ~/.local/bin directory like command_custom that would start SOME_ENV_VAR=value command. Like if you use bash:

    #!/usr/bin/bash
    
    SOME_ENV_VAR=value command
    

    Do not forget to chmod +x the file to make it executable.

    This way you will have additional command for your user only (no sudo require to create/update those), for system-wise command put it in /usr/local/bin.