From e1d128f28a7ba0e627a50651f433104618d7c103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20SALVI?= Date: Mon, 13 Oct 2025 18:29:23 +0200 Subject: [PATCH] Improving shell --- flake.lock | 12 +- modules/core/packages.nix | 2 + modules/core/tty.nix | 77 +++++++++++-- modules/core/users.nix | 2 + modules/optionnals/desktop/kitty.nix | 6 +- modules/optionnals/desktop/packages.nix | 2 + modules/optionnals/desktop/starship.nix | 144 ++++++++++++------------ modules/optionnals/hosts/home-nix.nix | 1 + modules/optionnals/hosts/work-nix.nix | 1 + modules/optionnals/k8s.nix | 22 ++++ result | 1 - 11 files changed, 181 insertions(+), 89 deletions(-) create mode 100644 modules/optionnals/k8s.nix delete mode 120000 result diff --git a/flake.lock b/flake.lock index d9de6b5..20c5e47 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1759381078, - "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", + "lastModified": 1760038930, + "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", + "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3", "type": "github" }, "original": { @@ -67,11 +67,11 @@ ] }, "locked": { - "lastModified": 1759188042, - "narHash": "sha256-f9QC2KKiNReZDG2yyKAtDZh0rSK2Xp1wkPzKbHeQVRU=", + "lastModified": 1759635238, + "narHash": "sha256-UvzKi02LMFP74csFfwLPAZ0mrE7k6EiYaKecplyX9Qk=", "owner": "Mic92", "repo": "sops-nix", - "rev": "9fcfabe085281dd793589bdc770a2e577a3caa5d", + "rev": "6e5a38e08a2c31ae687504196a230ae00ea95133", "type": "github" }, "original": { diff --git a/modules/core/packages.nix b/modules/core/packages.nix index e0e5d23..81264bd 100644 --- a/modules/core/packages.nix +++ b/modules/core/packages.nix @@ -21,6 +21,8 @@ pkgs.gptfdisk pkgs.duf pkgs.jq + pkgs.bash + pkgs.fzf ]; services = { locate = { diff --git a/modules/core/tty.nix b/modules/core/tty.nix index 2cfb7e7..c2d7fdd 100644 --- a/modules/core/tty.nix +++ b/modules/core/tty.nix @@ -1,11 +1,6 @@ { - config, - pkgs, ... -}@attrs: -let - cfg = config.services.getty; -in +}: { environment = { etc = { @@ -15,13 +10,79 @@ in ls = "ls --color=auto"; ll = "ls --color=auto -lha"; grep = "grep --color=auto"; + egrep = "egrep --color=auto"; + frep = "frep --color=auto"; ip = "ip -color=auto"; vi = "nvim"; + df = "df -h"; + du = "du -h"; }; variables = { + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_DATA_HOME = "$HOME/.local/share"; + ZDOTDIR = "$HOME/.config/zsh"; + TERMINAL = "kitty"; EDITOR = "nvim"; - HISTSIZE = 20000; - HISTTIMEFORMAT = "%F %T "; + BROWSER = "firefox"; + HISTSIZE = 200000; + SAVEHIST = 200000; }; }; + programs.zsh = { + enable = true; + enableCompletion = true; + syntaxHighlighting.enable = true; + autosuggestions.enable = false; + histSize = 200000; + histFile = "$HOME/.config/zsh/.zsh_history"; + setOptions = [ + "SHARE_HISTORY" + ]; + # shellInit = '' + # export XDG_CONFIG_HOME=$HOME/.config + # export XDG_CACHE_HOME=$HOME/.cache + # export XDG_DATA_HOME=$HOME/.local/share + # export ZDOTDIR=$HOME/.config/zsh + # export TERMINAL=kitty + # export EDITOR=nvim + # export BROWSER=firefox + # export SAVEHIST=200000 + # ''; + promptInit = '' + stty stop undef # Disable ctrl+s to freeze terminal + + # Get keycode by typing Ctrl+v in your terminal then the key or key combination you want + bindkey '^[OA' history-beginning-search-backward + bindkey '^[OB' history-beginning-search-forward + + zstyle ':completion:*' menu select + zmodload zsh/complist + + fzf-history() { + local selected + selected=$(fc -l 1 | fzf --tac --no-sort | sed 's/^[ ]*[0-9]*[ ]*//') + if [[ -n "$selected" ]]; then + BUFFER="$selected" + CURSOR=$#BUFFER + fi + zle redisplay + } + zle -N fzf-history + bindkey '^R' fzf-history + + # Fonction SSH avec fzf + fzf-ssh() { + local selected + selected=$(fc -l 1 | grep 'ssh ' | fzf --tac --no-sort | sed 's/^[ ]*[0-9]*[ ]*//') + if [[ -n "$selected" ]]; then + BUFFER="$selected" + CURSOR=$#BUFFER + fi + zle redisplay + } + zle -N fzf-ssh + bindkey '^S' fzf-ssh + ''; + }; } diff --git a/modules/core/users.nix b/modules/core/users.nix index 64c12bb..8179a9c 100644 --- a/modules/core/users.nix +++ b/modules/core/users.nix @@ -1,6 +1,7 @@ { config, username, + pkgs, ... }: { @@ -20,6 +21,7 @@ openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAKMJ3TkEmRQcX7RQijNa2km6a2xXJk6M6FERh7C9nTJ" ]; + shell = pkgs.zsh; }; root = { password = null; diff --git a/modules/optionnals/desktop/kitty.nix b/modules/optionnals/desktop/kitty.nix index a0faffc..ef48664 100644 --- a/modules/optionnals/desktop/kitty.nix +++ b/modules/optionnals/desktop/kitty.nix @@ -18,17 +18,15 @@ }; }; programs = { - starship.enable = true; - bash = { + zsh = { promptInit = '' [[ "$TERM" == "xterm-kitty" ]] && export TERM="xterm-256color" - [[ -f ${pkgs.nitch}/bin/nitch ]] && nitch - if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then hyprland --config /etc/xdg/hypr/hyprland.conf fi ''; }; + starship.enable = true; }; } diff --git a/modules/optionnals/desktop/packages.nix b/modules/optionnals/desktop/packages.nix index b989ee0..c5492f5 100644 --- a/modules/optionnals/desktop/packages.nix +++ b/modules/optionnals/desktop/packages.nix @@ -30,5 +30,7 @@ pkgs.nerd-fonts.comic-shanns-mono pkgs.nerd-fonts.roboto-mono pkgs.nerd-fonts.caskaydia-cove + pkgs.nerd-fonts.jetbrains-mono + pkgs.nerd-fonts.fira-code ]; } diff --git a/modules/optionnals/desktop/starship.nix b/modules/optionnals/desktop/starship.nix index 500fd71..447f4c2 100644 --- a/modules/optionnals/desktop/starship.nix +++ b/modules/optionnals/desktop/starship.nix @@ -3,14 +3,87 @@ ... }: { + environment.sessionVariables = { + KUBECONFIG = "$HOME/.kube/config"; + }; programs.starship = { enable = true; settings = { add_newline = true; command_timeout = 1300; scan_timeout = 50; - format = "$hostname$username$directory[](bg:pink fg:green)$nix_shell$git_branch$git_status[ ](bg:pink)[](fg:pink)$line_break$character"; + format = "[┌─](fg:surface1)$hostname$username$directory$git_branch$git_status[](fg:base bg:sky)$fill$kubernetes$time[─┐ ](fg:surface1)$line_break[└ ](fg:surface1)"; + right_format = "[┘](fg:surface1)"; palette = "catppuccin_frappe"; + + hostname = { + ssh_only = false; + format = "[](bg:base fg:mauve)[ $hostname ](bg:mauve fg:base)[](bg:mauve fg:blue)"; + disabled = false; + }; + + username = { + style_user = "bg:blue fg:base"; + style_root = "bg:red fg:base bold"; + format = "[ $user ]($style)[](bg:blue fg:sapphire)"; + show_always = true; + disabled = false; + }; + + directory = { + format = "[ $path ](bg:sapphire fg:base)[](bg:sapphire fg:sky)"; + truncation_length = 3; + truncation_symbol = "…/"; + }; + + directory.substitutions = { + Documents = "󰈙 Documents"; + Downloads = " Downloads"; + Music = "󰝚 Music"; + Pictures = " Pictures"; + Developer = "󰲋 Developer"; + }; + + git_branch = { + symbol = " "; + format = "[ $symbol$branch(:$remote_branch) ](fg:base bg:sky)"; + disabled = false; + }; + + git_status = { + format = "([$all_status$ahead_behind ](fg:base bg:sky))"; + conflicted = "😵"; + ahead = ""; + behind = ""; + diverged = "😵"; + up_to_date = "✓"; + untracked = "★"; + stashed = "📦"; + modified = "✗"; + #staged = "[($count)](fg:base bg:sapphire)" + staged = ""; + renamed = ""; + deleted = ""; + disabled = false; + }; + + kubernetes = { + disabled = false; + format = "[](fg:blue bg:base)[ ($namespace)/($cluster) ](fg:base bg:blue)[](bg:blue fg:mauve)"; + }; + + time = { + disabled = false; + format = "[ $time ](fg:base bg:mauve)"; + time_format = "%R"; + utc_time_offset = "2"; + }; + + fill = { + symbol = "─"; + style = "surface1"; + }; + palettes.catppuccin_frappe = { rosewater = "#f2d5cf"; flamingo = "#eebebe"; @@ -39,75 +112,6 @@ mantle = "#292c3c"; crust = "#232634"; }; - - hostname = { - ssh_only = false; - ssh_symbol = "󰣀"; - format = "(bg:blue fg:base)[ $ssh_symbol $hostname ](bg:blue fg:base)[](bg:teal fg:blue)"; - trim_at = "companyname.com"; - disabled = false; - }; - - username = { - show_always = true; - style_user = "bg:teal fg:base"; - style_root = "bg:red fg:base"; - format = "[ $user ]($style)[](bg:green fg:teal)"; - }; - - directory = { - style = "bg:green fg:base"; - format = "[ $path ]($style)"; - truncation_length = 3; - truncation_symbol = "…/"; - }; - - nix_shell = { - disabled = false; - impure_msg = "[impure shell](bold red)"; - pure_msg = "[pure shell](bold green)"; - unknown_msg = "[unknown shell](bold yellow)"; - format = "[ ($name)](bold bg:pink fg:base)"; - }; - - - directory.substitutions = { - Documents = "󰈙 "; - Downloads = " Downloads"; - Music = "󰝚 "; - Pictures = " "; - Developer = "󰲋 "; - }; - - git_branch = { - symbol = ""; - style = "bg: pink"; - format = "[[ $symbol $branch ](bg:pink fg:base)]($style)"; - }; - - git_status = { - style = "bg:pink fg:base"; - format = "([$modified$untracked$ahead_behind]($style))"; - ahead = ""; - behind = ""; - modified = "✗"; - untracked = "★"; - up_to_date = ""; - }; - - line_break = { - disabled = false; - }; - - character = { - disabled = false; - success_symbol = "[](bold fg:green)"; - error_symbol = "[✗](bold fg:red)"; - vimcmd_symbol = "[](bold fg:creen)"; - vimcmd_replace_one_symbol = "[](bold fg:purple)"; - vimcmd_replace_symbol = "[](bold fg:purple)"; - vimcmd_visual_symbol = "[](bold fg:lavender)"; - }; }; }; } diff --git a/modules/optionnals/hosts/home-nix.nix b/modules/optionnals/hosts/home-nix.nix index c9d1a75..4993551 100644 --- a/modules/optionnals/hosts/home-nix.nix +++ b/modules/optionnals/hosts/home-nix.nix @@ -7,6 +7,7 @@ imports = [ ../ai.nix ../autologin.nix + ../k8s.nix ../openfortivpn.nix ../packages.nix ../sops-desktop.nix diff --git a/modules/optionnals/hosts/work-nix.nix b/modules/optionnals/hosts/work-nix.nix index 44966b6..3491148 100644 --- a/modules/optionnals/hosts/work-nix.nix +++ b/modules/optionnals/hosts/work-nix.nix @@ -5,6 +5,7 @@ { imports = [ ../autologin.nix + ../k8s.nix ../openfortivpn.nix ../packages.nix ../sops-desktop.nix diff --git a/modules/optionnals/k8s.nix b/modules/optionnals/k8s.nix new file mode 100644 index 0000000..357750b --- /dev/null +++ b/modules/optionnals/k8s.nix @@ -0,0 +1,22 @@ +{ + pkgs, + ... +}: +{ + environment.systemPackages = [ + pkgs.kubectl + pkgs.kubernetes-helm + pkgs.k9s # Interface TUI pour Kubernetes + pkgs.kubectx # Changement rapide de contexte + pkgs.kustomize + ]; + programs.zsh.promptInit = '' + # kubectl + source <(kubectl completion zsh) + alias k=kubectl + alias h=helm + alias kn=kubens + compdef __start_kubectl k + compdef __start_helm h + ''; +} diff --git a/result b/result deleted file mode 120000 index 1ab7b7e..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/k6ir62f4xvynxfms4fczvv57i8mxry8n-nixos-system-home-nix-25.11.20251002.7df7ff7 \ No newline at end of file