2

In order to be able to launch my work environment with a single command, I want to start several urxvt windows running fish shell in different folders. However, I found no obvious way of having fish run a startup command (e.g. a cd) and not exit afterwards. Has anyone figured out how to do start fish in a particular directory without making it a default in config.fish?

2
  • 2
    Do the cd before starting fish (cd /x && urxvt) Commented Jun 22, 2014 at 21:27
  • urxvt always seems to start in my home dir.
    – avramov
    Commented Jun 22, 2014 at 21:29

2 Answers 2

5

Run cd from whatever is calling fish. For example, instead of urxvt -e fish, run

urxvt -e sh -c 'cd /wherever/you/want; fish'

Make that urxvt -e sh -c 'cd /wherever/you/want && fish' if you don't want the terminal to open if the directory doesn't exist.

1
  • This works for GNU screen configs as well, example in .screenrc : screen -t Projects 1 sh -c 'cd /home/my/projects/dir && fish' Commented Aug 5, 2020 at 16:45
0

For as long as I've been on StackExchange, I've been haunted by this problem where, as soon as I take the time to write up a question, I miraculously come across the answer.

For anyone who's trying to do the same, here's what I ended up doing.

If I add the following at the top of my config.fish:

cd $FISH_START_DIR

then I can do what I wanted to with the following command line:

$ urxvt -e /bin/bash -c 'FISH_START_DIR=<my required directory> fish'

Hacky, yes, but works a charm.
Sorry for the false alarm.

2
  • 2
    You don't want to do that. config.fish is interpreted by all the fish shells including those that interpret fish scripts or fish -c .... urxvt won't change the current directory. You probably have something wrong in your setup (for instance a cd alone or cd $unsetvar in your config.fish). Commented Jun 22, 2014 at 21:43
  • That line is the only thing that I currently have in config.fish. If FISH_START_DIR is unset, fish just starts in my home folder as usual, which is enough for the time being.
    – avramov
    Commented Jun 23, 2014 at 8:43

You must log in to answer this question.

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