147 lines
5.0 KiB
Nix
Raw Normal View History

2020-08-04 01:46:48 +04:00
{ pkgs, config, inputs, ... }: {
2019-08-27 20:49:08 +00:00
environment.pathsToLink = [ "/share/zsh" ];
2022-08-18 20:22:52 +03:00
environment.sessionVariables.SHELL = "${pkgs.zsh}/bin/zsh";
2022-12-10 22:34:39 +03:00
home-manager.users.${config.mainuser} = {
2022-08-18 20:22:52 +03:00
home.sessionVariables.SHELL = "${pkgs.zsh}/bin/zsh";
2023-08-30 18:38:17 +03:00
home.file.".profile".text = ''
2023-09-16 00:54:08 +03:00
. "${config.home-manager.users.${config.mainuser}.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
2023-08-30 18:38:17 +03:00
'';
2022-08-18 20:22:52 +03:00
programs = {
zsh = {
2021-03-17 23:06:22 +03:00
enable = true;
2022-08-18 20:22:52 +03:00
enableCompletion = true;
oh-my-zsh = {
enable = true;
theme = "agnoster";
plugins = [ "git" "dirhistory" ];
};
plugins = [
2022-10-21 14:08:45 +03:00
{
name = "zsh-nix-shell";
2023-03-27 20:57:06 +03:00
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
src = pkgs.zsh-nix-shell;
2022-10-21 14:08:45 +03:00
}
2022-08-18 20:22:52 +03:00
{
name = "zsh-autosuggestions";
2023-03-27 20:57:06 +03:00
file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
src = pkgs.zsh-autosuggestions;
2022-08-18 20:22:52 +03:00
}
{
name = "you-should-use";
2023-03-27 20:57:06 +03:00
file = "share/zsh/plugins/you-should-use/you-should-use.plugin.zsh";
src = pkgs.zsh-you-should-use;
2022-08-18 20:22:52 +03:00
}
2022-10-21 14:08:45 +03:00
{
name = "powerlevel10k-config";
src = ./.;
file = "p10k.zsh";
}
{
name = "zsh-powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
2022-08-18 20:22:52 +03:00
];
2021-03-17 23:06:22 +03:00
2022-08-18 20:22:52 +03:00
dotDir = ".config/zsh";
2021-06-16 05:30:04 +03:00
2022-08-18 20:22:52 +03:00
history = rec {
size = 1000000;
save = size;
path = "$HOME/.local/share/zsh/history";
};
2021-06-16 05:30:04 +03:00
2022-08-18 20:22:52 +03:00
envExtra = ''
SHELL="${pkgs.zsh}/bin/zsh";
'';
2020-08-15 19:36:16 +04:00
2022-08-18 20:22:52 +03:00
shellAliases = {
2022-12-07 22:13:34 +03:00
"_" = "doas";
2022-08-18 20:22:52 +03:00
"clr" = "clear";
2023-02-14 07:04:20 +03:00
"rcp" = "${pkgs.rsync}/bin/rsync -ah --partial --no-whole-file --info=progress2";
2024-01-21 19:29:36 +03:00
"rrcp" = "_ ${pkgs.rsync}/bin/rsync -ah --partial --no-whole-file --info=progress2";
"ncg" = "_ nix-collect-garbage";
"ncgd" = "_ nix-collect-garbage -d";
2022-08-18 20:22:52 +03:00
"weather" = "curl wttr.in/Volzhskiy";
"rede" = "systemctl --user start gammastep.service &";
"redd" = "systemctl --user stop gammastep.service &";
"show-packages" = "_ nix-store -q --references /run/current-system/sw";
"nsp" = "nix-shell --run zsh -p";
2023-01-26 00:36:27 +03:00
"nd" = "nix develop -c zsh";
2022-08-18 20:22:52 +03:00
"nb" = "nix build";
2023-10-13 19:52:54 +03:00
"nbf" = "nix-fast-build --flake";
"nbfc" = "nix-fast-build --skip-cached --flake";
2022-08-18 20:22:52 +03:00
"nr" = "nix run";
"e" = "$EDITOR";
2022-10-21 14:08:45 +03:00
"q" = "${pkgs.libqalculate}/bin/qalc";
2022-08-18 20:22:52 +03:00
"man" = "${pkgs.pinfo}/bin/pinfo";
2023-09-16 02:04:05 +03:00
"l" = "${pkgs.eza}/bin/eza -lahgF@ --git --group-directories-first";
"tree" = "${pkgs.eza}/bin/eza -T";
"ltree" = "${pkgs.eza}/bin/eza -lhgFT@ --git";
"atree" = "${pkgs.eza}/bin/eza -aT";
"latree" = "${pkgs.eza}/bin/eza -lahgFT@ --git";
2023-01-26 00:26:40 +03:00
"t" = "${pkgs.translate-shell}/bin/trans";
2023-10-13 19:51:59 +03:00
"steam-gamescope" = "gamescope -b --steam -- steam -pipewire-dmabuf";
2022-08-18 20:22:52 +03:00
};
initExtra = ''
2023-01-26 00:36:27 +03:00
setopt HIST_IGNORE_SPACE
2022-08-18 20:22:52 +03:00
rga-fzf() {
RG_PREFIX="rga --files-with-matches"
local file
file="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
--phony -q "$1" \
--bind "change:reload:$RG_PREFIX {q}" \
--preview-window="70%:wrap"
)" &&
echo "opening $file" &&
xdg-open "$file"
}
manix-fzf() {
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview="manix '{}'" | xargs manix
}
2023-03-25 19:30:34 +03:00
# zst 7z archive
z7za() {
rm /tmp/7z-exclude.lst > /dev/null 2>&1 || true
for var in "$@"; do
\find "$var" -type l -print -exec readlink -f {} \; >> /tmp/7z-exclude.lst
done
7z a $(basename "$1").7z "$@" -m0=zstd -mx3 -xr@/tmp/7z-exclude.lst
}
# zst 7z archive to backup folder
z7zab() {
rm /tmp/7z-exclude.lst > /dev/null 2>&1 || true
for var in "$@"; do
\find "$var" -type l -print -exec readlink -f {} \; >> /tmp/7z-exclude.lst
done
7z a ~/backup/$(basename "$1").7z "$@" -m0=zstd -mx3 -xr@/tmp/7z-exclude.lst
}
2024-01-21 19:29:36 +03:00
gif2webm() {
file="$1"
dir=$(dirname $1)
file="$(basename $file)"
file="''${file%.*}"
ffmpeg -i "$1" -c:v libvpx-vp9 -b:v 0 -crf 30 -an "$dir/$file.webm"
}
2021-06-16 05:30:04 +03:00
2022-08-18 20:22:52 +03:00
XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH
2022-07-06 00:14:26 +03:00
2022-10-21 14:08:45 +03:00
PS1="$PS1
$ "
2022-08-18 20:22:52 +03:00
'';
};
2020-08-15 19:36:16 +04:00
2022-08-18 20:22:52 +03:00
fzf = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
};
2021-03-17 23:06:22 +03:00
};
2019-08-27 20:49:08 +00:00
};
2022-12-14 23:49:46 +03:00
2023-01-26 00:41:28 +03:00
persist.state.homeDirectories = [ ".local/share/zsh" ];
2019-08-27 20:49:08 +00:00
}