Linux: aliases when using `screen`

6

2

I'm using screen, and I have several aliases in my ~/.bash_profile, for example python=python-2.6. But for some reasons these aliases don't work when I work in screen. How can I make them work?

Ram Rachum

Posted 2010-12-03T15:19:43.023

Reputation: 4 261

I want to open multiple new windows in screen and execute my alias in each of those, ie, "screen -t window1 my_alias". Any idea how to do that? – cat pants – 2013-05-05T17:46:33.257

Answers

4

.bash_profile gets run when in a login shell. You'll probably want to put your aliases in the .bashrc file. Or you could just execute your .bash_profile each time that you start up a shell in screen

dmah

Posted 2010-12-03T15:19:43.023

Reputation: 406

3

Use the -l option to bash in your .screenrc to start your screen session's bash shells as login shells:

screen bash -l

Doug Harris

Posted 2010-12-03T15:19:43.023

Reputation: 23 578

Using this method you would have to type "exit" twice - once to exit the additional bash session, and then second time to exit screen. – pako – 2016-08-04T21:51:02.373

The same applies to the original question. The example I showed here was for a .screenrc file to open the shell as a login shell. – Doug Harris – 2016-08-05T02:48:33.233

3

Add this line to your ~/.screenrc file:

shell -/bin/bash

The initial dash executes the shell with login option

dvdvck

Posted 2010-12-03T15:19:43.023

Reputation: 141

0

If you run exec bash after you start up screen, they will work

David Oneill

Posted 2010-12-03T15:19:43.023

Reputation: 2 381