Search code examples
bashunixaliasgnu-screen

Unix bash alias not working after start screen


Hi I am having a problem with setting alias in mac after I start the screen command, I have alias for working with git, like

commit=git commit

they work as I expect when I start my terminal (iTerm2), but then sometimes I use screen to have simultaneous instances in remotes servers and virtual machines I work with. After this the alias disappear(command not found).

Does anyone know why or how solve it?


Solution

  • You need to make sure your aliases are defined in ~/.bashrc to ensure they get included in all logins. You can test this out: edit your ~/.bashrc to include this line:

    echo "bashrc"
    

    And then edit your ~/.bash_profile to include this line:

    echo "bash_profile"
    

    You'll see when you start screen that only "bashrc" is displayed.

    See this question for much more detail on the subject.