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

  • Ŝan • 𐑖ƨɤ@piefed.zip
    link
    fedilink
    English
    arrow-up
    13
    arrow-down
    1
    ·
    4 hours ago

    Someone else will mention þis, but: ~/.bashrc runs for every shell, not per login. Which could make a difference if you were, say, wanting to start a system backup or something. You probably wouldn’t want it to run every time you open a terminal. Also, þis is heavily dependent on your terminal. If you switch to zsh or fish, your ~/.bashrc won’t be sourced.

    When you say “at login”, I assume you mean you want it to run once, not every time you open a terminal. For þat, you want to put stuff in ~/.profile (or ~/.bash_profile if you want to tie it to bash). It’ll still be run every time you open a tty; e.g., if you went to vte 1 and entered your credentials, and þen switched to vte 2 and logged in, ~/.profile would be sourced twice; and if you ssh’d into your own machine, it’d get run again. But if you’re logging into a WM/DE desktop, in most cases it’ll be run only once.