Using Oh-My-Bash with Jetify Devbox: A Step-by-Step Guide

If you’re a developer working with Jetify Devbox, you might have noticed that its shell environment doesn’t always play nicely with Oh-My-Bash. By following these steps, you can customize and personalize your themes and PS1 prompt to create a more enjoyable and productive shell experience.

Step 1: Install Oh-My-Bash

First, you need to install Oh-My-Bash. You can do this by running the following command in your terminal:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

Step 2: Configure Your Shell

Next, insert the following script into your ~/.bashrc file to set your preferred theme. You can replace "bakke" with any theme you like:

if [ -z "$OSH_THEME" ]; then
   OSH_THEME="bakke" # choose the theme you like
   source ~/.bashrc
fi

Step 3: Update Your Devbox Configuration

Now, from your Devbox project, open the devbox.json file and add the shell initialization hook to ensure your theme and configurations are applied when you start a Devbox shell:

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
  "packages": ["wails@latest"],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null",
      "OSH_THEME=purity",
      "source ~/.bashrc"
    ],
    "scripts": {
      "test": ["echo \"Error: no test specified\" && exit 1"]
    }
  }
}

In this example, the OSH_THEME is set to "purity", but you can choose any other theme you prefer.

Step 4: Personalize Your PS1 Prompt

To customize your PS1 prompt, edit the theme’s theme.sh file. For instance, if you are using the purity theme, the file path would be ~/.oh-my-bash/themes/purity/purity.theme.sh.

Open the file and edit the PS1 variable with your desired style. Here’s an example:

PS1="\nπŸ“¦${_omb_prompt_bold_purple} Devbox: ${_omb_prompt_navy}\w $(scm_prompt_info)\n${ret_status} "

Save your changes after editing.

Step 5: Apply Your Changes

Finally, load your changes by sourcing your ~/.bashrc file:

source ~/.bashrc

Result

After completing these steps, your shell should look something like this when you enter a Devbox shell:

fedora:  ~/gitlab/coco  |main βœ“|
β†’ devbox shell
Starting a devbox shell...

πŸ“¦ Devbox: ~/gitlab/coco ( main βœ“ )
❯  exit
exit

fedora:  ~/gitlab/coco  |main βœ“|
β†’

With these configurations, you can enjoy a customized and productive shell environment within Jetify Devbox using Oh-My-Bash. Happy coding!