xin/configs/zsh.nix

73 lines
1.8 KiB
Nix
Raw Normal View History

2023-09-12 08:44:05 -06:00
{ ... }: {
2022-08-25 12:21:35 -06:00
config = {
programs.zsh.interactiveShellInit = ''
export NO_COLOR=1
# That sweet sweet ^W
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
autoload -Uz compinit && compinit
set -o emacs
'';
programs.zsh.promptInit = ''
autoload -U promptinit && promptinit
autoload -Uz vcs_info
autoload -Uz colors && colors
setopt prompt_subst
#setopt prompt_sp
zstyle ':vcs_info:*' enable git hg cvs
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' formats '(%b)'
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
prompt_char() {
if [ -z "$IN_NIX_SHELL" ]; then
echo -n "%#"
else
echo -n ";"
fi
}
2022-10-16 08:22:31 -06:00
export NETRC=/run/secrets/netrc
2022-08-25 12:21:35 -06:00
PROMPT='%n@%m[%(?.%{$fg[default]%}.%{$fg[red]%})%?%{$reset_color%}]:%~$vcs_info_msg_0_$(prompt_char) '
go_update_deps() {
for i in $(go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all); do
go get -u $i
done
go mod tidy
}
mkhash() {
nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$1")
}
2022-08-25 12:21:35 -06:00
k() {
''${K_DEBUG}
if [ -z $1 ]; then
echo $PWD >> ~/.k
else
K=~/.k
case $1 in
clean) sort -u $K -o ''${K};;
rm) sed -i -E "\#^''${2:-''${PWD}}\$#d" ''${K};;
ls) cat ''${K};;
*) cd "$(grep -e "$1" ''${K} | head -n 1)";;
esac
fi
}
#[[ ! -r $HOME/.opam/opam-init/init.zsh ]] || source $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
2022-08-25 12:21:35 -06:00
eval "$(direnv hook zsh)"
'';
};
}