Fix zsh
This commit is contained in:
parent
03f76257e3
commit
6bd49cd960
@ -132,5 +132,11 @@ in {
|
|||||||
startAt = cfg.cache.clean.dates;
|
startAt = cfg.cache.clean.dates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.activationScripts = {
|
||||||
|
homedir.text = builtins.concatStringsSep "\n" (map (dir: ''
|
||||||
|
mkdir -p ${cfg.persistRoot}${dir}
|
||||||
|
chown balsoft:users ${cfg.persistRoot}${dir}
|
||||||
|
'') (builtins.filter (lib.hasPrefix "/home/balsoft") allDirectories));
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{ pkgs, config, ... }: {
|
{ pkgs, config, lib, ... }: {
|
||||||
|
|
||||||
environment.pathsToLink = [ "/share/zsh" ];
|
environment.pathsToLink = [ "/share/zsh" ];
|
||||||
environment.sessionVariables.SHELL = "zsh";
|
environment.sessionVariables.SHELL = "zsh";
|
||||||
|
|
||||||
# A history file is screwed up otherwise :(
|
# A history file is screwed up otherwise :(
|
||||||
persist.state.directories = [ "/home/balsoft/.config/zsh/history" ];
|
persist.state.directories = [ "/home/balsoft/.local/share/zsh" ];
|
||||||
|
|
||||||
home-manager.users.balsoft.programs.zsh = {
|
home-manager.users.balsoft.programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@ -21,18 +21,18 @@
|
|||||||
history = rec {
|
history = rec {
|
||||||
size = 1000000;
|
size = 1000000;
|
||||||
save = size;
|
save = size;
|
||||||
path = "$HOME/.config/zsh/history/file";
|
path = "$HOME/.local/share/zsh/history";
|
||||||
};
|
};
|
||||||
plugins = [
|
plugins = [
|
||||||
{
|
{
|
||||||
name = "zsh-nix-shell";
|
name = "zsh-nix-shell";
|
||||||
file = "nix-shell.plugin.zsh";
|
file = "nix-shell.plugin.zsh";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "chisui";
|
owner = "chisui";
|
||||||
repo = "zsh-nix-shell";
|
repo = "zsh-nix-shell";
|
||||||
rev = "b2609ca787803f523a18bb9f53277d0121e30389";
|
rev = "b2609ca787803f523a18bb9f53277d0121e30389";
|
||||||
sha256 = "01w59zzdj12p4ag9yla9ycxx58pg3rah2hnnf3sw4yk95w3hlzi6";
|
sha256 = "01w59zzdj12p4ag9yla9ycxx58pg3rah2hnnf3sw4yk95w3hlzi6";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "zsh-autosuggestions";
|
name = "zsh-autosuggestions";
|
||||||
@ -67,63 +67,63 @@
|
|||||||
"cat" = "${pkgs.bat}/bin/bat";
|
"cat" = "${pkgs.bat}/bin/bat";
|
||||||
};
|
};
|
||||||
initExtra = ''
|
initExtra = ''
|
||||||
cmdignore=(htop tmux top vim)
|
cmdignore=(htop tmux top vim)
|
||||||
|
|
||||||
# end and compare timer, notify-send if needed
|
# end and compare timer, notify-send if needed
|
||||||
function notifyosd-precmd() {
|
function notifyosd-precmd() {
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ ! -z "$cmd" ]; then
|
if [ ! -z "$cmd" ]; then
|
||||||
cmd_end=`date +%s`
|
cmd_end=`date +%s`
|
||||||
((cmd_time=$cmd_end - $cmd_start))
|
((cmd_time=$cmd_end - $cmd_start))
|
||||||
fi
|
fi
|
||||||
if [ $retval -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
cmdstat="✓"
|
cmdstat="✓"
|
||||||
else
|
else
|
||||||
cmdstat="✘"
|
cmdstat="✘"
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$cmd" ]; then
|
if [ ! -z "$cmd" ]; then
|
||||||
${pkgs.libnotify}/bin/notify-send -i utilities-terminal -u low "$cmdstat $cmd" "in `date -u -d @$cmd_time +'%T'`"
|
${pkgs.libnotify}/bin/notify-send -i utilities-terminal -u low "$cmdstat $cmd" "in `date -u -d @$cmd_time +'%T'`"
|
||||||
fi
|
fi
|
||||||
unset cmd
|
unset cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
# make sure this plays nicely with any existing precmd
|
# make sure this plays nicely with any existing precmd
|
||||||
precmd_functions+=( notifyosd-precmd )
|
precmd_functions+=( notifyosd-precmd )
|
||||||
|
|
||||||
# get command name and start the timer
|
# get command name and start the timer
|
||||||
function notifyosd-preexec() {
|
function notifyosd-preexec() {
|
||||||
cmd=$1
|
cmd=$1
|
||||||
cmd_start=`date +%s`
|
cmd_start=`date +%s`
|
||||||
}
|
}
|
||||||
|
|
||||||
bindkey -M emacs '^H' backward-kill-word
|
bindkey -M emacs '^H' backward-kill-word
|
||||||
bindkey -r '^W'
|
bindkey -r '^W'
|
||||||
|
|
||||||
# make sure this plays nicely with any existing preexec
|
# make sure this plays nicely with any existing preexec
|
||||||
preexec_functions+=( notifyosd-preexec )
|
preexec_functions+=( notifyosd-preexec )
|
||||||
XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH
|
XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH
|
||||||
|
|
||||||
function repl() {
|
function repl() {
|
||||||
source="$(nix flake prefetch --json "$1" | ${pkgs.jq}/bin/jq -r .storePath)"
|
source="$(nix flake prefetch --json "$1" | ${pkgs.jq}/bin/jq -r .storePath)"
|
||||||
TEMP="$(mktemp --suffix=.nix)"
|
TEMP="$(mktemp --suffix=.nix)"
|
||||||
echo "let self = builtins.getFlake \"$source\"; in self // self.legacyPackages.\''${builtins.currentSystem} or { } // self.packages.\''${builtins.currentSystem} or { }" > "$TEMP"
|
echo "let self = builtins.getFlake \"$source\"; in self // self.legacyPackages.\''${builtins.currentSystem} or { } // self.packages.\''${builtins.currentSystem} or { }" > "$TEMP"
|
||||||
nix repl "$TEMP"
|
nix repl "$TEMP"
|
||||||
rm "$TEMP"
|
rm "$TEMP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function ss() { nix shell "self#$1" }
|
function ss() { nix shell "self#$1" }
|
||||||
function es() { nix edit "self#$1" }
|
function es() { nix edit "self#$1" }
|
||||||
function bs() { nix build "self#$1" }
|
function bs() { nix build "self#$1" }
|
||||||
function is() { nix search "self#$1" }
|
function is() { nix search "self#$1" }
|
||||||
function rs() { repl self }
|
function rs() { repl self }
|
||||||
|
|
||||||
source ${pkgs.nix-zsh-completions}/share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh
|
source ${pkgs.nix-zsh-completions}/share/zsh/plugins/nix/nix-zsh-completions.plugin.zsh
|
||||||
fpath=(${pkgs.nix-zsh-completions}/share/zsh/site-functions $fpath)
|
fpath=(${pkgs.nix-zsh-completions}/share/zsh/site-functions $fpath)
|
||||||
autoload -U compinit && compinit
|
autoload -U compinit && compinit
|
||||||
|
|
||||||
PS1="$PS1
|
PS1="$PS1
|
||||||
$ "
|
$ "
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user