Compare commits
3 Commits
5f8997f418
...
6f7aec9147
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f7aec9147 | ||
|
|
c4a93c7647 | ||
|
|
8d98936961 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "3rd-party/complete-alias"]
|
||||
path = 3rd-party/complete-alias
|
||||
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
3rd-party/junegunn/fzf-git.sh
vendored
Submodule
1
3rd-party/junegunn/fzf-git.sh
vendored
Submodule
Submodule 3rd-party/junegunn/fzf-git.sh added at c823ffd521
1
bashrc
1
bashrc
@@ -28,6 +28,7 @@ _source_dir_files "${BASEDIR}"/libs
|
||||
|
||||
# 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/junegunn/fzf-git.sh/fzf-git.sh"
|
||||
|
||||
# Early customization
|
||||
_source_dir_files "${BASEDIR}"/rc.before.d
|
||||
|
||||
@@ -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_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 {
|
||||
echo_bold bold
|
||||
echo_faint faint
|
||||
@@ -77,4 +89,5 @@ function echo_demo {
|
||||
echo_error error
|
||||
echo_success success
|
||||
echo_failed failed
|
||||
DEBUG=true echo_debug debug
|
||||
}
|
||||
|
||||
49
rc.d/terminal-title
Normal file
49
rc.d/terminal-title
Normal 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
|
||||
Reference in New Issue
Block a user