split zsh config into several nix files
This commit is contained in:
36
modules/home/environment/zsh/aliases.nix
Normal file
36
modules/home/environment/zsh/aliases.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ lib, config, self, ... }:
|
||||
{
|
||||
options.movOpts.envConfig.zshConfig.shellAliases.enable = lib.mkEnableOption "enables my zsh aliases";
|
||||
config = lib.mkIf config.movOpts.envConfig.zshConfig.shellAliases.enable {
|
||||
programs.zsh = {
|
||||
shellAliases = {
|
||||
grep = "grep --color=auto";
|
||||
yazi = "y";
|
||||
vi = "nvim";
|
||||
mv = "mv -v";
|
||||
cp = "cp -vr";
|
||||
gt = "gtrash";
|
||||
gtp = "playshellsound ${self}/assets/sound/rm.wav; gtrash put";
|
||||
sr = "source ~/.zshrc";
|
||||
".." = "cd ..";
|
||||
rm = "echo 'use \"gtp\" instead'";
|
||||
psg = "ps aux | grep -v grep | grep -i -e VSZ -e";
|
||||
mkdir = "mkdir -p";
|
||||
pk = "pkill -9 -f";
|
||||
svcu = "systemctl --user";
|
||||
svc = "sudo systemctl";
|
||||
viflake = "nvim flake.nix";
|
||||
iv = "invoke";
|
||||
cfgfilecount =
|
||||
''find $FLAKEPATH -name "*.nix" | wc -l | toilet -f 3d | lolcat'';
|
||||
|
||||
#git
|
||||
ga = "playshellsound ${self}/assets/sound/gitadd.wav; git add";
|
||||
gcomm = "gitcommit_sfx";
|
||||
gpush = "gitpush_sfx";
|
||||
gpull = "gitpull_sfx";
|
||||
greb = "gitrebase_sfx";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
modules/home/environment/zsh/default.nix
Normal file
10
modules/home/environment/zsh/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ lib, config, self, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./env.nix
|
||||
./aliases.nix
|
||||
./options.nix
|
||||
./extraconfig.nix
|
||||
];
|
||||
}
|
||||
22
modules/home/environment/zsh/env.nix
Normal file
22
modules/home/environment/zsh/env.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ lib, config, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
movOpts.envConfig.zshConfig.envVariables.enable = lib.mkEnableOption "enables my default session variables";
|
||||
};
|
||||
config = lib.mkIf config.movOpts.envConfig.zshConfig.envVariables.enable {
|
||||
programs.zsh = {
|
||||
sessionVariables = {
|
||||
SOUNDS_ENABLED = "1";
|
||||
EDITOR = "nvim";
|
||||
SUDO_EDITOR = "nvim";
|
||||
VISUAL = "nvim";
|
||||
LANG = "en_US.UTF-8";
|
||||
BROWSER = "firefox";
|
||||
FLAKEPATH = "$HOME/.sysflake";
|
||||
STEAMPATH = "$HOME/.local/share/Steam";
|
||||
PATH = "$PATH:$HOME/.userpath/";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
158
modules/home/environment/zsh/extraconfig.nix
Normal file
158
modules/home/environment/zsh/extraconfig.nix
Normal file
@@ -0,0 +1,158 @@
|
||||
{ lib, config, self, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
movOpts.envConfig.zshConfig.extraConfig.enable = lib.mkEnableOption "enables my extra shell configurations";
|
||||
};
|
||||
config = lib.mkIf config.movOpts.envConfig.zshConfig.extraConfig.enable {
|
||||
programs.zsh = {
|
||||
initExtra = ''
|
||||
playshellsound() {
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: playshellsound <path/to/sound>"
|
||||
return 1
|
||||
fi
|
||||
if ! scheck; then
|
||||
return 0
|
||||
else
|
||||
runbg aplay "$1"
|
||||
fi
|
||||
}
|
||||
grimblast() {
|
||||
command grimblast "$@"
|
||||
playshellsound ${self}/assets/sound/screenshot.wav
|
||||
}
|
||||
ssh() { # reverts ssh theme upon returning
|
||||
command ssh "$@"
|
||||
kitty_ssh_theme
|
||||
}
|
||||
kitty_ssh_theme() {
|
||||
if [ -n "$SSH_CONNECTION" ]; then
|
||||
kitty @ set-colors -a ~/.config/kitty/ssh-theme.conf
|
||||
else
|
||||
kitty @ set-colors -a ~/.config/kitty/default-theme.conf
|
||||
fi
|
||||
}
|
||||
gitcheckout_sfx() {
|
||||
if git checkout "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitcheckout.wav
|
||||
return 0
|
||||
else
|
||||
playshellsound ${self}/assets/sound/error.wav
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
gitrebase_sfx() {
|
||||
if git rebase "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitrebase.wav
|
||||
return 0
|
||||
else
|
||||
playshellsound ${self}/assets/sound/error.wav
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
gitcommit_sfx() {
|
||||
if git commit "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitcommit.wav
|
||||
return 0
|
||||
else
|
||||
playshellsound ${self}/assets/sound/error.wav
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
gitpush_sfx() {
|
||||
if git push "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitpush.wav
|
||||
return 0
|
||||
else
|
||||
playshellsound ${self}/assets/sound/error.wav
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
gitpull_sfx() {
|
||||
if git pull "$@"; then
|
||||
playshellsound ${self}/assets/sound/gitpull.wav
|
||||
return 0
|
||||
else
|
||||
playshellsound ${self}/assets/sound/error.wav
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
unalias ls
|
||||
ls() {
|
||||
eza -1 --group-directories-first --icons "$@"
|
||||
playshellsound ${self}/assets/sound/ls.wav
|
||||
return 0
|
||||
}
|
||||
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
y() {
|
||||
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||
builtin cd -- "$cwd"
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
}
|
||||
|
||||
cd() {
|
||||
local prev_sounds_enabled="$SOUNDS_ENABLED"
|
||||
SOUNDS_ENABLED=0
|
||||
eza -1 --group-directories-first --icons "$@"
|
||||
SOUNDS_ENABLED=$prev_sounds_enabled
|
||||
builtin cd "$@"
|
||||
playshellsound /nix/store/7a9w7np3qrvmzxjbs7xj05qq2yccgfsj-source/assets/sound/cd.wav
|
||||
return 0
|
||||
}
|
||||
if [ ! -e $HOME/.zsh_history ]; then
|
||||
touch $HOME/.zsh_history
|
||||
chmod 600 $HOME/.zsh_history
|
||||
fi
|
||||
setopt APPEND_HISTORY # Append history to the history file (don't overwrite)
|
||||
setopt INC_APPEND_HISTORY # Append to the history file incrementally
|
||||
setopt SHARE_HISTORY # Share history between all zsh sessions
|
||||
|
||||
setopt CORRECT
|
||||
setopt NO_NOMATCH
|
||||
setopt LIST_PACKED
|
||||
setopt ALWAYS_TO_END
|
||||
setopt GLOB_COMPLETE
|
||||
setopt COMPLETE_ALIASES
|
||||
setopt COMPLETE_IN_WORD
|
||||
setopt AUTO_CD
|
||||
setopt AUTO_CONTINUE
|
||||
setopt LONG_LIST_JOBS
|
||||
setopt HIST_VERIFY
|
||||
setopt SHARE_HISTORY
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt EXTENDED_GLOB
|
||||
setopt TRANSIENT_RPROMPT
|
||||
setopt INTERACTIVE_COMMENTS
|
||||
|
||||
autoload -U compinit # completion
|
||||
autoload -U terminfo # terminfo keys
|
||||
zmodload -i zsh/complist # menu completion
|
||||
autoload -U promptinit # prompt
|
||||
|
||||
autoload -U up-line-or-beginning-search; zle -N up-line-or-beginning-search
|
||||
autoload -U down-line-or-beginning-search; zle -N down-line-or-beginning-search
|
||||
|
||||
bindkey -v
|
||||
kitty_ssh_theme
|
||||
type starship_zle-keymap-select >/dev/null || \
|
||||
{
|
||||
eval "$(starship init zsh)"
|
||||
}
|
||||
unalias ls
|
||||
clear
|
||||
playshellsound ${self}/assets/sound/sh-source.wav
|
||||
[ ! -f $FLAKEPATH/flake.nix ] && echo "WARNING: flake.nix not found at \$FLAKEPATH. Shell aliases for editing config files won't work correctly!" && echo "Edit the FLAKEPATH session variable in zshell.nix to point to the path where you saved the system configuration flake."
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
30
modules/home/environment/zsh/options.nix
Normal file
30
modules/home/environment/zsh/options.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{ lib, config, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
movOpts.envConfig.zshConfig.shellOptions.enable = lib.mkEnableOption "enables my default shell settings";
|
||||
};
|
||||
config = lib.mkIf config.movOpts.envConfig.zshConfig.shellOptions.enable {
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
plugins = [ "git" "fzf" ];
|
||||
};
|
||||
|
||||
enableCompletion = true;
|
||||
|
||||
history = {
|
||||
path = "$HOME/.zsh_history";
|
||||
save = 10000;
|
||||
size = 10000;
|
||||
share = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user