diff --git a/README.md b/README.md index e05c9db..767dbda 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -Mon dotfiles zellij +Mon dotfiles zellij / spaceship Pour utiliser cloner le depot et lancé le script dans le dossier install diff --git a/dotfiles/spaceship/spaceship.zsh b/dotfiles/spaceship/spaceship.zsh index 9334b8d..2e3130d 100644 --- a/dotfiles/spaceship/spaceship.zsh +++ b/dotfiles/spaceship/spaceship.zsh @@ -36,3 +36,4 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then char # Prompt character ) fi + diff --git a/dotfiles/zsh/zshrc.perso b/dotfiles/zsh/zshrc.perso index 04e4fed..dde7583 100644 --- a/dotfiles/zsh/zshrc.perso +++ b/dotfiles/zsh/zshrc.perso @@ -1,4 +1,91 @@ -eval "$(zellij setup --generate-auto-start zsh)" +###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() { @@ -10,7 +97,23 @@ udig() { 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)"