Skip to content

Shell

Overview

Installs and configures a user's shell (Bash or Zsh) with tools like z for directory jumping, argcomplete for tab completion, Oh My Zsh and optional Oh My Posh theming.


Deployment

Saltbox dependency.

sb install shell

Role Defaults

Info

Variables can be overridden in /srv/git/saltbox/inventories/host_vars/localhost.yml.

Example Override
shell_type: "custom_value"
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 '' }})"
shell_role_autoheal_enabled
# Enable or disable Autoheal monitoring for the container created when deploying
# Type: bool (true/false)
shell_role_autoheal_enabled: true
shell_role_depends_on
# List of container dependencies that must be running before the container start
# Type: string
shell_role_depends_on: ""
shell_role_depends_on_delay
# Delay in seconds before starting the container after dependencies are ready
# Type: string (quoted number)
shell_role_depends_on_delay: "0"
shell_role_depends_on_healthchecks
# Enable healthcheck waiting for container dependencies
# Type: string ("true"/"false")
shell_role_depends_on_healthchecks:
shell_role_diun_enabled
# Enable or disable Diun update notifications for the container created when deploying
# Type: bool (true/false)
shell_role_diun_enabled: true
shell_role_dns_enabled
# Enable or disable automatic DNS record creation for the container
# Type: bool (true/false)
shell_role_dns_enabled: true
shell_role_docker_controller
# Enable or disable Saltbox Docker Controller management for the container
# Type: bool (true/false)
shell_role_docker_controller: true
shell_role_traefik_autodetect_enabled
# Enable Traefik autodetect middleware for the container
# Type: bool (true/false)
shell_role_traefik_autodetect_enabled: false
shell_role_traefik_crowdsec_enabled
# Enable CrowdSec middleware for the container
# Type: bool (true/false)
shell_role_traefik_crowdsec_enabled: false
shell_role_traefik_error_pages_enabled
# Enable custom error pages middleware for the container
# Type: bool (true/false)
shell_role_traefik_error_pages_enabled: false
shell_role_traefik_gzip_enabled
# Enable gzip compression middleware for the container
# Type: bool (true/false)
shell_role_traefik_gzip_enabled: false
shell_role_traefik_middleware_http_api_insecure
# Type: bool (true/false)
shell_role_traefik_middleware_http_api_insecure:
shell_role_traefik_middleware_http_insecure
# Type: bool (true/false)
shell_role_traefik_middleware_http_insecure:
shell_role_traefik_robot_enabled
# Enable robots.txt middleware for the container
# Type: bool (true/false)
shell_role_traefik_robot_enabled: true
shell_role_traefik_tailscale_enabled
# Enable Tailscale-specific Traefik configuration for the container
# Type: bool (true/false)
shell_role_traefik_tailscale_enabled: false
shell_role_traefik_wildcard_enabled
# Enable wildcard certificate for the container
# Type: bool (true/false)
shell_role_traefik_wildcard_enabled: true
shell_role_web_fqdn_override
# Override the Traefik fully qualified domain name (FQDN) for the container
# Type: list
shell_role_web_fqdn_override:

Example Override

shell_role_web_fqdn_override:
  - "{{ traefik_host }}"
  - "shell2.{{ user.domain }}"
  - "shell.otherdomain.tld"

Note: Include {{ traefik_host }} to preserve the default FQDN alongside your custom entries

shell_role_web_host_override
# Override the Traefik web host configuration for the container
# Type: string
shell_role_web_host_override:

Example Override

shell_role_web_host_override: "Host(`{{ traefik_host }}`) || Host(`{{ 'shell2.' + user.domain }}`)"

Note: Use {{ traefik_host }} to include the default host configuration in your custom rule

shell_role_web_scheme
# URL scheme to use for web access to the container
# Type: string ("http"/"https")
shell_role_web_scheme: