From dc4979ca20a81fee36d2c2c79103560633565d50 Mon Sep 17 00:00:00 2001 From: gytisrepecka Date: Tue, 19 Mar 2024 22:59:45 +0200 Subject: [PATCH 1/5] Added new Inretio theme. --- clean_files.txt | 1 + themes/inretio/inretio.theme.bash | 99 +++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 themes/inretio/inretio.theme.bash diff --git a/clean_files.txt b/clean_files.txt index 758e3b80a7..0ba14ff020 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -170,6 +170,7 @@ themes/pete themes/powerline themes/pure themes/purity +themes/inretio # vendor init files # diff --git a/themes/inretio/inretio.theme.bash b/themes/inretio/inretio.theme.bash new file mode 100644 index 0000000000..ceac5a296b --- /dev/null +++ b/themes/inretio/inretio.theme.bash @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +# Inretio theme for Bash-it +# Contact: bashit@inretio.eu + +# Inspired by existing themes: +# - metal +# - bobby + +# virtualenv prompts +VIRTUALENV_CHAR=" ⓔ" +VIRTUALENV_THEME_PROMPT_PREFIX="" +VIRTUALENV_THEME_PROMPT_SUFFIX="" + +# SCM prompts +SCM_NONE_CHAR="" +SCM_GIT_CHAR="[±] " +SCM_GIT_BEHIND_CHAR="${red}↓${normal}" +SCM_GIT_AHEAD_CHAR="${bold_green}↑${normal}" +SCM_GIT_UNTRACKED_CHAR="⌀" +SCM_GIT_UNSTAGED_CHAR="${bold_yellow}•${normal}" +SCM_GIT_STAGED_CHAR="${bold_green}+${normal}" + +SCM_THEME_PROMPT_DIRTY="" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_PREFIX="" +SCM_THEME_PROMPT_SUFFIX="" + +# Git status prompts +GIT_THEME_PROMPT_DIRTY=" ${red}✗${normal}" +GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}" +GIT_THEME_PROMPT_PREFIX="" +GIT_THEME_PROMPT_SUFFIX="" + +# ICONS ======================================================================= + +icon_start="┌──" +icon_user=" 🐧 " +icon_host=" 💻 " +icon_directory=" 📂 " +icon_branch="🌵" +icon_end="└> " + +# extra spaces ensure legiblity in prompt + +# FUNCTIONS =================================================================== + +# Display virtual environment info +function _virtualenv_prompt { + VIRTUALENV_DETAILS="" + VIRTUALENV_CHAR="" + + # $VIRTUAL_ENV is set and is non-zero length + if [[ -n "$VIRTUAL_ENV" ]]; then + # Check if Python 3 exists + if command -v python3 >/dev/null 2>&1; then + VIRTUALENV_DETAILS="$($VIRTUAL_ENV/bin/python --version | sed 's,Python ,,') on [$(basename $VIRTUAL_ENV)]" + VIRTUALENV_CHAR=" 🐍" + else + VIRTUALENV_DETAILS="[$(basename $VIRTUAL_ENV)]" + VIRTUALENV_CHAR=" ⓔ" + fi + fi + + echo "$VIRTUALENV_CHAR $VIRTUALENV_DETAILS" +} + +# Rename tab +function tabname { + printf "\e]1;$1\a" +} + +# Rename window +function winname { + printf "\e]2;$1\a" +} + +_theme_clock() { + printf '[%s]' "$(clock_prompt)" + + if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then + printf '%s' "$(clock_char) " + fi +} +THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"false"} +THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$red"} +THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"} +THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"} + +# PROMPT OUTPUT =============================================================== + +# Displays the current prompt +function prompt_command() { + PS1="\n${icon_start}$(_theme_clock)${icon_user}${bold_green}\u${normal}${icon_host}${bold_cyan}\h${normal}${green}$(_virtualenv_prompt)${normal}${icon_directory}${bold_purple}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} $(scm_prompt_info) \")${white}${normal}\n${icon_end}" + PS2="${icon_end}" +} + +# Runs prompt (this bypasses bash_it $PROMPT setting) +safe_append_prompt_command prompt_command From adb01ad8c28b9bd0e63ee10e2bcd8f0576f3c21a Mon Sep 17 00:00:00 2001 From: gytisrepecka Date: Wed, 20 Mar 2024 12:15:06 +0200 Subject: [PATCH 2/5] Added documentation for new Inretio theme. --- docs/themes-list/index.rst | 15 +++++++++++++++ docs/themes-list/inretio.rst | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 docs/themes-list/inretio.rst diff --git a/docs/themes-list/index.rst b/docs/themes-list/index.rst index 0275001b38..0196ba62ed 100644 --- a/docs/themes-list/index.rst +++ b/docs/themes-list/index.rst @@ -221,6 +221,21 @@ Envy ---- +Inretio +^^^^^^^ + + +.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png + :target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png + :alt: Inretio theme in dark color scheme + + +.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png + :target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png + :alt: Inretio theme in light color scheme + +---- + Iterate ^^^^^^^ diff --git a/docs/themes-list/inretio.rst b/docs/themes-list/inretio.rst new file mode 100644 index 0000000000..7850616ae5 --- /dev/null +++ b/docs/themes-list/inretio.rst @@ -0,0 +1,32 @@ +.. _inretio: + +Inretio Theme +========== + +Simple theme showing date and time, username and hostname, current folder, Git details and as a bonus - virtual environment along with Python version available in it. + +Inspired by existing themes: +- metal +- bobby + +Examples +-------- + +In Git-tracked folder: + +.. code-block:: bash + + ┌──[2024-03-20 12:05:07] 🐧 gytis 💻 gytis-legion 📂 bash-it on 🌵 theme-inretio ⌀1 ✗ + └> ls + aliases clean_files.txt custom hooks lib lint_clean_files.sh profiles template test_lib uninstall.sh + bash_it.sh completion docs install.sh LICENSE plugins scripts test themes vendor + + +In Python virtual environment: + +.. code-block:: bash + + ┌──[2024-03-20 12:07:32] 🐧 gytis 💻 gytis-legion 🐍 3.12.2 on [general] 📂 general + └> ls + bin include lib lib64 pyvenv.cfg share + From f486dc9f426c3c4e6d60faf19a62149bfbe8d1db Mon Sep 17 00:00:00 2001 From: gytisrepecka Date: Wed, 20 Mar 2024 13:07:22 +0200 Subject: [PATCH 3/5] Fix documentation: title underline too short. --- docs/themes-list/inretio.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/themes-list/inretio.rst b/docs/themes-list/inretio.rst index 7850616ae5..0e424a99f8 100644 --- a/docs/themes-list/inretio.rst +++ b/docs/themes-list/inretio.rst @@ -1,7 +1,7 @@ .. _inretio: Inretio Theme -========== +============= Simple theme showing date and time, username and hostname, current folder, Git details and as a bonus - virtual environment along with Python version available in it. From dcafe3ce70c24144f4daf408cfe078a751208ad6 Mon Sep 17 00:00:00 2001 From: gytisrepecka Date: Wed, 20 Mar 2024 13:09:48 +0200 Subject: [PATCH 4/5] Fix sorting in clean_files.txt list. --- clean_files.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clean_files.txt b/clean_files.txt index 0ba14ff020..c6c48d4589 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -162,6 +162,7 @@ themes/candy themes/easy themes/essential themes/githelpers.theme.bash +themes/inretio themes/modern themes/norbu themes/oh-my-posh @@ -170,7 +171,6 @@ themes/pete themes/powerline themes/pure themes/purity -themes/inretio # vendor init files # From 608b4399f341dab576e69084d429da6ab6f30b1f Mon Sep 17 00:00:00 2001 From: gytisrepecka Date: Thu, 28 Mar 2024 12:05:32 +0200 Subject: [PATCH 5/5] Fix theme file header as required by hooks/dot-bash.sh line 15. --- themes/inretio/inretio.theme.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/inretio/inretio.theme.bash b/themes/inretio/inretio.theme.bash index ceac5a296b..58ac36ddfb 100644 --- a/themes/inretio/inretio.theme.bash +++ b/themes/inretio/inretio.theme.bash @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +# shellcheck shell=bash +# shellcheck disable=SC2034 # Expected behavior for themes. # Inretio theme for Bash-it # Contact: bashit@inretio.eu