Files
dotfiles-new/dotfiles/zsh/zshrc.perso
T

120 lines
3.4 KiB
Plaintext

###Man page color
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
#eval "$(zellij setup --generate-auto-start zsh)"
zellij_autostart() {
[[ -n "$ZELLIJ" ]] && return
[[ -o interactive ]] || return
local sessions
sessions=$(zellij list-sessions --no-formatting 2>/dev/null)
if [[ -z "$sessions" ]]; then
zellij
return
fi
local count
count=$(printf '%s\n' "$sessions" | wc -l)
if (( count == 1 )); then
zellij attach "$(printf '%s\n' "$sessions" | cut -d' ' -f1)"
return
fi
if command -v fzf >/dev/null 2>&1; then
local choice
choice=$(printf '%s\n' "$sessions" | fzf \
--tac --height=40% --border \
--prompt="Session zellij > " \
--header 'Entrée: attacher | Ctrl-R: supprimer la session surlignée' \
--bind 'ctrl-r:execute-silent(name=$(echo {} | cut -d" " -f1); zellij kill-session "$name" 2>/dev/null; zellij delete-session "$name" --force 2>/dev/null)+reload(zellij list-sessions --no-formatting 2>/dev/null)' \
| cut -d' ' -f1)
if [[ -n "$choice" ]]; then
zellij attach "$choice"
else
zellij
fi
else
# Fallback sans fzf : menu numéroté avec option de suppression "rN"
while true; do
sessions=$(zellij list-sessions --no-formatting 2>/dev/null)
[[ -z "$sessions" ]] && { zellij; return; }
print -P "%BSessions zellij disponibles :%b"
local -a names
local i=1
while IFS= read -r line; do
names+=("${line%% *}")
printf " %d) %s\n" "$i" "$line"
((i++))
done <<< "$sessions"
printf " n) Nouvelle session\n"
printf " rN) Supprimer la session N (ex: r2)\n"
read "choix?Ton choix : "
if [[ "$choix" == "n" || -z "$choix" ]]; then
zellij
return
elif [[ "$choix" =~ ^r[0-9]+$ ]]; then
local idx="${choix#r}"
if (( idx >= 1 && idx <= ${#names[@]} )); then
local target="${names[$idx]}"
zellij kill-session "$target" 2>/dev/null
zellij delete-session "$target" --force 2>/dev/null
echo "Session '$target' supprimée."
fi
# on reboucle pour ré-afficher la liste à jour
elif [[ "$choix" =~ ^[0-9]+$ ]] && (( choix >= 1 && choix <= ${#names[@]} )); then
zellij attach "${names[$choix]}"
return
else
zellij
return
fi
done
fi
}
zellij_autostart
### Fonction a utiliser comme ceci udig an.ginder
udig() {
if [ "$1" != "" ]
then
dig +short TXT $1.u.perf1.net @192.168.232.10
else
echo "Missing user - Please specify udig pr.nom"
fi
}
### Fonction pour le git push mr
git-push-mr() {
local title="$1"
git push \
-o merge_request.create \
-o merge_request.target=main \
-o merge_request.remove_source_branch \
-o merge_request.title="$title" \
-o merge_request.description="$title" \
-o merge_request.assign="sysops"
}
#Export Perso
export SSH_AUTH_SOCK=/home/an.ginder/.keeper/anael.ginder@nameshield.net.ssh_agent
#source ~/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source "$HOME/.zsh/spaceship/spaceship.zsh"
source /opt/keeper-cli-venv/bin/activate
#export PYTHONPATH=/opt/wapt
eval "$(zoxide init zsh)"