5

In my .screenrc, I have several lines similar to the following:

screen -t qf1 bash

So for that window, I am currently executing bash. Instead, I would like to execute the following alias "qf" which is a bash alias that executes lynx for a certain URL.

However, I get the following error:

"Cannot exec 'qf': No such file or directory"

I know it probably has something to do with the path, but providing:

screen -t qf1 lynx www.google.com

Doesn't work either. I know I'm missing something obvious. Thanks!

1

1 Answer 1

6

Most likely, your bash aliases are not available to screen. There's a couple ways to fix this.

  • If your aliases are in .bash_profile, move them to .bashrc
  • Start your bash shells with the -l switch to force bash to parse .bash_profile

Have a look at this question for a similar issue.

EDIT

There's actually two things that keep this from working:

Use bash's command-string syntax to pass commands to the new window

    screen -t "YayScreen" bash -c "man screen"

Aliases are a pain in screen

Create a bash script with the desired name in your $PATH (say, /bin), and call that in the same way as the above example. For example, I have a very simple alias called psgrep that looks for a process by name. I create this script as /bin/psgrep:

#!/bin/bash
ps aux | grep -v grep | grep $1

Then I can add this to my .screenrc:

screen -t "Useless Command" bash -c "psgrep gnome"

See this old Mac OS X forum post for a longer list of what didn't work.

6
  • Ok, I tried doing "screen -t qf1 bash -l qf" with no luck. I did see that question already. I think this question is more about the syntax of .screenrc.
    – cat pants
    May 7, 2013 at 3:21
  • Ah. I didn't read your original question closely enough. Adding another answer now.
    – Lemur
    May 7, 2013 at 18:08
  • 1
    Or just an edit. That works, too.
    – Lemur
    May 7, 2013 at 19:51
  • Perfect, that is exactly what I needed. Thanks a ton!!
    – cat pants
    May 8, 2013 at 20:25
  • My aliases are in .bashrc and i still can't use them with screen
    – chovy
    Sep 23, 2019 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .