dotfiles/modules/home-manager/zsh.nix

125 lines
2.6 KiB
Nix
Raw Normal View History

2024-04-16 12:00:00 +00:00
{ pkgs, ... }:
2023-11-06 23:48:09 +00:00
{
programs.zsh = {
dotDir = ".config/zsh";
enable = true;
enableCompletion = true;
2023-11-06 23:48:09 +00:00
2024-08-28 12:00:09 +00:00
cdpath = [ "~/Code" ];
shellAliases = (import ./zsh/aliases.nix);
2024-04-16 12:00:00 +00:00
localVariables = {
ABBR_SET_EXPANSION_CURSOR = 1;
};
initExtra = ''
# suffix
alias -s gz="tar -tf"
alias -s {html,HTML}="background firefox"
alias -s {jpg,JPG,png,PNG}="background okular"
alias -s {pdf,PDF}="background okular"
alias -s {zip,ZIP}="unzip -l"
background() {
for ((i=2;i<=$#;i++)); do
''${@[1]} ''${@[$i]} &> /dev/null &
done
}
git() {
if [[ "''${1}" == "root" ]]; then
shift
local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)"
if [[ $# == 0 ]]; then
cd "''${ROOT}"
else
(cd "''${ROOT}" && eval "''${@}")
fi
else
${pkgs.git}/bin/git "''${@}"
fi
}
ttyper() {
command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}"
}
yt-dlp() {
command yt-dlp --paths ~/Videos "$@"
}
2023-11-06 23:48:09 +00:00
# Case insensitive autocompletion.
zstyle ":completion:*" matcher-list "" "m:{a-zA-Z}={A-Za-z}" "r:|=*" "l:|=* r:|=*"
autoload -Uz compinit && compinit
2024-10-09 16:46:04 +00:00
bindkey -s ^f "t\n"
2024-07-23 19:46:25 +00:00
bindkey -s ^v "nvim\n"
2023-11-06 23:48:09 +00:00
clear-ls-all() {
clear
ls -al
zle reset-prompt
2023-11-06 23:48:09 +00:00
}
zle -N clear-ls-all
clear-git-status() {
clear
git status
zle reset-prompt
2023-11-06 23:48:09 +00:00
}
zle -N clear-git-status
clear-tree-2() {
clear
tree -L 2
zle reset-prompt
2023-11-06 23:48:09 +00:00
}
zle -N clear-tree-2
clear-tree-3() {
clear
tree -L 3
zle reset-prompt
2023-11-06 23:48:09 +00:00
}
zle -N clear-tree-3
bindkey '^G' clear-git-status
# bindkey '^H' clear-tree-3
# bindkey '^J' clear-tree-2
# bindkey '^K' clear-ls-all
setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
'';
zplug = {
enable = true;
plugins = [
{
name = "plugin/git";
2024-03-18 20:33:28 +00:00
tags = [ "from:oh-my-zsh" ];
2023-11-06 23:48:09 +00:00
}
2023-11-06 23:48:09 +00:00
{
name = "plugin/vi-mode";
2024-03-18 20:33:28 +00:00
tags = [ "from:oh-my-zsh" ];
2023-11-06 23:48:09 +00:00
}
{ name = "olets/zsh-abbr"; }
2024-03-18 20:33:28 +00:00
{ name = "zsh-users/zsh-completions"; }
{ name = "zsh-users/zsh-syntax-highlighting"; }
2023-11-06 23:48:09 +00:00
];
};
};
home.file.".config/zsh-abbr/user-abbreviations".text = builtins.readFile ./zsh/abbreviations.zsh;
2023-11-06 23:48:09 +00:00
}