From bf97a55b922fc4cf852a4e5c55addba746602468 Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 2 May 2024 20:06:56 +0200 Subject: [PATCH] feat: zsh tweaks --- home/apps/zsh.nix | 32 ++++++++++++++++++++++++++++--- home/apps/zsh/functions/incognito | 12 ------------ home/apps/zsh/functions/open | 7 ------- 3 files changed, 29 insertions(+), 22 deletions(-) delete mode 100644 home/apps/zsh/functions/incognito delete mode 100644 home/apps/zsh/functions/open diff --git a/home/apps/zsh.nix b/home/apps/zsh.nix index 8d4624b..e66bd57 100644 --- a/home/apps/zsh.nix +++ b/home/apps/zsh.nix @@ -4,6 +4,7 @@ pkgs, ... }: let + inherit (pkgs.stdenv) isLinux; srcs = pkgs.callPackage ../../_sources/generated.nix {}; zshPlugins = plugins: (map (plugin: rec { name = src.name; @@ -16,6 +17,7 @@ in { LESSHISTFILE = "-"; MANPAGER = "sh -c 'col -bx | bat -l man -p'"; }; + home.packages = [pkgs.onefetch]; programs = { atuin = { @@ -127,9 +129,33 @@ in { ZVM_VI_HIGHLIGHT_FOREGROUND=white } ''; - initExtra = '' - for script in "${./zsh/functions}"/**/*; do source "$script"; done - ''; + initExtra = + '' + function incognito() { + if [[ -n $ZSH_INCOGNITO ]]; then + add-zsh-hook precmd _atuin_precmd + add-zsh-hook preexec _atuin_preexec + unset ZSH_INCOGNITO + else + add-zsh-hook -d precmd _atuin_precmd + add-zsh-hook -d preexec _atuin_preexec + export ZSH_INCOGNITO=1 + fi + } + + onefetch_in_git_dir() { + if [[ -d '.git' ]]; then + ${pkgs.onefetch}/bin/onefetch --no-merges --no-bots --no-color-palette --text-colors 1 1 3 4 4 + fi + } + + add-zsh-hook chpwd onefetch_in_git_dir + '' + + lib.optionalString isLinux '' + function open() { + nohup xdg-open "$*" > /dev/null 2>&1 + } + ''; dotDir = ".config/zsh"; oh-my-zsh = { diff --git a/home/apps/zsh/functions/incognito b/home/apps/zsh/functions/incognito deleted file mode 100644 index 5b243cc..0000000 --- a/home/apps/zsh/functions/incognito +++ /dev/null @@ -1,12 +0,0 @@ -# vim:ft=zsh -function incognito() { - if [[ -n $ZSH_INCOGNITO ]]; then - add-zsh-hook precmd _atuin_precmd - add-zsh-hook preexec _atuin_preexec - unset ZSH_INCOGNITO - else - add-zsh-hook -d precmd _atuin_precmd - add-zsh-hook -d preexec _atuin_preexec - export ZSH_INCOGNITO=1 - fi -} diff --git a/home/apps/zsh/functions/open b/home/apps/zsh/functions/open deleted file mode 100644 index 79b8ae8..0000000 --- a/home/apps/zsh/functions/open +++ /dev/null @@ -1,7 +0,0 @@ -# vim:ft=zsh -# exit early if we're on macOS -[[ $(uname) == "Darwin" ]] && return - -function open() { - nohup xdg-open "$*" > /dev/null 2>&1 -}