home: zsh: port to programs API
This commit is contained in:
parent
a6056aeb47
commit
4c74a95194
|
@ -1,7 +1,7 @@
|
||||||
{ config, lib, pkgs, sane-lib, ... }:
|
{ config, lib, pkgs, sane-lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkIf mkMerge mkOption types;
|
||||||
cfg = config.sane.zsh;
|
cfg = config.sane.zsh;
|
||||||
# powerlevel10k prompt config
|
# powerlevel10k prompt config
|
||||||
# p10k.zsh is the auto-generated config, and i overwrite those defaults here, below.
|
# p10k.zsh is the auto-generated config, and i overwrite those defaults here, below.
|
||||||
|
@ -38,124 +38,129 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = mkMerge [
|
||||||
sane.user.persist.plaintext = [
|
({
|
||||||
# we don't need to full zsh dir -- just the history file --
|
sane.programs.zsh = {
|
||||||
# but zsh will sometimes backup the history file and we get fewer errors if we do proper mounts instead of symlinks.
|
persist.plaintext = [
|
||||||
# TODO: should be private?
|
# we don't need to full zsh dir -- just the history file --
|
||||||
".local/share/zsh"
|
# but zsh will sometimes backup the history file and we get fewer errors if we do proper mounts instead of symlinks.
|
||||||
# cache gitstatus otherwise p10k fetched it from the net EVERY BOOT
|
# TODO: should be private?
|
||||||
".cache/gitstatus"
|
".local/share/zsh"
|
||||||
];
|
# cache gitstatus otherwise p10k fetched it from the net EVERY BOOT
|
||||||
|
".cache/gitstatus"
|
||||||
|
];
|
||||||
|
|
||||||
# zsh/prezto complains if zshrc doesn't exist; but it does allow an "empty" file.
|
# zsh/prezto complains if zshrc doesn't exist; but it does allow an "empty" file.
|
||||||
sane.user.fs.".config/zsh/.zshrc" = sane-lib.fs.wantedText "# ";
|
fs.".config/zsh/.zshrc" = sane-lib.fs.wantedText "# ";
|
||||||
|
|
||||||
# enable zsh completions
|
# prezto = oh-my-zsh fork; controls prompt, auto-completion, etc.
|
||||||
environment.pathsToLink = [ "/share/zsh" ];
|
# see: https://github.com/sorin-ionescu/prezto
|
||||||
|
# i believe this file is auto-sourced by the prezto init.zsh script.
|
||||||
|
fs.".config/zsh/.zpreztorc" = sane-lib.fs.wantedText ''
|
||||||
|
zstyle ':prezto:*:*' color 'yes'
|
||||||
|
|
||||||
programs.zsh = {
|
# modules (they ship with prezto):
|
||||||
enable = true;
|
# ENVIRONMENT: configures jobs to persist after shell exit; other basic niceties
|
||||||
histFile = "$HOME/.local/share/zsh/history";
|
# TERMINAL: auto-titles terminal (e.g. based on cwd)
|
||||||
shellAliases = {
|
# EDITOR: configures shortcuts like Ctrl+U=undo, Ctrl+L=clear
|
||||||
":q" = "exit";
|
# HISTORY: `history-stat` alias, setopts for good history defaults
|
||||||
# common typos
|
# DIRECTORY: sets AUTO_CD, adds `d` alias to list directory stack, and `1`-`9` to cd that far back the stack
|
||||||
"cd.." = "cd ..";
|
# SPECTRUM: helpers for term colors and styling. used by prompts? might be unnecessary
|
||||||
"cd../" = "cd ../";
|
# UTILITY: configures aliases like `ll`, `la`, disables globbing for things like rsync
|
||||||
|
# adds aliases like `get` to fetch a file. also adds `http-serve` alias??
|
||||||
|
# COMPLETION: tab completion. requires `utility` module prior to loading
|
||||||
|
# TODO: enable AUTO_PARAM_SLASH
|
||||||
|
zstyle ':prezto:load' pmodule \
|
||||||
|
'environment' \
|
||||||
|
'terminal' \
|
||||||
|
'editor' \
|
||||||
|
'history' \
|
||||||
|
'directory' \
|
||||||
|
'spectrum' \
|
||||||
|
'utility' \
|
||||||
|
'completion' \
|
||||||
|
'prompt'
|
||||||
|
|
||||||
|
# default keymap. try also `vicmd` (vim normal mode, AKA "cmd mode") or `vi`.
|
||||||
|
zstyle ':prezto:module:editor' key-bindings 'emacs'
|
||||||
|
|
||||||
|
zstyle ':prezto:module:prompt' theme 'powerlevel10k'
|
||||||
|
|
||||||
|
# disable `mv` confirmation (and `rm`, too, unfortunately)
|
||||||
|
zstyle ':prezto:module:utility' safe-ops 'no'
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
setOptions = [
|
})
|
||||||
# defaults:
|
(mkIf config.sane.programs.zsh.enabled {
|
||||||
"HIST_IGNORE_DUPS"
|
# enable zsh completions
|
||||||
"SHARE_HISTORY"
|
environment.pathsToLink = [ "/share/zsh" ];
|
||||||
"HIST_FCNTL_LOCK"
|
|
||||||
# disable `rm *` confirmations
|
|
||||||
"rmstarsilent"
|
|
||||||
];
|
|
||||||
|
|
||||||
# .zshenv config:
|
programs.zsh = {
|
||||||
shellInit = ''
|
enable = true;
|
||||||
ZDOTDIR=$HOME/.config/zsh
|
histFile = "$HOME/.local/share/zsh/history";
|
||||||
'';
|
shellAliases = {
|
||||||
|
":q" = "exit";
|
||||||
|
# common typos
|
||||||
|
"cd.." = "cd ..";
|
||||||
|
"cd../" = "cd ../";
|
||||||
|
};
|
||||||
|
setOptions = [
|
||||||
|
# defaults:
|
||||||
|
"HIST_IGNORE_DUPS"
|
||||||
|
"SHARE_HISTORY"
|
||||||
|
"HIST_FCNTL_LOCK"
|
||||||
|
# disable `rm *` confirmations
|
||||||
|
"rmstarsilent"
|
||||||
|
];
|
||||||
|
|
||||||
# .zshrc config:
|
# .zshenv config:
|
||||||
interactiveShellInit =
|
shellInit = ''
|
||||||
(builtins.readFile ./p10k.zsh)
|
ZDOTDIR=$HOME/.config/zsh
|
||||||
+ p10k-overrides
|
'';
|
||||||
+ prezto-init
|
|
||||||
+ ''
|
|
||||||
# zmv is a way to do rich moves/renames, with pattern matching/substitution.
|
|
||||||
# see for an example: <https://filipe.kiss.ink/zmv-zsh-rename/>
|
|
||||||
autoload -Uz zmv
|
|
||||||
|
|
||||||
HISTORY_IGNORE='(sane-shutdown *|sane-reboot *|rm *|nixos-rebuild.* switch)'
|
# .zshrc config:
|
||||||
|
interactiveShellInit =
|
||||||
|
(builtins.readFile ./p10k.zsh)
|
||||||
|
+ p10k-overrides
|
||||||
|
+ prezto-init
|
||||||
|
+ ''
|
||||||
|
# zmv is a way to do rich moves/renames, with pattern matching/substitution.
|
||||||
|
# see for an example: <https://filipe.kiss.ink/zmv-zsh-rename/>
|
||||||
|
autoload -Uz zmv
|
||||||
|
|
||||||
# extra aliases
|
HISTORY_IGNORE='(sane-shutdown *|sane-reboot *|rm *|nixos-rebuild.* switch)'
|
||||||
# TODO: move to `shellAliases` config?
|
|
||||||
function nd() {
|
|
||||||
mkdir -p "$1";
|
|
||||||
pushd "$1";
|
|
||||||
}
|
|
||||||
''
|
|
||||||
+ lib.optionalString cfg.showDeadlines ''
|
|
||||||
${pkgs.sane-scripts}/bin/sane-deadlines
|
|
||||||
''
|
|
||||||
+ ''
|
|
||||||
# auto-cd into any of these dirs by typing them and pressing 'enter':
|
|
||||||
hash -d 3rd="/home/colin/dev/3rd"
|
|
||||||
hash -d dev="/home/colin/dev"
|
|
||||||
hash -d knowledge="/home/colin/knowledge"
|
|
||||||
hash -d nixos="/home/colin/nixos"
|
|
||||||
hash -d nixpkgs="/home/colin/dev/3rd/nixpkgs"
|
|
||||||
hash -d ref="/home/colin/ref"
|
|
||||||
hash -d secrets="/home/colin/knowledge/secrets"
|
|
||||||
hash -d tmp="/home/colin/tmp"
|
|
||||||
hash -d uninsane="/home/colin/dev/uninsane"
|
|
||||||
hash -d Videos="/home/colin/Videos"
|
|
||||||
'';
|
|
||||||
|
|
||||||
syntaxHighlighting.enable = true;
|
# extra aliases
|
||||||
vteIntegration = true;
|
# TODO: move to `shellAliases` config?
|
||||||
};
|
function nd() {
|
||||||
|
mkdir -p "$1";
|
||||||
|
pushd "$1";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
+ lib.optionalString cfg.showDeadlines ''
|
||||||
|
${pkgs.sane-scripts}/bin/sane-deadlines
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
# auto-cd into any of these dirs by typing them and pressing 'enter':
|
||||||
|
hash -d 3rd="/home/colin/dev/3rd"
|
||||||
|
hash -d dev="/home/colin/dev"
|
||||||
|
hash -d knowledge="/home/colin/knowledge"
|
||||||
|
hash -d nixos="/home/colin/nixos"
|
||||||
|
hash -d nixpkgs="/home/colin/dev/3rd/nixpkgs"
|
||||||
|
hash -d ref="/home/colin/ref"
|
||||||
|
hash -d secrets="/home/colin/knowledge/secrets"
|
||||||
|
hash -d tmp="/home/colin/tmp"
|
||||||
|
hash -d uninsane="/home/colin/dev/uninsane"
|
||||||
|
hash -d Videos="/home/colin/Videos"
|
||||||
|
'';
|
||||||
|
|
||||||
# enable a command-not-found hook to show nix packages that might provide the binary typed.
|
syntaxHighlighting.enable = true;
|
||||||
programs.nix-index.enable = true;
|
vteIntegration = true;
|
||||||
programs.command-not-found.enable = false; #< mutually exclusive with nix-index
|
};
|
||||||
|
|
||||||
# prezto = oh-my-zsh fork; controls prompt, auto-completion, etc.
|
# enable a command-not-found hook to show nix packages that might provide the binary typed.
|
||||||
# see: https://github.com/sorin-ionescu/prezto
|
programs.nix-index.enable = true;
|
||||||
# i believe this file is auto-sourced by the prezto init.zsh script.
|
programs.command-not-found.enable = false; #< mutually exclusive with nix-index
|
||||||
sane.user.fs.".config/zsh/.zpreztorc" = sane-lib.fs.wantedText ''
|
})
|
||||||
zstyle ':prezto:*:*' color 'yes'
|
];
|
||||||
|
|
||||||
# modules (they ship with prezto):
|
|
||||||
# ENVIRONMENT: configures jobs to persist after shell exit; other basic niceties
|
|
||||||
# TERMINAL: auto-titles terminal (e.g. based on cwd)
|
|
||||||
# EDITOR: configures shortcuts like Ctrl+U=undo, Ctrl+L=clear
|
|
||||||
# HISTORY: `history-stat` alias, setopts for good history defaults
|
|
||||||
# DIRECTORY: sets AUTO_CD, adds `d` alias to list directory stack, and `1`-`9` to cd that far back the stack
|
|
||||||
# SPECTRUM: helpers for term colors and styling. used by prompts? might be unnecessary
|
|
||||||
# UTILITY: configures aliases like `ll`, `la`, disables globbing for things like rsync
|
|
||||||
# adds aliases like `get` to fetch a file. also adds `http-serve` alias??
|
|
||||||
# COMPLETION: tab completion. requires `utility` module prior to loading
|
|
||||||
# TODO: enable AUTO_PARAM_SLASH
|
|
||||||
zstyle ':prezto:load' pmodule \
|
|
||||||
'environment' \
|
|
||||||
'terminal' \
|
|
||||||
'editor' \
|
|
||||||
'history' \
|
|
||||||
'directory' \
|
|
||||||
'spectrum' \
|
|
||||||
'utility' \
|
|
||||||
'completion' \
|
|
||||||
'prompt'
|
|
||||||
|
|
||||||
# default keymap. try also `vicmd` (vim normal mode, AKA "cmd mode") or `vi`.
|
|
||||||
zstyle ':prezto:module:editor' key-bindings 'emacs'
|
|
||||||
|
|
||||||
zstyle ':prezto:module:prompt' theme 'powerlevel10k'
|
|
||||||
|
|
||||||
# disable `mv` confirmation (and `rm`, too, unfortunately)
|
|
||||||
zstyle ':prezto:module:utility' safe-ops 'no'
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ let
|
||||||
# yarn
|
# yarn
|
||||||
# youtube-dl
|
# youtube-dl
|
||||||
yt-dlp
|
yt-dlp
|
||||||
|
zsh
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user