Skip to content

Shell

Overview

Shell is a Saltbox module that installs and configures a user's shell (Bash or Zsh).


Deployment

Core Saltbox role.

sb install shell

Extras

Oh My Zsh

If you have selected zsh as your shell type, Oh My Zsh, a framework for managing your Zsh configuration, is included.

Oh My Posh

If enabled via its Inventory toggle, Oh My Posh, a prompt theme engine, is included on top of Oh My Zsh.

Role Defaults

Variables can be customized using the Inventory. (1)

  1. Example override

    shell_type: "custom_value"
    

    Avoid overriding variables ending in _default

    When overriding variables that end in _default (like shell_docker_envs_default), you replace the entire default configuration. Future updates that add new default values will not be applied to your setup, potentially breaking functionality.

    Instead, use the corresponding _custom variable (like shell_docker_envs_custom) to add your changes. Custom values are merged with defaults, ensuring you receive updates.

shell_type
# Type: string
shell_type: "{{ shell | default('zsh') }}"
shell_editor
# Type: string
shell_editor: "nano"
shell_misc_argcomplete_pip_package
# Type: string
shell_misc_argcomplete_pip_package: argcomplete
shell_misc_argcomplete_command
# Type: string
shell_misc_argcomplete_command: "activate-global-python-argcomplete"
shell_z_git_repo_url
# Type: string
shell_z_git_repo_url: "https://github.com/rupa/z.git"
shell_z_git_repo_dest
# Type: string
shell_z_git_repo_dest: "{{ server_appdata_path }}/z"
shell_bash_bashrc_path
# Type: string
shell_bash_bashrc_path: "/home/{{ user.name }}/.bashrc"
shell_bash_bashrc_block_content
# Type: string
shell_bash_bashrc_block_content: |
  # Editor
  export EDITOR={{ shell_editor }}
  # Include Z
  . {{ shell_z_git_repo_dest }}/z.sh
  # Aliases
  alias lso="ls -alG | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\" %0o \",k);print}'"
  # OSC 1337 - Set current directory
  export PS1="$PS1\[\e]1337;CurrentDir="'$(pwd)\a\]'
shell_bash_bashrc_block_custom
# Type: string
shell_bash_bashrc_block_custom: ""
shell_bash_binary_path
# Type: string
shell_bash_binary_path: "/bin/bash"
shell_zsh_apt_packages_list
# Type: list
shell_zsh_apt_packages_list:
  - zsh
shell_zsh_omzsh_git_repo_url
# Type: string
shell_zsh_omzsh_git_repo_url: https://github.com/robbyrussell/oh-my-zsh.git
shell_zsh_omzsh_git_repo_dest
# Type: string
shell_zsh_omzsh_git_repo_dest: "/home/{{ user.name }}/.oh-my-zsh"
shell_zsh_zshrc_template_path
# Type: string
shell_zsh_zshrc_template_path: "/home/{{ user.name }}/.oh-my-zsh/templates/zshrc.zsh-template"
shell_zsh_zshrc_path
# Type: string
shell_zsh_zshrc_path: "/home/{{ user.name }}/.zshrc"
shell_zsh_zshrc_block_content1
# Type: string
shell_zsh_zshrc_block_content1: |
  # Oh-my-zsh - auto update zsh without prompt
  DISABLE_UPDATE_PROMPT=true
shell_zsh_zshrc_block_content2
# Type: string
shell_zsh_zshrc_block_content2: |
  # zsh - allows commands to run with the un-expanded glob
  unsetopt nomatch
  # zsh - set TIMEFMT
  export TIMEFMT=$'
  real  %E
  user  %U
  sys   %S'
  # Editor
  export EDITOR={{ shell_editor }}
  # Include Z
  . {{ shell_z_git_repo_dest }}/z.sh
  # Aliases
  alias lso="ls -alG | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\" %0o \",k);print}'"
  # Load compinit and bashcompinit
  autoload -U +X compinit && compinit
  autoload -U +X bashcompinit && bashcompinit
  # OSC 1337 - Set current directory
  precmd () { echo -n "\x1b]1337;CurrentDir=$(pwd)\x07" }
shell_zsh_zshrc_block_custom
# Type: string
shell_zsh_zshrc_block_custom: ""
shell_zsh_plugins
# Type: string
shell_zsh_plugins: "(git docker docker-compose ansible)"
shell_zsh_binary_previous_path
# Type: string
shell_zsh_binary_previous_path: "/bin/zsh5"
shell_zsh_binary_path
# Type: string
shell_zsh_binary_path: "/bin/zsh"
shell_ohmyposh_enabled
# Type: bool (true/false)
shell_ohmyposh_enabled: false
shell_ohmyposh_config
# Takes a file path or url to a config file
# Type: string
shell_ohmyposh_config: ""
shell_zsh_zshrc_oh_my_posh
# Type: string
shell_zsh_zshrc_oh_my_posh: |
  # Oh My Posh
  eval "$(oh-my-posh init zsh{{ ' --config ' + shell_ohmyposh_config if shell_ohmyposh_config | length > 0 else '' }})"