Skip to content

Commit

Permalink
Merge pull request #2247 from inretio/theme-inretio
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Nov 6, 2024
2 parents 998e1d6 + 608b439 commit 0375b77
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
1 change: 1 addition & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ themes/candy
themes/easy
themes/essential
themes/githelpers.theme.bash
themes/inretio
themes/modern
themes/norbu
themes/oh-my-posh
Expand Down
15 changes: 15 additions & 0 deletions docs/themes-list/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^

Expand Down
32 changes: 32 additions & 0 deletions docs/themes-list/inretio.rst
Original file line number Diff line number Diff line change
@@ -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
100 changes: 100 additions & 0 deletions themes/inretio/inretio.theme.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.

# 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

0 comments on commit 0375b77

Please sign in to comment.