I just realized that you can run a command at login by appending it to your .bashrc

For instance, I added a curl pointing to a certain address that immediately upon login returns a message that tells me whether I’m connected to my VPN provider or not.

Sorry for the beginner revelation. Just thought it was cool. :3

  • melroy@kbin.melroy.org
    link
    fedilink
    arrow-up
    2
    ·
    9 hours ago

    No its not like cron. The moment you open a terminal, the .bashrc script is automatically executed (for NON-login shells), but only when you start a terminal using bash. And it will get executed everything you open again a new shell/terminal.

    Using source, anyhow. It is true you can add anything you like to your .bashrc file… Often at the top you might have:

    case $- in
        *i*) ;;
          *) return;;
    esac
    

    This will return directly (stops) the bashrc script, since you do not want to this this script most likely when you are not running interactively.

    Its located in your home directory so: ~/.bashrc.

    Finally, .bashrc is often used for setting aliases, or extending your PATH, sourcing other files actually otherwise the bashrc file becomes too large (like bash auto complete). Normally you don’t want to execute scripts that take too long to execute.

    I do recommend looking in other improvements to your shell like https://starship.rs/