2021-06-13 21:56:34 +04:00
|
|
|
{ pkgs, config, lib, ... }: {
|
2020-02-17 17:00:59 +04:00
|
|
|
|
|
|
|
environment.pathsToLink = [ "/share/zsh" ];
|
|
|
|
environment.sessionVariables.SHELL = "zsh";
|
2021-06-08 20:35:21 +04:00
|
|
|
|
2021-06-09 02:00:13 +04:00
|
|
|
# A history file is screwed up otherwise :(
|
2021-06-13 21:56:34 +04:00
|
|
|
persist.state.directories = [ "/home/balsoft/.local/share/zsh" ];
|
2021-06-08 20:35:21 +04:00
|
|
|
|
2020-02-17 17:00:59 +04:00
|
|
|
home-manager.users.balsoft.programs.zsh = {
|
|
|
|
enable = true;
|
2021-11-21 22:44:14 +04:00
|
|
|
# enableAutosuggestions = true;
|
2020-02-17 17:00:59 +04:00
|
|
|
enableCompletion = true;
|
|
|
|
oh-my-zsh = {
|
|
|
|
enable = true;
|
|
|
|
theme = "agnoster";
|
|
|
|
plugins = [ "git" "dirhistory" ];
|
|
|
|
};
|
2021-02-01 20:54:45 +04:00
|
|
|
|
2021-06-09 02:00:13 +04:00
|
|
|
dotDir = ".config/zsh";
|
|
|
|
|
2020-08-22 12:09:44 +04:00
|
|
|
history = rec {
|
|
|
|
size = 1000000;
|
|
|
|
save = size;
|
2021-06-13 21:56:34 +04:00
|
|
|
path = "$HOME/.local/share/zsh/history";
|
2020-08-22 12:09:44 +04:00
|
|
|
};
|
2020-02-17 17:00:59 +04:00
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
name = "zsh-autosuggestions";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "zsh-users";
|
|
|
|
repo = "zsh-autosuggestions";
|
|
|
|
rev = "v0.4.0";
|
|
|
|
sha256 = "0z6i9wjjklb4lvr7zjhbphibsyx51psv50gm07mbb0kj9058j6kc";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "you-should-use";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "MichaelAquilina";
|
|
|
|
repo = "zsh-you-should-use";
|
|
|
|
rev = "2be37f376c13187c445ae9534550a8a5810d4361";
|
|
|
|
sha256 = "0yhwn6av4q6hz9s34h4m3vdk64ly6s28xfd8ijgdbzic8qawj5p1";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
shellAliases = {
|
2021-02-03 22:02:39 +04:00
|
|
|
"b" = "nix build";
|
2020-02-17 17:00:59 +04:00
|
|
|
"p" = "nix-shell --run zsh -p";
|
2021-02-01 20:54:45 +04:00
|
|
|
"s" = "nix shell";
|
2022-06-02 00:41:05 +04:00
|
|
|
"e" = "$EDITOR -n";
|
|
|
|
"dog" = "$EDITOR -n -";
|
2021-02-01 20:54:45 +04:00
|
|
|
"d" = "nix develop";
|
2021-02-03 22:02:39 +04:00
|
|
|
"r" = "nix run";
|
|
|
|
"f" = "nix search";
|
|
|
|
"fs" = "nix search self";
|
2020-02-17 17:00:59 +04:00
|
|
|
"o" = "xdg-open";
|
|
|
|
"post" = ''curl -F"file=@-" https://0x0.st'';
|
2020-07-16 17:46:49 +04:00
|
|
|
"cat" = "${pkgs.bat}/bin/bat";
|
2021-06-15 00:08:02 +04:00
|
|
|
"ls" = "${pkgs.exa}/bin/exa";
|
2021-10-31 12:22:24 +04:00
|
|
|
"hpc" = "bluetoothctl connect CC:98:8B:C0:FC:D2";
|
|
|
|
"hpd" = "bluetoothctl disconnect CC:98:8B:C0:FC:D2";
|
2020-02-17 17:00:59 +04:00
|
|
|
};
|
|
|
|
initExtra = ''
|
2021-06-13 21:56:34 +04:00
|
|
|
cmdignore=(htop tmux top vim)
|
2020-02-17 17:00:59 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
# end and compare timer, notify-send if needed
|
|
|
|
function notifyosd-precmd() {
|
|
|
|
retval=$?
|
|
|
|
if [ ! -z "$cmd" ]; then
|
|
|
|
cmd_end=`date +%s`
|
|
|
|
((cmd_time=$cmd_end - $cmd_start))
|
|
|
|
fi
|
|
|
|
if [ $retval -eq 0 ]; then
|
|
|
|
cmdstat="✓"
|
|
|
|
else
|
|
|
|
cmdstat="✘"
|
|
|
|
fi
|
2021-09-23 21:13:38 +04:00
|
|
|
if [ ! -z "$cmd" ] && [[ $cmd_time -gt 3 ]]; then
|
2022-04-28 18:49:47 +04:00
|
|
|
${pkgs.libnotify}/bin/notify-send -a command_complete -i utilities-terminal -u low "$cmdstat $cmd" "in `date -u -d @$cmd_time +'%T'`"
|
2022-05-03 22:26:30 +04:00
|
|
|
echo -e '\a'
|
2021-06-13 21:56:34 +04:00
|
|
|
fi
|
|
|
|
unset cmd
|
|
|
|
}
|
2020-02-17 17:00:59 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
# make sure this plays nicely with any existing precmd
|
|
|
|
precmd_functions+=( notifyosd-precmd )
|
2020-02-17 17:00:59 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
# get command name and start the timer
|
|
|
|
function notifyosd-preexec() {
|
|
|
|
cmd=$1
|
|
|
|
cmd_start=`date +%s`
|
|
|
|
}
|
2020-02-17 17:00:59 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
bindkey -M emacs '^H' backward-kill-word
|
|
|
|
bindkey -r '^W'
|
2020-06-17 12:08:14 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
# make sure this plays nicely with any existing preexec
|
|
|
|
preexec_functions+=( notifyosd-preexec )
|
|
|
|
XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH
|
2021-02-03 22:02:39 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
function repl() {
|
|
|
|
source="$(nix flake prefetch --json "$1" | ${pkgs.jq}/bin/jq -r .storePath)"
|
|
|
|
TEMP="$(mktemp --suffix=.nix)"
|
|
|
|
echo "let self = builtins.getFlake \"$source\"; in self // self.legacyPackages.\''${builtins.currentSystem} or { } // self.packages.\''${builtins.currentSystem} or { }" > "$TEMP"
|
|
|
|
nix repl "$TEMP"
|
|
|
|
rm "$TEMP"
|
|
|
|
}
|
2021-03-11 21:28:50 +04:00
|
|
|
|
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
function ss() { nix shell "self#$1" }
|
|
|
|
function es() { nix edit "self#$1" }
|
|
|
|
function bs() { nix build "self#$1" }
|
|
|
|
function is() { nix search "self#$1" }
|
|
|
|
function rs() { repl self }
|
2021-02-03 22:02:39 +04:00
|
|
|
|
2021-06-13 21:56:34 +04:00
|
|
|
PS1="$PS1
|
2021-06-14 12:05:14 +04:00
|
|
|
$ "
|
2021-06-13 21:56:34 +04:00
|
|
|
'';
|
2020-02-17 17:00:59 +04:00
|
|
|
};
|
|
|
|
}
|