Compare commits

...

3 Commits

Author SHA1 Message Date
Xavier Logerais
6f7aec9147 feat(libs): Improve colors lib 2025-11-21 19:44:12 +00:00
Xavier Logerais
c4a93c7647 feat(rc): Smart titles for tmux windows 2025-11-21 19:43:35 +00:00
Xavier Logerais
8d98936961 feat: Add fzf-git as 3rd party module 2025-11-21 19:42:04 +00:00
5 changed files with 72 additions and 5 deletions

3
.gitmodules vendored
View File

@@ -4,3 +4,6 @@
[submodule "3rd-party/complete-alias"] [submodule "3rd-party/complete-alias"]
path = 3rd-party/complete-alias path = 3rd-party/complete-alias
url = https://github.com/cykerway/complete-alias.git url = https://github.com/cykerway/complete-alias.git
[submodule "3rd-party/junegunn/fzf-git.sh"]
path = 3rd-party/junegunn/fzf-git.sh
url = https://github.com/junegunn/fzf-git.sh

1
bashrc
View File

@@ -28,6 +28,7 @@ _source_dir_files "${BASEDIR}"/libs
# Source 3rd party libs if they exists # Source 3rd party libs if they exists
_source_file_if_exists "${BASEDIR}/3rd-party/complete-alias/complete_alias" _source_file_if_exists "${BASEDIR}/3rd-party/complete-alias/complete_alias"
_source_file_if_exists "${BASEDIR}/3rd-party/junegunn/fzf-git.sh/fzf-git.sh"
# Early customization # Early customization
_source_dir_files "${BASEDIR}"/rc.before.d _source_dir_files "${BASEDIR}"/rc.before.d

View File

@@ -64,6 +64,18 @@ function echo_error { >&2 echo -e "\e[00;01;31;49m ${*}\e[39;49;00m"; }
function echo_success { >&2 echo -e "\e[00;01;32;49m ${*}\e[39;49;00m"; } function echo_success { >&2 echo -e "\e[00;01;32;49m ${*}\e[39;49;00m"; }
function echo_failed { >&2 echo -e "\e[00;01;31;49m✖ ${*}\e[39;49;00m"; } function echo_failed { >&2 echo -e "\e[00;01;31;49m✖ ${*}\e[39;49;00m"; }
function echo_verbose {
if [ -n "${VERBOSE}" ]; then
echo_faint "${*}" >&2
fi
}
function echo_debug {
if [ -n "${DEBUG}" ]; then
echo_faint "🐛 ${*}" >&2
fi
}
function echo_demo { function echo_demo {
echo_bold bold echo_bold bold
echo_faint faint echo_faint faint
@@ -77,4 +89,5 @@ function echo_demo {
echo_error error echo_error error
echo_success success echo_success success
echo_failed failed echo_failed failed
DEBUG=true echo_debug debug
} }

49
rc.d/terminal-title Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Function to update terminal/tmux title
_update_terminal_title() {
local kubecontext dir gitrepo gitremote icon title
# Detect Kubernetes context (if kubectl is available)
if [ -n "${KUBECONFIG}" ]; then
if command -v kubectl >/dev/null 2>&1; then
kubecontext=$(kubectl config current-context 2>/dev/null)
if [ -n "$kubecontext" ]; then
title="󱃾 ${kubecontext}"
fi
fi
fi
# If no title is already set, check if we're in $HOME
if [ -z "${title}" ] && [ "$PWD" = "$HOME" ]; then
title="󱂵 ~"
fi
# If we're in a git repo display repo name with a nice icon
if [ -z "${title}" ] && gitrepo=$(git rev-parse --show-toplevel 2>/dev/null); then
dir=$(basename "${gitrepo}")
# Detect host from remote URL
gitremote=$(git remote get-url origin 2>/dev/null)
case "${gitremote}" in
*github.com*) icon="" ;; # nf-fa-github
*gitlab.com*) icon="" ;; # nf-fa-gitlab
*gitea*) icon="" ;; # nf-linux-gitea
*) icon="" ;; # nf-dev-git
esac
title="${icon} ${dir}"
fi
# Set the title in tmux or terminal window
if [ -n "${title}" ]; then
if [ -n "$TMUX" ]; then
tmux rename-window "${title}"
else
printf '\033]0;%s\007' "${title}"
fi
fi
}
# Add the function to the PROMPT_COMMAND variable to have regular updates
if [ "$TERM" != "linux" ]; then _prompt_command_add "_update_terminal_title"; fi