SOLFIND
Web Lens
Portal home

Changing the shell in a codespace - GitHub Docs

https://docs.github.com/en/codespaces/customizing-your-codespace/changing-the-shell-in-a-codespace • 234 KB fetched
Open original page


Changing the shell in a codespace - GitHub Docs Skip to main content GitHub Docs Version: Free, Pro, & Team Search or ask Copilot Search or ask Copilot Select language: current language is English Search or ask Copilot Search or ask Copilot Open menu Collapse sidebar Expand sidebar Scroll breadcrumbs left * Home * Codespaces * Customizing your codespace * Change your shell Scroll breadcrumbs right Codespaces * * * Quickstart * Getting started * What are Codespaces? * Codespaces features * The codespace lifecycle * Deep dive into Codespaces * Developing in a codespace * Develop in a codespace * Create a codespace for a repo * Create a codespace from a template * Delete a codespace * Open an existing codespace * Work collaboratively * Source control * Pull requests * Stop a codespace * Forward ports * Rebuilding a container * Default environment variables * Persist variables and files * Connecting to a private network * Machine learning * Visual Studio Code * GitHub CLI * Customizing your codespace * Rename a codespace * Change your shell * Change the machine type * Setting your user preferences * Personalize your codespaces * Set the default editor * Set the default region * Set the timeout * Configure automatic deletion * Choose the host image * Setting up your project * Adding a dev container configuration * Introduction to dev containers * Setting up a Node.js project * Setting up a C# (.NET) project * Setting up a Java project * Setting up a PHP project * Setting up a Python project * Configuring dev containers * Set a minimum machine spec * Adding features * Automatically opening files * Specifying recommended secrets * Setting up your repository * Facilitating codespace creation * Set up a template repo * Prebuilding your codespaces * About prebuilds * Configure prebuilds * Allow external repo access * Manage prebuilds * Test dev container changes * Managing your codespaces * Codespaces secrets * Repository access * Security logs * GPG verification * Managing your organization * Enable or disable Codespaces * Billing and ownership * List organization codespaces * Manage Codespaces costs * Manage secrets * Audit logs * Restrict machine types * Restrict codespace creation * Restrict base image * Restrict port visibility * Restrict timeout periods * Restrict the retention period * Reference * Access a private registry * Copilot in Codespaces * VS Code Command Palette * Security in Codespaces * Disaster recovery * Troubleshooting * Codespaces logs * Codespaces clients * Included usage * Exporting changes * Creation and deletion * Authenticating to repositories * Connection * Codespaces prebuilds * Personalization * Port forwarding * GPG verification * Working with support * github.dev editor Changing the shell in a codespace You can change your shell in a codespace to keep the setup you're used to. Copy as Markdown In this article * Changing from the default shell in VS Code * Installing a new shell * Setting the default shell in VS Code * Setting the default shell over SSH * Configuring your shell * Further reading When you're working in a codespace, you can open a new terminal window with a shell of your choice, change your default shell for new terminal windows, or install a new shell. You can also use dotfiles to configure your shell. Codespaces that use the default dev container image come with the bash , zsh , and fish shells installed. If you open a new codespace in the VS Code web client, or connect to a codespace over SSH, the terminal opens with a bash session running by default. In the VS Code desktop application, the default shell depends on your local settings and operating system. For more information, see Terminal Profiles in the VS Code documentation. Changing from the default shell in VS Code If you don't want to use the default shell, you can open a new terminal session with a different shell. * If you cannot see the integrated terminal in VS Code, press Ctrl + ` . * To the right of the icon for opening a new terminal window, select the dropdown icon. * In the dropdown menu, click the name of the shell you want to use. Installing a new shell If you want to use a shell that isn't already installed in the base image or dev container configuration for a codespace, you can install a new shell. If you're using the default dev container image, look for installation instructions for Ubuntu Linux. If you just want to use a different shell for one session, you can use the command line to install the shell in the codespace you're working in. However, you may lose programs you have installed if you rebuild the container in the codespace. For more information, see Deep dive into GitHub Codespaces . A more robust option for installing new shells is to include the installation commands either in a dotfiles repository, or as a lifecycle command such as postCreateCommand in a devcontainer.json file. You should use a dotfiles repository to install a shell you want to use in all your own codespaces, and a devcontainer.json file for a shell that contributors to a specific repository should have installed. For more information, see Personalizing GitHub Codespaces for your account and Introduction to dev containers . Adding a VS Code terminal profile for a new shell VS Code automatically detects most standard shells and adds them as a terminal profile, so you can easily open new terminal windows using the shell you have installed. If the shell you install isn't detected automatically, you can add a new terminal profile to your user settings. This setting is dependent on your operating system, so you should use linux for the VS Code web client and your local operating system for the desktop application. * To open the Visual Studio Code Command Palette, press Command + Shift + P (Mac) or Ctrl + Shift + P (Windows). * Start typing "user settings," then click Preferences: Open User Settings (JSON) . * In the settings.json file, inside the JSON object, add a new property like the following. Replace OPERATING-SYSTEM with the relevant operating system (such as linux , windows , or osx ) and SHELL with the shell you have installed. JSON "terminal.integrated.profiles.OPERATING-SYSTEM": { "SHELL": { "path": "SHELL" } } "terminal.integrated.profiles.OPERATING-SYSTEM" : { "SHELL" : { "path" : "SHELL" } } For example: "terminal.integrated.profiles.linux" : { "csh" : { "path" : "csh" } } * Save the file. You can use Settings Sync to share these settings across all codespaces you open in the VS Code web client and desktop application. If you're working in the web client, Settings Sync is disabled by default, and you must enable Settings Sync to push changes to your settings or pull in new changes you have made elsewhere. For more information, see Personalizing GitHub Codespaces for your account . Setting the default shell in VS Code You can set a default terminal profile to choose the default shell used for all new terminal windows you open in VS Code. The default terminal profile is dependent on your operating system, so you can set a default profile for Linux, if you're using the VS Code web client, or for your local operating system, if you're using the desktop application. Note Regardless of your default profile, codespaces opened in the web client always open with a bash session running initially. * To open the Visual Studio Code Command Palette, press Command + Shift + P (Mac) or Ctrl + Shift + P (Windows). * Start typing "user settings," then click Preferences: Open User Settings (JSON) . * Inside the JSON object, to set the default shell for the relevant operating system, add lines or edit existing lines like the following. "terminal.integrated.defaultProfile.OPERATING-SYSTEM" : "SHELL" For example: JSON { "terminal.integrated.defaultProfile.osx": "zsh", "terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.defaultProfile.windows": "PowerShell" } { "terminal.integrated.defaultProfile.osx" : "zsh" , "terminal.integrated.defaultProfile.linux" : "bash" , "terminal.integrated.defaultProfile.windows" : "PowerShell" } * Save the settings.json file. You can use Settings Sync to share these settings across all codespaces you open in the VS Code web client and desktop application. If you're working in the web client, Settings Sync is disabled by default, and you must enable Settings Sync to push changes to your settings or pull in new changes you have made elsewhere. For more information, see Personalizing GitHub Codespaces for your account . Setting the default shell over SSH When you connect to a codespace from the command line over SSH, you connect to a bash session in the codespace by default. If you have enabled a dotfiles repository for GitHub Codespaces, you can change the default shell you connect to by adding a command to an installation script such as install.sh in your dotfiles. For more information, see Using GitHub Codespaces with GitHub CLI and Personalizing GitHub Codespaces for your account . For example, the following command changes the default shell to zsh . Shell sudo chsh "$(id -un)" --shell "/usr/bin/zsh" sudo chsh "$(id -un)" --shell "/usr/bin/zsh" If you want to use a default shell that isn't installed in your codespace by default, or ensure you have the latest version of the shell, you can install the shell first. Shell sudo apt-get update -y sudo apt-get install -y csh sudo chsh "$(id -un)" --shell "/usr/bin/csh" sudo apt-get update -y sudo apt-get install -y csh sudo chsh "$(id -un)" --shell "/usr/bin/csh" Note If you create a new codespace (for example by using gh codespace create ), you must wait sufficient time to ensure the script has finished running before you connect to the codespace over SSH. If the script hasn't finished running, you will connect to a default bash session. When you have connected to the codespace, for most shells, you can use the command readlink /proc/$$/exe to check the correct shell is running. Configuring your shell With most shells, you have the option of using a configuration file, such as .bashrc , to configure the shell with your preferred settings. These settings can include things like aliases and environment variables. By default, codespaces contain predefined configuration for the shells that come preinstalled. For example, the home directory in a codespace contains .bashrc and .zshrc files. You can change the contents of these files then use a command like source ~/.bashrc to update your shell configuration. However, you will lose any changes to these files if you rebuild the container in a codespace. For more information, see Deep dive into GitHub Codespaces . Generally, you should use a dotfiles repository to configure shells with your preferred settings. The setup in your dotfiles applies to all codespaces you create, and persists over rebuilds of the container. For more information, see Personalizing GitHub Codespaces for your account . Troubleshooting the fish shell The fish shell includes a web-based configuration interface. You can use the fish_config command to start a local web server and launch this interface, then do things like change the terminal prompt or view your environment variables. You can use the web-based interface for fish in a codespace. However, the color settings in VS Code's integrated terminal depend on your chosen VS Code theme, and you cannot override these settings by setting a new theme in the fish_config interface. When fish starts the local server, the default link that GitHub Codespaces provides to the forwarded port does not work. For example, if you click Open in Browser on the popup message, you will be taken to an error page. To access the web-based interface for fish_config : * In a terminal running a fish session, enter fish_config . * In the terminal output, use Command +click or Ctrl +click to open the link to the web_config HTML file. $ fish_config Web config started at file:///tmp/web_config60rc9tr3.html Hit ENTER to stop. * In the web_config file, use Command +click or Ctrl +click to open the link to the forwarded port. < body > < p > < a href = "http://localhost:8000/1b9411c2469e392b96df5e5b28da485b/" > Start the Fish Web config </ a > </ p > </ body > Further reading * Setting your user preferences * Managing your codespaces Back to top Help and support Was this Doc helpful? Yes No Help us make GitHub Docs great! All Docs are open source. See something that's wrong or unclear? Submit a pull request. Make a contribution Still need help? Provide GitHub Feedback Contact support Expert services Blog GitHub Inc. © 2026 Terms Privacy Status Pricing

Links found on this page

  1. Skip to main content [direct]
  2. GitHub Docs [direct]
  3. Codespaces [direct]
  4. Customizing your codespace [direct]
  5. Quickstart [direct]
  6. What are Codespaces? [direct]
  7. Codespaces features [direct]
  8. The codespace lifecycle [direct]
  9. Deep dive into Codespaces [direct]
  10. Develop in a codespace [direct]
  11. Create a codespace for a repo [direct]
  12. Create a codespace from a template [direct]
  13. Delete a codespace [direct]
  14. Open an existing codespace [direct]
  15. Work collaboratively [direct]
  16. Source control [direct]
  17. Pull requests [direct]
  18. Stop a codespace [direct]
  19. Forward ports [direct]
  20. Rebuilding a container [direct]
  21. Default environment variables [direct]
  22. Persist variables and files [direct]
  23. Connecting to a private network [direct]
  24. Machine learning [direct]
  25. Visual Studio Code [direct]
  26. GitHub CLI [direct]
  27. Rename a codespace [direct]
  28. Change the machine type [direct]
  29. Personalize your codespaces [direct]
  30. Set the default editor [direct]
  31. Set the default region [direct]
  32. Set the timeout [direct]
  33. Configure automatic deletion [direct]
  34. Choose the host image [direct]
  35. Introduction to dev containers [direct]
  36. Setting up a Node.js project [direct]
  37. Setting up a C# (.NET) project [direct]
  38. Setting up a Java project [direct]
  39. Setting up a PHP project [direct]
  40. Setting up a Python project [direct]
  41. Set a minimum machine spec [direct]
  42. Adding features [direct]
  43. Automatically opening files [direct]
  44. Specifying recommended secrets [direct]
  45. Facilitating codespace creation [direct]
  46. Set up a template repo [direct]
  47. About prebuilds [direct]
  48. Configure prebuilds [direct]
  49. Allow external repo access [direct]
  50. Manage prebuilds [direct]
  51. Test dev container changes [direct]
  52. Codespaces secrets [direct]
  53. Repository access [direct]
  54. Security logs [direct]
  55. GPG verification [direct]
  56. Enable or disable Codespaces [direct]
  57. Billing and ownership [direct]
  58. List organization codespaces [direct]
  59. Manage Codespaces costs [direct]
  60. Manage secrets [direct]
  61. Audit logs [direct]
  62. Restrict machine types [direct]
  63. Restrict codespace creation [direct]
  64. Restrict base image [direct]
  65. Restrict port visibility [direct]
  66. Restrict timeout periods [direct]
  67. Restrict the retention period [direct]
  68. Access a private registry [direct]
  69. Copilot in Codespaces [direct]
  70. VS Code Command Palette [direct]
  71. Security in Codespaces [direct]
  72. Disaster recovery [direct]
  73. Codespaces logs [direct]
  74. Codespaces clients [direct]
  75. Included usage [direct]
  76. Exporting changes [direct]
  77. Creation and deletion [direct]
  78. Authenticating to repositories [direct]
  79. Connection [direct]
  80. Codespaces prebuilds [direct]