diff --git a/home-manager/roles/desktop/gnome.nix b/home-manager/roles/desktop/gnome.nix index 9ec16db2..64aabb0e 100644 --- a/home-manager/roles/desktop/gnome.nix +++ b/home-manager/roles/desktop/gnome.nix @@ -4,7 +4,7 @@ "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal" = { binding = "Return"; - command = "kitty"; + command = "kitty mytmux"; name = "Terminal"; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/hotkeys" = diff --git a/home-manager/roles/zsh/default.nix b/home-manager/roles/zsh/default.nix index a1be600b..ab0a1083 100644 --- a/home-manager/roles/zsh/default.nix +++ b/home-manager/roles/zsh/default.nix @@ -4,8 +4,8 @@ enableAutosuggestions = true; enableCompletion = true; history = { - save = 100000; - size = 100000; + save = 1000000; + size = 1000000; }; initExtra = '' ${builtins.readFile ./zshrc} diff --git a/home-manager/roles/zsh/zshrc b/home-manager/roles/zsh/zshrc index 8fa2579f..350aebc0 100644 --- a/home-manager/roles/zsh/zshrc +++ b/home-manager/roles/zsh/zshrc @@ -1,34 +1,11 @@ -# If not in a tmux, start tmux -if [[ -z "$TMUX" ]] { - session=$(tmux ls | grep -v attached | head -1 | cut -f1 -d:) - if [[ -n $session ]] { - exec tmux attach -t $session; - } else { - exec tmux; - } -} - mkdir -p /var/run/user/$UID/tmp/downloads setopt prompt_subst autoload -U colors && colors # Enable colors in prompt -precmd() { - if hash eventc 2> /dev/null; - then - local s=$? c=( $(fc -L -D -l -1) ) - if [[ $launched && "${c[2]}" != "0:00" ]] { - eventc command $([[ ${s} == 0 ]] && echo success || echo failure) -d command="\"${c[3,-1]}\"" -d time="\"${c[2]}\"" -d host="\"$HOST\"" - } else { - export launched=true; - } - fi -} - alias cat=bat alias accounting='hledger -f ~/git/buchhaltung/buchhaltung.ledger ui -- --watch --theme=terminal -T -E' alias o=xdg-open -alias c=cdr alias sudo='sudo -A' alias s='sudo -A systemctl' alias u='systemctl --user' @@ -37,9 +14,22 @@ alias ls='exa -lh --git' autoload -Uz chpwd_recent_dirs cdr add-zsh-hook add-zsh-hook chpwd chpwd_recent_dirs -zstyle ':chpwd:*' recent-dirs-max 25 +zstyle ':chpwd:*' recent-dirs-max 100 if [[ $PWD == "$HOME" ]] { cd "$(head -n1 ~/.chpwd-recent-dirs | sed s/\\$// | sed s/\'//g)" } -bindkey '^R' history-incremental-pattern-search-backward +fzf-history-search() { + LBUFFER=$( history | sed -E 's/ *[0-9]*\*? *//' | fzf +s --tac | sed -E 's/\\/\\\\/g') + zle redisplay +} +zle -N fzf-history-search +bindkey '^R' fzf-history-search + +fzf-directory-history-search() { + LBUFFER=$( sed "s/\\$//;s/\'//g" ~/.chpwd-recent-dirs | fzf +s | sed -E 's/\\/\\\\/g;s/^/cd /') + zle redisplay +} + +zle -N fzf-directory-history-search +bindkey '^T' fzf-directory-history-search diff --git a/overlays/pkgSets.nix b/overlays/pkgSets.nix index 7c005d76..80ee685f 100644 --- a/overlays/pkgSets.nix +++ b/overlays/pkgSets.nix @@ -23,6 +23,14 @@ self: super: { scp "$@" ag-forward: ssh ag-forward lpr -r "$@" ''; + mytmux = super.writeShellScriptBin "mytmux" '' + session=$(${self.tmux}/bin/tmux ls | grep -v attached | head -1 | cut -f1 -d:) + if [[ -n $session ]]; then + exec ${self.tmux}/bin/tmux attach -t $session; + else + exec ${self.tmux}/bin/tmux; + fi + ''; }; desktop-pkgs = { inherit (self) lm_sensors xwayland xdg_utils libnotify;