From 274cc8026a523a1de7d425cbb2e8f4c9ea4c7a44 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 10 Jan 2023 16:47:16 +0100 Subject: [PATCH] sh: Add distrobox alias and enable displaying host Add a simple alias to quickly use distrobox with `db` alias, and modify pure prompt initialization slightly so that it displays a hostname when in a distrobox container (akin to operating from ssh or normal container usage). HACKY implementation makes use of both an internal pure prompt api (see here https://github.com/sindresorhus/pure/issues/585) and a distrobox env var that I am not sure how exposed it is either. Powerlevel10k uses a similar method though, so maybe it is fine (see here https://github.com/romkatv/powerlevel10k/blob/33916e91a743a73472a15f3fc27dd0aa9f7abbdf/internal/p10k.zsh#L8336). --- sh/.config/sh/alias | 5 +++++ terminal/.config/zsh/.zshrc | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index b67408e..c71d8f4 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -119,3 +119,8 @@ elif exist ipython; then elif exist python; then alias py=python fi + +# distrobox +if exist distrobox; then + alias db=distrobox +fi diff --git a/terminal/.config/zsh/.zshrc b/terminal/.config/zsh/.zshrc index d403f19..4efb1d8 100644 --- a/terminal/.config/zsh/.zshrc +++ b/terminal/.config/zsh/.zshrc @@ -66,6 +66,10 @@ promptinit prompt_newline='%666v' # show git stash status as a ≡ zstyle :prompt:pure:git:stash show yes +# show hostname if we are in a distrobox environment +if [ -n "$DISTROBOX_ENTER_PATH" ] && [ -f /run/.containerenv ]; then + local container=lxc +fi prompt pure # shellcheck source=alias