From f5a3e0a2ea197abc292518d7dc129d25898c75a2 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Thu, 4 Mar 2021 17:04:05 +0100 Subject: [PATCH] Include toolbox name in status Signed-off-by: Matej Focko --- playbooks/roles/shell/tasks/zsh.yml | 13 +++++++++++++ .../roles/shell/templates/scripts/toolbox_name.sh | 3 +++ playbooks/roles/shell/templates/starship.toml.j2 | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 playbooks/roles/shell/templates/scripts/toolbox_name.sh diff --git a/playbooks/roles/shell/tasks/zsh.yml b/playbooks/roles/shell/tasks/zsh.yml index 75974cb..a11c6b9 100644 --- a/playbooks/roles/shell/tasks/zsh.yml +++ b/playbooks/roles/shell/tasks/zsh.yml @@ -30,3 +30,16 @@ template: src: templates/starship.toml.j2 dest: ~/.config/starship.toml + +- name: Create directories in `~/.local` + file: + path: "{{ item }}" + state: directory + loop: + - ~/.local/bin + - ~/.local/share + +- name: Install script for toolbox name retrieval + template: + src: templates/scripts/toolbox_name.sh + dest: ~/.local/bin/toolbox_name.sh diff --git a/playbooks/roles/shell/templates/scripts/toolbox_name.sh b/playbooks/roles/shell/templates/scripts/toolbox_name.sh new file mode 100644 index 0000000..67607bc --- /dev/null +++ b/playbooks/roles/shell/templates/scripts/toolbox_name.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cat /run/.containerenv | grep -E '^name=' | sed -e 's/name=\"\(.*\)\"/\1/' diff --git a/playbooks/roles/shell/templates/starship.toml.j2 b/playbooks/roles/shell/templates/starship.toml.j2 index 14b3bae..78bd759 100644 --- a/playbooks/roles/shell/templates/starship.toml.j2 +++ b/playbooks/roles/shell/templates/starship.toml.j2 @@ -35,6 +35,8 @@ format = "[$path]($style)[$read_only]($read_only_style) " [custom.toolbox] when = "ls /run/.containerenv" symbol = " " +command = "~/.local/bin/toolbox_name.sh" +format = "[$symbol($output )]($style)" style = "bold purple" [character]