Based on three questions:

tl:dr – for example:

  • .zshrc
if [ -f /usr/bin/tilix ]; then
  if [ -f ~/tilix.zshrc ]; then
    source ~/tilix.zshrc
elif [ -f /usr/bin/deepin-terminal ]; then
  if [ -f ~/deepin-terminal.zshrc ]; then
    source ~/deepin-terminal.zshrc
elif [ -f /usr/bin/code-insiders ]; then
  if [ -f ~/code-insiders.zshrc ]; then
    source ~/code-insiders.zshrc
    source ~/tilix.zshrc
  • And the files Deepin Terminal's and Tilix's desktop files:
Exec=bash -c 'source $HOME/deepin-terminal.zshrc && deepin-terminal'
Exec=bash -c 'source $HOME/tilix.zshrc && tilix'
  • VSCode's settings.json:
  "terminal.integrated.shell.linux": "source $HOME/code-insiders.zshrc && /usr/bin/zsh"

But nothing worked.

Maybe I should use devilspie, but I am not sure if it will work.

1 Answer 1


From the terminal side

In the configuration of each terminal or terminal launcher, arrange to set an environment variable, e.g. TERM_SUBTYPE=tilix or TERM_SUBTYPE=deepin or TERM_SUBTYPE=vscode. In your .zshrc, check the value of this variable:

  tilix) …;;
  '') …;;

The '') line is the case when nothing has set TERM_SUBTYPE. You can leave it out if you have nothing to do in this case.

From the shell side

The terminal emulator is usually the parent of the shell, so check the parent process.

case ${$(ps -p $PPID -o comm=):t} in
  tilix) …;;
  deepin-terminal) …;;
  code-insiders) …;;
  *) …;

The *) line is a fallback if the parent process is not one of the recognized cases. You can leave it out if you have nothing to do in this case.

  • Should it be ;; instead of ;? It seemed that none of them worked yet. I am using Arch Linux. Does Arch Linux understand TERM_SUBTYPE when it does not exist? Sep 29, 2019 at 10:33
  • AH, based on the first of three question cited above, I replaced for ps -o comm= -p $PPID, and it worked now. But I am waiting for your answer about TERM_SUBTYPE. Sep 29, 2019 at 10:37
  • @GustavoReis ; instead of ;; was a typo, I've fixed it. I've also added an explanation of the case when TERM_SUBTYPE is not set. Do note that TERM_SUBTYPE is a name that I made up: to use this solution, you need to configure each of your terminals to set it (and I don't know any of the three you mentioned so I can't help you there). Sep 29, 2019 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.