Use a different shell by default in each terminal emulator

7,735

Solution 1

Each terminal emulator has its custom way to select which shell to run:

  • gnome-terminal has the run a custom command instead of my shell field in the profile editor.
  • xterm (and pterm) uses xrdb database to store its configuration but do not allow to configure the command to run. You could write a simple shell script that wraps the xterm executable to give him an executable parameter.
  • konsole has the command field in the profile editor.

So you need to discover, by reading the manual, how (and if) each terminal emulator can be configured. There is no common way :-(

If you need only a simple way to choose which shell to run, I strongly suggest you to choose a terminal emulator that supports profiles (like gnome-terminal) and to create a different profile for each shell type. This way you'll can launch a new tab or window running the needed shell by the gnome-terminal internal menu (and, as bonus, choose a different text color for each shell).

Solution 2

As a quick and contained solution, you could make a wrapper script.

case "$1" in
   xterm) shell=/bin/tcsh ;;
   pterm) shell=/bin/pysh ;;
   gnome-terminal) shell=/bin/bash ;;
   *)
       printf "Not supported: %s\n" "$1" >&2
       exit 1
esac

SHELL="$shell" "$1"

Just use it as such: thescript <terminal_emulator>.

It's generally preferable to configure each terminal emulator individually though.

Share:
7,735

Related videos on Youtube

Devyn Collier Johnson
Author by

Devyn Collier Johnson

See http://dcjtech.info/about-the-crew/#devyncjohnson for information about me and visit http://dcjtech.info/ to learn more about computers.

Updated on September 18, 2022

Comments

  • Devyn Collier Johnson
    Devyn Collier Johnson over 1 year

    I would like to change the default shell in each terminal emulator separately. To clarify, I want xterm to use tcsh, pterm to use pysh, gnome-terminal to use bash, etc. Is this possible? If so, how can this be accomplished?