This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: init sh

+172
+2
flake.nix
··· 24 24 imports = [ 25 25 ./tools/nvim.nix 26 26 ./tools/astronvim/flake-module.nix 27 + 28 + ./tools/zsh.nix 27 29 ]; 28 30 }; 29 31 }
+170
tools/zsh.nix
··· 1 + { ... }: 2 + { 3 + perSystem = { system, pkgs, ... }: let 4 + zshrc = '' 5 + autoload -U compinit && compinit 6 + 7 + # Setup custom interactive shell init stuff. 8 + # Bind gpg-agent to this TTY if gpg commands are used. 9 + export GPG_TTY=$(tty) 10 + 11 + 12 + unsetopt nomatch # no matches found urls 13 + setopt autocd extendedglob 14 + bindkey -e 15 + 16 + #C-x C-e open line in editor 17 + autoload -z edit-command-line 18 + zle -N edit-command-line 19 + bindkey "^X^E" edit-command-line 20 + 21 + #fzf inclusion 22 + source ${pkgs.fzf}/share/fzf/completion.zsh 23 + source ${pkgs.fzf}/share/fzf/key-bindings.zsh 24 + 25 + # atuin distributed shell history 26 + export ATUIN_CONFIG_DIR=${pkgs.writeTextDir "/config.toml" '' 27 + auto_sync = true 28 + update_check = false 29 + sync_address = "http://green.r:8888" 30 + sync_frequency = 0 31 + style = "compact" 32 + ''}; 33 + export ATUIN_NOBIND="true" # disable all keybdinings of atuin 34 + eval "$(atuin init zsh)" 35 + bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin 36 + # use zsh only session history 37 + fc -p 38 + 39 + #completion magic 40 + autoload -Uz compinit 41 + compinit 42 + zstyle ':completion:*' menu select 43 + 44 + #enable automatic rehashing of $PATH 45 + zstyle ':completion:*' rehash true 46 + 47 + # fancy mv which interactively gets the second argument if not given 48 + function mv() { 49 + if [[ "$#" -ne 1 ]] || [[ ! -e "$1" ]]; then 50 + command mv -v "$@" 51 + return 52 + fi 53 + 54 + newfilename="$1" 55 + vared newfilename 56 + command mv -v -- "$1" "$newfilename" 57 + } 58 + 59 + #emacs bindings 60 + bindkey "[7~" beginning-of-line 61 + bindkey "[8~" end-of-line 62 + bindkey "Oc" emacs-forward-word 63 + bindkey "Od" emacs-backward-word 64 + 65 + # direnv integration 66 + eval "$(${pkgs.direnv}/bin/direnv hook zsh)" 67 + 68 + # This function is called whenever a command is not found. 69 + command_not_found_handler() { 70 + local p='${pkgs.nix-index}/etc/profile.d/command-not-found.sh' 71 + if [ -x "$p" ] && [ -f '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' ]; then 72 + # Run the helper program. 73 + "$p" "$@" 74 + 75 + # Retry the command if we just installed it. 76 + if [ $? = 126 ]; then 77 + "$@" 78 + else 79 + return 127 80 + fi 81 + else 82 + # Indicate than there was an error so ZSH falls back to its default handler 83 + echo "$1: command not found" >&2 84 + return 127 85 + fi 86 + } 87 + 88 + 89 + # Setup aliases. 90 + alias -- grep='grep --color=auto' 91 + alias -- ip='ip -color=auto' 92 + alias -- l='ls -alh' 93 + alias -- la='ls -la' 94 + alias -- ll='ls -l' 95 + alias -- ls='ls --color' 96 + alias -- ns='nix-shell --command zsh' 97 + 98 + # Setup prompt. 99 + autoload -U promptinit 100 + promptinit 101 + 102 + p_error='%(?..%F{red}%?%f )' 103 + t_error='%(?..%? )' 104 + 105 + case $UID in 106 + 0) 107 + p_username='%F{red}root%f' 108 + t_username='root' 109 + ;; 110 + 1337) 111 + p_username="" 112 + t_username="" 113 + ;; 114 + *) 115 + p_username='%F{blue}%n%f' 116 + t_username='%n' 117 + ;; 118 + esac 119 + 120 + if test -n "$SSH_CLIENT"; then 121 + p_hostname='@%F{magenta}%M%f ' 122 + t_hostname='@%M ' 123 + else 124 + p_hostname="" 125 + t_hostname="" 126 + fi 127 + 128 + #check if in nix shell 129 + if test -n "$IN_NIX_SHELL"; then 130 + p_nixshell='%F{green}[s]%f ' 131 + t_nixshell='[s] ' 132 + else 133 + p_nixshell="" 134 + t_nixshell="" 135 + fi 136 + 137 + PROMPT="$p_error$p_username$p_hostname$p_nixshell%~ " 138 + TITLE="$t_error$t_username$t_hostname$t_nixshell%~" 139 + case $TERM in 140 + (*xterm* | *rxvt*) 141 + function precmd { 142 + PROMPT_EVALED=$(print -P "$TITLE") 143 + echo -ne "\033]0;$$ $PROMPT_EVALED\007" 144 + } 145 + # This seems broken for some reason 146 + # # This is seen while the shell waits for a command to complete. 147 + # function preexec { 148 + # PROMPT_EVALED=$(print -P "$TITLE") 149 + # echo -ne "\033]0;$$ $PROMPT_EVALED $1\007" 150 + # } 151 + ;; 152 + esac 153 + 154 + 155 + # Disable some features to support TRAMP. 156 + if [ "$TERM" = dumb ]; then 157 + unsetopt zle prompt_cr prompt_subst 158 + unset RPS1 RPROMPT 159 + PS1='$ ' 160 + PROMPT='$ ' 161 + fi 162 + ''; 163 + in { 164 + packages.sh = pkgs.writeScriptBin "sh" '' 165 + zdotdir=$(mktemp -d) 166 + export ZDOTDIR=${pkgs.writeTextDir "/.zshrc" zshrc} 167 + exec ${pkgs.zsh}/bin/zsh "$@" 168 + ''; 169 + }; 170 + }