refactor: extract zsh config

main
mandlm 2024-07-10 13:06:26 +02:00
parent 8f1ca25dba
commit 55af25ccb3
Signed by: mandlm
GPG Key ID: 088ED38F036C7AF2
4 changed files with 47 additions and 63 deletions

View File

@ -34,6 +34,7 @@
../starship.nix ../starship.nix
../tree.nix ../tree.nix
../zoxide.nix ../zoxide.nix
../zsh.nix
./ssh.nix ./ssh.nix
./zsh.nix ./zsh.nix
]; ];

View File

@ -1,68 +1,53 @@
{ ... }: { ... }:
{ {
programs.zsh = { programs.zsh.initExtra = ''
enable = true; if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ];
enableCompletion = true; then
history.size = 10000; source $HOME/.nix-profile/etc/profile.d/nix.sh
fi
autosuggestion = { function sc-log {
enable = true; ssh smartcan "SYSTEMD_COLORS=true journalctl --follow --no-tail --unit smartcan-''${1:-*}"
highlight = "fg=10"; }
};
syntaxHighlighting = { function sc-restart {
enable = true; ssh smartcan "systemctl restart smartcan-''${1}"
}; }
initExtra = '' function fu-reboot {
if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; ssh fusion "reboot"
then }
source $HOME/.nix-profile/etc/profile.d/nix.sh
function fu-flash {
local ssh_login="fusion"
local update_file=''${1}
if [ -z ''${update_file} ]; then
update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1)
fi fi
function sc-log { if [ -z ''${update_file} ]; then
ssh smartcan "SYSTEMD_COLORS=true journalctl --follow --no-tail --unit smartcan-''${1:-*}" echo "no file selected"
} return 1
fi
function sc-restart { if [ ! -f ''${update_file} ]; then
ssh smartcan "systemctl restart smartcan-''${1}" echo "file \"''${update_file}\" does not exist"
} return 2
fi
function fu-reboot { echo "flashing ''${update_file} to device..."
ssh fusion "reboot" cat "''${update_file}" | ssh ''${ssh_login} "swupdate-client -"
}
function fu-flash { if [ $? -ne 0 ]; then
local ssh_login="fusion" echo "update failed"
local update_file=''${1} return 3
fi
if [ -z ''${update_file} ]; then echo "rebooting device"
update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1) ssh ''${ssh_login} reboot
fi
if [ -z ''${update_file} ]; then echo "done."
echo "no file selected" }
return 1 '';
fi
if [ ! -f ''${update_file} ]; then
echo "file \"''${update_file}\" does not exist"
return 2
fi
echo "flashing ''${update_file} to device..."
cat "''${update_file}" | ssh ''${ssh_login} "swupdate-client -"
if [ $? -ne 0 ]; then
echo "update failed"
return 3
fi
echo "rebooting device"
ssh ''${ssh_login} reboot
echo "done."
}
'';
};
} }

View File

@ -71,6 +71,6 @@
../sway ../sway
../tree.nix ../tree.nix
../zoxide.nix ../zoxide.nix
./zsh.nix ../zsh.nix
]; ];
} }

View File

@ -13,6 +13,10 @@ in
highlight = zsh_autosuggest_highlight_style; highlight = zsh_autosuggest_highlight_style;
}; };
syntaxHighlighting = {
enable = true;
};
initExtra = '' initExtra = ''
function set_win_title(){ function set_win_title(){
local TITLE=$(git config --get remote.origin.url || echo "$PWD") local TITLE=$(git config --get remote.origin.url || echo "$PWD")
@ -21,11 +25,5 @@ in
precmd_functions+=(set_win_title) precmd_functions+=(set_win_title)
''; '';
shellAliases = {
ls = "eza --group-directories-first --git";
neovide = "neovide --multigrid";
xclip = "xclip -selection clipboard";
};
}; };
} }