The default Ollama Docker container provides a powerful AI environment, but its command-line interface is plain and basic. By customizing the Bash prompt, you can make your terminal more informative, visually appealing, and efficient.
This guide will walk you through replacing the default prompt with a modern, two-line prompt inspired by Parrot Security OS. This new prompt includes features like exit-code indicators and Git integration. Best of all, this entire process requires no text editors like vim or nano, making it perfect for the minimal Ollama container environment.

What the New Prompt Offers
Your new prompt will provide immediate, at-a-glance information:
Two-Line Layout: Separates your command input from the directory information for a cleaner workspace.
Success/Failure Indicator: A red ✗ will instantly appear if your last command failed.
Root User Highlighting: The root user is displayed in bright red to remind you of your elevated privileges.
Git Integration: Automatically displays the current Git branch and an asterisk (*) for uncommitted changes when you're inside a repository.
Here’s what it will look like:
Default View (as root, after a successful command):
╭─root@ollama─(/)─╮
╰─▶
Failure View (after a command fails):
╭─✗─root@ollama─(/)─╮
╰─▶
The Complete .bashrc Code
This is the full configuration file you will add to your container. It includes all the logic for colors, layout, and Git detection.
[ -z "$PS1" ] && return
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
shopt -s checkwinsize
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
PROMPT_COMMAND="_prompt_command"
_prompt_command() {
local EXIT_CODE=$?
local C_RESET='\[\e[0m\]'
local C_USER='\[\e[0;96m\]'
local C_ROOT='\[\e[1;91m\]'
local C_AT='\[\e[0;90m\]'
local C_HOST='\[\e[0;36m\]'
local C_PATH='\[\e[1;32m\]'
local C_GIT='\[\e[0;33m\]'
local C_GIT_DIRTY='\[\e[1;31m\]'
local C_PROMPT='\[\e[0;93m\]'
local C_FAIL='\[\e[0;91m\]'
local C_BOX='\[\e[0;90m\]'
local P_TOP=""
P_TOP+="${C_BOX}╭─"
if [ $EXIT_CODE -ne 0 ]; then
P_TOP+="${C_FAIL}✗─"
fi
if [ "$EUID" -eq 0 ]; then
P_TOP+="${C_ROOT}\u${C_AT}@${C_HOST}\h"
else
P_TOP+="${C_USER}\u${C_AT}@${C_HOST}\h"
fi
P_TOP+="${C_BOX}─(${C_PATH}\w${C_BOX})"
if command -v git &>/dev/null && [ -n "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
local GIT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
local GIT_STATUS=$(git status --porcelain 2>/dev/null)
if [ -n "$GIT_STATUS" ]; then
P_TOP+="${C_BOX}─(${C_GIT_DIRTY}${GIT_BRANCH}*${C_BOX})"
else
P_TOP+="${C_BOX}─(${C_GIT}${GIT_BRANCH}${C_BOX})"
fi
fi
P_TOP+="${C_BOX}─╮${C_RESET}"
local P_BOTTOM="${C_BOX}╰─${C_PROMPT}\\$ ${C_RESET}"
PS1="\n${P_TOP}\n${P_BOTTOM}"
}
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Implementation Steps
Follow these steps carefully to install your new prompt.
Step 1: Get a Shell in the Ollama Container
First, open a terminal on your host machine and use the docker exec command to access the bash shell inside your running Ollama container.
docker exec -it ollama bash
(Note: If your container is named something other than ollama, replace it in the command.)
Step 2: (Optional) Back Up Your Current .bashrc
It's always a good idea to keep a backup of the original configuration file. You can do this with a simple copy command.
cp ~/.bashrc ~/.bashrc.bak
Step 3: Write the New .bashrc without an Editor
Now, we'll use the cat command to write our new configuration. This command turns your terminal into a temporary file writer.
First, run this command. Your cursor will move to a blank line, waiting for input.
cat > ~/.bashrc
Next, copy the entire code block from the section above and paste it into your terminal.
Finally, press Enter once (to ensure you're on a new line) and then press CTRL+D. This signals that you're done and saves the file. Your normal prompt will reappear.
Step 3.1: Alternative to Previous Option (Alternative)
Also we can use this command:
cat > ~/.bashrc <<'EOF'
Next, paste the code block and then after the last line write EOF in the terminal and hit enter .
Step 4: Activate Your New Prompt
The changes are saved, but they won't apply to your current session until you source the file. Run the following command:
source ~/.bashrc
Your terminal prompt will instantly transform into the new Parrot OS style! Any new shell you open with docker exec will automatically have this prompt from now on. Enjoy your upgraded Ollama experience! ✨
The default Ollama Docker container provides a powerful AI environment, but its command-line interface is plain and basic. By customizing the Bash prompt, you can make your terminal more informative, visually appealing, and efficient.
This guide will walk you through replacing the default prompt with a modern, two-line prompt inspired by Parrot Security OS. This new prompt includes features like exit-code indicators and Git integration. Best of all, this entire process requires no text editors like
vimornano, making it perfect for the minimal Ollama container environment.What the New Prompt Offers
Your new prompt will provide immediate, at-a-glance information:
Two-Line Layout: Separates your command input from the directory information for a cleaner workspace.
Success/Failure Indicator: A red
✗will instantly appear if your last command failed.Root User Highlighting: The
rootuser is displayed in bright red to remind you of your elevated privileges.Git Integration: Automatically displays the current Git branch and an asterisk (
*) for uncommitted changes when you're inside a repository.Here’s what it will look like:
Default View (as root, after a successful command):
╭─root@ollama─(/)─╮ ╰─▶ # _Failure View (after a command fails):
╭─✗─root@ollama─(/)─╮ ╰─▶ # _The Complete
.bashrcCodeThis is the full configuration file you will add to your container. It includes all the logic for colors, layout, and Git detection.
# ~/.bashrc: Executed by bash(1) for non-login shells. # This file is optimized for a minimal container environment like Ollama. # If not running interactively, don't do anything [ -z "$PS1" ] && return # Don't put duplicate lines or lines starting with space in the history. HISTCONTROL=ignoreboth # Append to the history file, don't overwrite it shopt -s histappend # For setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000 # Check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize # Set a fancy prompt (non-color, unless we know we "want" color) force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 color_prompt=yes else color_prompt= fi fi # Custom prompt function PROMPT_COMMAND="_prompt_command" _prompt_command() { local EXIT_CODE=$? # Define colors local C_RESET='\[\e[0m\]' local C_USER='\[\e[0;96m\]' # Cyan local C_ROOT='\[\e[1;91m\]' # Bright Red local C_AT='\[\e[0;90m\]' # Grey local C_HOST='\[\e[0;36m\]' # Dark Cyan local C_PATH='\[\e[1;32m\]' # Bright Green local C_GIT='\[\e[0;33m\]' # Yellow local C_GIT_DIRTY='\[\e[1;31m\]' # Red local C_PROMPT='\[\e[0;93m\]'# Bright Yellow local C_FAIL='\[\e[0;91m\]' # Bright Red local C_BOX='\[\e[0;90m\]' # Grey # Top line of the prompt local P_TOP="" # Start with box character P_TOP+="${C_BOX}╭─" # Add exit code indicator if last command failed if [ $EXIT_CODE -ne 0 ]; then P_TOP+="${C_FAIL}✗─" fi # User and host info if [ "$EUID" -eq 0 ]; then P_TOP+="${C_ROOT}\u${C_AT}@${C_HOST}\h" else P_TOP+="${C_USER}\u${C_AT}@${C_HOST}\h" fi # Path info P_TOP+="${C_BOX}─(${C_PATH}\w${C_BOX})" # Git info (only if in a git repo and git is installed) if command -v git &>/dev/null && [ -n "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then local GIT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null) local GIT_STATUS=$(git status --porcelain 2>/dev/null) if [ -n "$GIT_STATUS" ]; then P_TOP+="${C_BOX}─(${C_GIT_DIRTY}${GIT_BRANCH}*${C_BOX})" else P_TOP+="${C_BOX}─(${C_GIT}${GIT_BRANCH}${C_BOX})" fi fi P_TOP+="${C_BOX}─╮${C_RESET}" # Bottom line of the prompt local P_BOTTOM="${C_BOX}╰─${C_PROMPT}\\$ ${C_RESET}" # Combine into final PS1 PS1="\n${P_TOP}\n${P_BOTTOM}" } # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; *) ;; esac # Enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi # Some more ls aliases alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' # Add some other useful aliases alias ..='cd ..' alias ...='cd ../..' # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fiImplementation Steps
Follow these steps carefully to install your new prompt.
Step 1: Get a Shell in the Ollama Container
First, open a terminal on your host machine and use the
docker execcommand to access the bash shell inside your running Ollama container.docker exec -it ollama bash(Note: If your container is named something other than
ollama, replace it in the command.)Step 2: (Optional) Back Up Your Current
.bashrcIt's always a good idea to keep a backup of the original configuration file. You can do this with a simple copy command.
Step 3: Write the New
.bashrcwithout an EditorNow, we'll use the
catcommand to write our new configuration. This command turns your terminal into a temporary file writer.First, run this command. Your cursor will move to a blank line, waiting for input.
Next, copy the entire code block from the section above and paste it into your terminal.
Finally, press Enter once (to ensure you're on a new line) and then press CTRL+D. This signals that you're done and saves the file. Your normal prompt will reappear.
Step 3.1: Alternative to Previous Option (Alternative)
Also we can use this command:
cat > ~/.bashrc <<'EOF'Next, paste the code block and then after the last line write
EOFin the terminal and hitenter.Step 4: Activate Your New Prompt
The changes are saved, but they won't apply to your current session until you source the file. Run the following command:
source ~/.bashrcYour terminal prompt will instantly transform into the new Parrot OS style! Any new shell you open with
docker execwill automatically have this prompt from now on. Enjoy your upgraded Ollama experience! ✨