From 62b73590ae6f6870e3f0b3e4fd1323d48b50eb46 Mon Sep 17 00:00:00 2001 From: Iulian Meghea Date: Tue, 17 Feb 2026 05:30:39 +0000 Subject: [PATCH] feat: add starship bash prompt support to base and nix images Install starship cross-shell prompt with a minimal configuration that shows directory, git branch/status, Node.js version, nix shell indicator, command duration, and a colored prompt character. - Base image: install via official install script, copy starship.toml, init in .bashrc - Nix image: add starship package, writeTextDir config, init in .bashrc - Devops image inherits from base automatically --- images/base/Dockerfile | 7 +++++++ images/base/starship.toml | 33 ++++++++++++++++++++++++++++++ images/nix/flake.nix | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 images/base/starship.toml diff --git a/images/base/Dockerfile b/images/base/Dockerfile index 6ab2de7..46c29bb 100644 --- a/images/base/Dockerfile +++ b/images/base/Dockerfile @@ -48,6 +48,9 @@ curl -fsSLo /usr/local/bin/sops \ https://github.com/getsops/sops/releases/download/v3.11.0/sops-v3.11.0.linux.amd64 chmod +x /usr/local/bin/sops +# Install starship prompt +curl -fsSL https://starship.rs/install.sh | sh -s -- --yes + # Cleanup rm -rf /var/lib/apt/lists/* EOF @@ -70,3 +73,7 @@ RUN userdel -r ubuntu && \ echo "coder ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers.d/nopasswd USER coder + +# Starship prompt configuration +COPY --chown=coder:coder starship.toml /home/coder/.config/starship.toml +RUN echo 'eval "$(starship init bash)"' >> /home/coder/.bashrc diff --git a/images/base/starship.toml b/images/base/starship.toml new file mode 100644 index 0000000..2b2f397 --- /dev/null +++ b/images/base/starship.toml @@ -0,0 +1,33 @@ +format = """ +$directory\ +$git_branch\ +$git_status\ +$nodejs\ +$nix_shell\ +$cmd_duration\ +$line_break\ +$character""" + +[directory] +truncation_length = 3 +truncate_to_repo = true + +[git_branch] +format = "[$branch]($style) " + +[git_status] +format = '([$all_status$ahead_behind]($style) )' + +[nodejs] +format = "[$symbol($version)]($style) " + +[nix_shell] +format = "[$symbol$state]($style) " + +[cmd_duration] +min_time = 2_000 +format = "[$duration]($style) " + +[character] +success_symbol = "[>](bold green)" +error_symbol = "[>](bold red)" diff --git a/images/nix/flake.nix b/images/nix/flake.nix index 8590f33..ce3d977 100644 --- a/images/nix/flake.nix +++ b/images/nix/flake.nix @@ -66,6 +66,43 @@ coder ALL=(ALL) NOPASSWD:ALL source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc ''; + # Starship prompt configuration + starshipConfig = pkgs.writeTextDir "home/coder/.config/starship.toml" '' +format = """ +$directory\ +$git_branch\ +$git_status\ +$nodejs\ +$nix_shell\ +$cmd_duration\ +$line_break\ +$character""" + +[directory] +truncation_length = 3 +truncate_to_repo = true + +[git_branch] +format = "[$branch]($style) " + +[git_status] +format = '([$all_status$ahead_behind]($style) )' + +[nodejs] +format = "[$symbol($version)]($style) " + +[nix_shell] +format = "[$symbol$state]($style) " + +[cmd_duration] +min_time = 2_000 +format = "[$duration]($style) " + +[character] +success_symbol = "[>](bold green)" +error_symbol = "[>](bold red)" + ''; + # nix-ld: library environment for running unpatched dynamic binaries. # This bundles common shared libraries so that pre-compiled binaries # (e.g. from npm, pip wheels, GitHub releases, VS Code Remote, rustup) @@ -122,6 +159,9 @@ fi # Direnv hook eval "$(direnv hook bash)" + +# Starship prompt +eval "$(starship init bash)" ''; in @@ -173,6 +213,7 @@ eval "$(direnv hook bash)" ripgrep fd tmux + starship # Secrets management sops @@ -195,6 +236,7 @@ eval "$(direnv hook bash)" nixConf sudoersConf direnvrc + starshipConfig bashrc nix-ld-libraries ];