I'm on CentOS 7.9 (Gnome Terminal 3.28.2) with csh (yeah I know but work requirement) as my default shell. My problem is this: whenever I open a new tab in gnome terminal, the new tab redirects to ~/, rather than preserving the path of the old path. Say I'm currently at /home/myself/project1/src/, I'd like my new tab to also be at /home/myself/project1/src/, not back to /home/myself.

On our super old CentOS 6.10 machines (Gnome Terminal 2.31.3) where users are also using csh as default, new tabs do preserve old paths as we want it.

Meanwhile, bash doesn't show any problems. Whether on 6.10 or 7.9, users using bash as the default shell always keep their old path when opening new tabs.

It seems like my issue is both related to the shell and Gnome Terminal. Frustratingly, the /etc/csh.cshrc files on both CentOS 6.10 and 7.9 machines look the same, and I failed to find any toggles in Gnome Terminal's preferences.

So back to the title, when using csh how can I let a new tab open start from the path of the old tab in gnome terminal instead of going back to ~/? Many Thanks!

  • When you just start a new csh shell, is your path preserved?
    – aviro
    Feb 14, 2022 at 8:04
  • @aviro Hi, I always start a new shell by right-clicking my mouse and choose Open Terminal (when right-clicking on the Desktop) or Open in Terminal (when right-clicking in a folder). Open Terminal starts the shell at ~, whereas Open in Terminal starts the shell at wherever I opened it (~/Documents for example). New tabs will always start at wherever the new shell started. If the new shell window started at ~/Documents, and I cd to ~/Documents/project1, then open a new tab, the new tab will start at ~/Documents, not project1
    – NoobAdmin
    Feb 18, 2022 at 8:07

1 Answer 1


You need to emit the OSC 7 escape sequence, with its parameter being the URI of the current working directory, in URI-encoded format. This tells the terminal emulator what the working directory is, and thus in turn lets it launch new tabs/windows in that same directory.

You might want to look at /etc/profile.d/vte.csh and /etc/profile.d/vte-2.91.sh for an idea how to do this, including the use of the helper binary /usr/libexec/vte-urlencode-cwd that performs URI-encoding. The exact pathnames might slightly vary across systems.

/etc/profile.d/vte.csh seems to check for the shell being tcsh. I don't know if it uses anything that wouldn't work for plain old csh, or how to hook it up in csh to some appropriate place (e.g. when the prompt is printed, or when the directory is changed). Or maybe it works in csh as well, you just have to remove the tcsh check. I'm not familiar with csh or tcsh at all, so I leave this part for you as an exercise.

You must log in to answer this question.

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