Terminal (Bash) customization

Hey guys,

is there a possibility to modify the bash. Adding colortheme, maybe some predefinded alias and autocompletion. On my Debain i used oh-my-bash, but in the nix packages there is no such paket.
As a alternative there seems to be starship, but since I am working with the helix editor, starship overrides the helix colortheme :frowning:
Does anyone have already a solution?

You can use the bash shellAliases option to set the aliases. For the colorscheme you could use nix-colors or stylix.

1 Like

If you are using Home Manager, have a look at the programs.bash configuration attribute set.

https://nix-community.github.io/home-manager/options.xhtml#opt-programs.bash.enable

So in case you really want oh-my-bash, I can provide some clues to make it work and reproducible (yes!):

  1. Check if ~/.bashrc and ~/.bash_profile are symlinks to Nix store. If they are, you can mv $(realpath ~/.bashrc) ~/.bashrc and chmod +wrx ~/.bashrc to get a writable copy.
  2. Run the installation script as its README says.
  3. Check ~/.bashrc to see what’s new inside. You should see something like source ~/.oh-my-bash/something/something.sh or . ~/.oh-my-bash/something/something.sh.
  4. Edit your configuration. In case you are configuring it in NixOS, add programs.bash.promptInit (for home-manager it should be programs.bash.initExtra) and copy what’s added in step 3 here. Write:
promptInit = let
  oh-my-bash = pkgs.fetchFromGitHub {
    owner = "ohmybash";
    repo = "oh-my-bash";
    # Latest commit in https://github.com/ohmybash/oh-my-bash/commits/master/
    rev = "b88b2244f15a0e0f65f1588a3de2db6d1c55169b";
    hash = "";
  };
in
''
  #Other lines, like theme and color configuration related to oh-my-bash
  source ${oh-my-bash}/something/something.sh
''
  1. If bashrc was a symlink, delete the file you created.
  2. Run nixos-rebuild switch. It will error out with the correct hash. Fill in the hash into the above quotes.

You are all set. Congrats!

And if you are using flake, you can replace the let ... in part with

flake.nix

{
  inputs = {
    oh-my-bash = {
      url = "github:ohmybash/oh-my-bash";
      flake = false;
    };
  };
}

And make sure to include inputs as specialArgs when creating NixOS or home-manager configuration. Then replace ~/.oh-my-bash with ${inputs.oh-my-bash}.

1 Like

Thanks for all the replies :smiley:
At the weekend i spend fome times reading and the zsh is fully supported, also oh-my-zsh. It seems like a relative convenient way to change from bash to zsh.
I’m also using now home-manager since it seems to be a elegant way for reproduction.