Skip to content

Epic: Improved support for user-defined shells (e.g. fish / zsh, etc) #10105

Closed
@axonasif

Description

@axonasif

Improve the support for user-defined shells such as zsh, fish, etc.

Includes, but not limited to:

  • Improve documentation around SHELL environment variable
  • Update Gitpod compatibility matrix
  • Update default workspaces images
  • Update any other parts of the product that assume bash (where possible)

Relates to:


Original issue description

Is your feature request related to a problem? Please describe

It would be nice to have Gitpod switch to the user defined(terminal.integrated.defaultProfile.linux ) SHELL after processing the task commands in bash.

Describe the behaviour you'd like

  • Imagine I have this on my .gitpod.yml:
tasks:
  - name: combined tasks
    command: echo "this is a command (combined)"
    before: echo "this is a before (combined)"
  • Upon workspace IDE start, I would see this on my task terminal:
Screenshot 2022-05-18 at 9 19 58 PM

Proposed solution

So, I think we could just put ; exec <user-shell>(only if the user is not using bash as default) at the end of the script that we're sending to the task terminal, which could look like:

 HISTFILE=/workspace/.gitpod/cmd-0 history -r; {
echo "this is a before (combined)"
} && {
echo "this is a command (combined)"
}; exec /usr/bin/fish # This here mainly

We might also need to consider having an option for .gitpod.yml to disable the switching behavior as someone might not want it to switch on some specific use case.

Describe alternatives you've considered

There are two ways I know of at this moment:

  1. Set SHELL env var in https://gitpod.io/variables or set in dockerfile to make the defined SHELL globally be used across the workspace, @akosyakov shared this trick 👍
    However, this will cause issues since many of the bash builtins are either not present in other shells or behaves differently. On the other hand, we also have non POSIX shells like fish.
  2. Append some custom logic(hijacking PROMPT_COMMAND) into $HOME/.bashrc to run exec <shell> upon detection of a task terminal and to switch only after the commands have been run. This is done via utilizing the dotfiles feature of Gitpod 1
    However, this is not a neat or straightforward method of doing this.

Additional context

Internal discussion on Slack.

Footnotes

  1. https://github.com/axonasif/dotfiles/blob/5d50fdc8a6fd171ecf3ddeed6443ca45e1f817f3/src/main.sh#L61

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions