I don't know if i like this

This commit is contained in:
Gerg-L 2025-01-17 19:18:32 -05:00
parent c6a9144ffe
commit 1b62d16ddc
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
63 changed files with 369 additions and 294 deletions

127
nixosModules/DE/dwm.nix Normal file
View file

@ -0,0 +1,127 @@
{
pkgs,
config,
lib,
suckless,
self',
}:
{
options.local.DE.dwm.enable = lib.mkEnableOption "";
config = lib.mkIf config.local.DE.dwm.enable {
local.packages = {
inherit (suckless.packages) dmenu dwm st;
inherit (pkgs)
maim
playerctl
xclip
feh
numlockx
picom
sxhkd
xscreensaver
;
xsecurelock = pkgs.writeShellScriptBin "xsecurelock" ''
export XSECURELOCK_BLANK_TIMEOUT="30"
export XSECURELOCK_AUTH_TIMEOUT="30"
export XSECURELOCK_BLANK_DPMS_STATE="off"
export XSECURELOCK_BACKGROUND_COLOR="#000000"
export XSECURELOCK_AUTH_BACKGROUND_COLOR="#080808"
export XSECURELOCK_AUTH_FOREGROUND_COLOR="#bdbdbd"
export XSECURELOCK_FONT="Overpass"
export XSECURELOCK_SHOW_DATETIME="1"
${lib.getExe pkgs.xsecurelock}
'';
};
systemd.user.services = {
sxhkd = {
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${lib.getExe pkgs.sxhkd} -c /etc/sxhkd/sxhkdrc";
Restart = "always";
RestartSec = 2;
ExecReload = "pkill -usr1 -x $MAINPID";
};
};
picom = {
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${lib.getExe pkgs.picom} --backend egl";
Restart = "always";
RestartSec = 2;
ExecReload = "pkill -usr1 -x $MAINPID";
};
};
};
services = {
gvfs.enable = true;
displayManager.defaultSession = "none+dwm";
xserver = {
enable = true;
displayManager = {
sessionCommands = ''
feh --bg-center "${self'.packages.images}/recursion.png"
numlockx
'';
};
windowManager.session = [
{
name = "dwm";
start = ''
update_time () {
while :
do
sleep 1
xsetroot -name "$(date +"%I:%M %p")"
done
}
dont_stop() {
while type dwm >/dev/null ; do dwm && continue || break ; done
}
update_time &
dont_stop &
waitPID=$!
'';
}
];
};
};
environment.etc."sxhkd/sxhkdrc".text = ''
XF86AudioPlay
playerctl play-pause
XF86AudioPause
playerctl play-pause
XF86AudioStop
playerctl stop
XF86AudioNext
playerctl next
XF86AudioPrev
playerctl previous
XF86AudioRaiseVolume
wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+
XF86AudioLowerVolume
wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-
XF86AudioMute
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
Print
maim $HOME/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
Print + shift
maim | xclip -selection clipboard -t image/png
super + Print
maim -s $HOME/Screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
super + Print + shift
maim -s | xclip -selection clipboard -t image/png
super + ctrl + r
pkill -usr1 -x sxhkd
super + ctrl + l
xsecurelock
'';
};
}

51
nixosModules/DE/gnome.nix Normal file
View file

@ -0,0 +1,51 @@
{
config,
lib,
pkgs,
}:
{
options.local.DE.gnome.enable = lib.mkEnableOption "";
config = lib.mkIf config.local.DE.gnome.enable {
environment = {
systemPackages = [ pkgs.gnome.gnome-calculator ];
gnome.excludePackages = builtins.attrValues {
inherit (pkgs)
gnome-photos
gnome-tour
gnome-text-editor
gnome-online-accounts
;
inherit (pkgs.gnome)
gnome-weather
gnome-shell
gnome-disk-utility
gnome-maps
gnome-clocks
gnome-remote-desktop
gnome-calendar
gnome-music
simple-scan
cheese # webcam tool
epiphany # web browser
geary # email reader
evince # document viewer
gnome-characters
totem # video player
tali # poker game
iagno # go game
hitori # sudoku game
atomix # puzzle game
;
};
};
services = {
displayManager.defaultSession = "gnome";
xserver = {
enable = true;
desktopManager.gnome.enable = true;
};
};
};
}

22
nixosModules/DE/xfce.nix Normal file
View file

@ -0,0 +1,22 @@
{
config,
lib,
pkgs,
}:
{
options.local.DE.xfce.enable = lib.mkEnableOption "";
config = lib.mkIf config.local.DE.xfce.enable {
environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
services = {
xserver = {
enable = true;
desktopManager.xfce = {
enable = true;
enableScreensaver = true;
};
};
displayManager.defaultSession = "xfce";
};
};
}

View file

@ -0,0 +1,19 @@
{ config, lib }:
{
options.local.DM = {
autoLogin = lib.mkEnableOption "";
loginUser = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
};
config = lib.mkIf config.local.DM.autoLogin {
services.displayManager = {
autoLogin = {
enable = true;
user = config.local.DM.loginUser;
};
};
};
}

View file

@ -0,0 +1,47 @@
{
self',
config,
lib,
}:
{
options.local.DM.lightdm.enable = lib.mkEnableOption "";
config = lib.mkIf config.local.DM.lightdm.enable {
services.xserver.displayManager = {
lightdm = {
enable = true;
background = "${self'.packages.images}/recursion.png";
extraConfig = "minimum-vt=1";
greeters.mini = {
enable = true;
user = config.local.DM.loginUser;
extraConfig = ''
[greeter]
show-password-label = false
password-label-text =
invalid-password-text =
show-input-cursor = false
password-alignment = center
password-input-width = 19
show-image-on-all-monitors = true
[greeter-theme]
font = "OverpassMono Nerd Font"
font-size = 1.1em
text-color = "#7AA2F7"
error-color = "#DB4B4B"
background-color = "#000000"
window-color = "#000000"
border-color = "#000000"
password-character = -1
password-color = "#7AA2F7"
password-background-color = "#24283B"
password-border-color = "#000000"
password-border-radius = 0.341125em
'';
};
};
};
};
}

11
nixosModules/X11.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, lib }:
{
services.xserver = {
tty = lib.mkDefault 1;
exportConfiguration = true;
xkb.layout = "us";
xautolock.enable = false;
excludePackages = [ pkgs.xterm ];
desktopManager.xterm.enable = false;
};
}

20
nixosModules/_default.nix Normal file
View file

@ -0,0 +1,20 @@
{
self,
unstable,
...
}:
let
myLib = self.lib;
inherit (unstable) lib;
in
lib.pipe ./. [
myLib.listNixFilesRecursive
(map (name: {
name = lib.pipe name [
(lib.removeSuffix ".nix")
(lib.removePrefix "${./.}/")
];
value = myLib.addSchizophreniaToModule name;
}))
builtins.listToAttrs
]

View file

@ -0,0 +1,41 @@
{
lib,
self',
pkgs,
config,
}:
{
options.local.bootConfig.disable = lib.mkEnableOption "";
config = lib.mkIf (!config.local.bootConfig.disable) {
boot = {
loader = {
grub.configurationLimit = 10;
systemd-boot = {
configurationLimit = 10;
enable = lib.mkDefault true;
consoleMode = "max";
editor = false;
};
efi.canTouchEfiVariables = lib.mkDefault true;
};
plymouth = {
enable = lib.mkDefault true;
theme = "breeze";
logo = "${self'.packages.images}/logo.png";
};
};
systemd.services.efibootmgr = {
reloadIfChanged = false;
restartIfChanged = false;
stopIfChanged = false;
wantedBy = [ "default.target" ];
serviceConfig = {
ExecStart = "${lib.getExe' pkgs.efibootmgr "efibootmgr"} -t 0";
Type = "oneshot";
RemainAfterExit = true;
};
};
};
}

View file

@ -0,0 +1,42 @@
{ lib }:
{
/*
Lots taken from here
https://wiki.archlinux.org/title/Silent_boot
*/
environment.etc.issue = {
/*
Turns the cursor back on in the TTY
It's the output of this commmand
setterm -cursor on
*/
text = "[?12l[?25h";
mode = "0444";
};
boot = {
kernelParams = lib.mkBefore [
"fbcon=nodefer" # Wipes the vendor logo earlier
"vt.global_cursor_default=0" # Stops cursor blinking while booting
"quiet" # Less log messages
"systemd.show_status=auto" # Only show systemd errors
"udev.log_level=3" # Only show udev errors
"splash" # Show splash
];
consoleLogLevel = 3; # Only errors
initrd = {
verbose = false; # Less stage1 messages
systemd.enable = true; # Use systemd initrd
};
# Hide grub (if it's being used)
loader.grub.extraConfig = ''
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT_QUIET=true
'';
/*
Not recommended
rolling back can be a pain
*/
#timeout = 0;
};
}

44
nixosModules/builders.nix Normal file
View file

@ -0,0 +1,44 @@
{ config, lib }:
{
options.local.remoteBuild.enable = lib.mkEnableOption "";
config = lib.mkMerge [
(lib.mkIf config.local.remoteBuild.enable {
nix = {
settings = {
keep-outputs = false;
keep-derivations = false;
builders-use-substitutes = true;
max-jobs = 0;
substituters = [ "https://cache.gerg-l.com" ];
trusted-public-keys = [ "cache.gerg-l.com:6p1+h6jQnb1MOt3ra3PlQpfgEEF4zRrQWiEuAqcjBj8=" ];
};
distributedBuilds = true;
buildMachines = [
{
hostName = "gerg-desktop";
protocol = "ssh-ng";
maxJobs = 32;
systems = [
"x86_64-linux"
"i686-linux"
];
supportedFeatures = [
"big-parallel"
"nixos-test"
"kvm"
"benchmark"
];
sshUser = "builder";
sshKey = "/etc/ssh/ssh_host_ed25519_key";
publicHostKey = config.local.keys.gerg-desktop_fingerprint;
}
];
};
programs.ssh.knownHosts.gerg-desktop = {
extraHostNames = [ "gerg-desktop.lan" ];
publicKey = config.local.keys.root_gerg-desktop;
};
})
];
}

43
nixosModules/hardware.nix Normal file
View file

@ -0,0 +1,43 @@
{ config, lib }:
let
cfg = config.local.hardware;
in
{
options.local.hardware = {
gpuAcceleration.disable = lib.mkEnableOption "";
sound.disable = lib.mkEnableOption "";
};
config = lib.mkMerge [
(lib.mkIf (!cfg.gpuAcceleration.disable) {
hardware.graphics = {
enable = true;
enable32Bit = true;
};
})
(lib.mkIf (!cfg.sound.disable) {
security.rtkit.enable = true;
services = {
pulseaudio.enable = lib.mkForce false; # disable pulseAudio
pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = false;
};
};
})
{
hardware = {
enableRedistributableFirmware = true;
cpu = {
intel.updateMicrocode = true;
amd.updateMicrocode = true;
};
};
}
];
}

13
nixosModules/keys.nix Normal file
View file

@ -0,0 +1,13 @@
{ lib }:
{
options.local.keys = lib.mkOption { };
config.local.keys = {
gerg_gerg-phone = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILZKIp3iObuxEUPx1dsMiN3vyMaMQb0N1gKJY78TtRxd";
gerg_gerg-windows = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILpYY2uw0OH1Re+3BkYFlxn0O/D8ryqByJB/ljefooNc";
root_media-laptop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIq9YTf4jlVCKBKn44m4yJvj94C7pTOyaa4VjZFohNqD";
root_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIeHsGcmOdIMzV+SNe4WFcA3CPHCNb1aqxThkXtm7G/1";
gerg-desktop_fingerprint = "BQxvBOWsTw1gdNDR0KzrSRmbVhDrJdG05vYXkVmw8yA";
gerg_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJWbwkFJmRBgyWyWU+w3ksZ+KuFw9uXJN3PwqqE7Z/i8";
};
}

87
nixosModules/misc.nix Normal file
View file

@ -0,0 +1,87 @@
{
lib,
config,
pkgs,
nix-janitor,
}:
{
options.local.allowedUnfree = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
config = {
nixpkgs.config = {
allowAliases = false;
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.local.allowedUnfree;
};
local.packages = {
inherit (pkgs)
bottom # view tasks
efibootmgr # efi editor
nix-output-monitor # nom nom nom nom;
nix-tree # view packages
pciutils # lspci
nixos-rebuild-ng
;
nix-janitor = pkgs.symlinkJoin {
name = "nix-janitor";
paths = [ nix-janitor.packages.default ];
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
postBuild = ''
wrapProgram "$out/bin/janitor" \
--suffix PATH : ${lib.makeBinPath [ config.nix.package ]}
'';
};
};
programs.git.enable = true;
# Mr sandro why
services.libinput.enable = true;
programs.nano.enable = false;
environment.defaultPackages = lib.mkForce [ ];
#enable ssh
programs.mtr.enable = true; # ping and traceroute
services.openssh = {
enable = true;
hostKeys = lib.mkForce [
{
path = "/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
];
settings = {
PermitRootLogin = lib.mkDefault "no";
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
};
programs.ssh = {
startAgent = true;
agentTimeout = "1m";
extraConfig = ''
AddKeysToAgent yes
'';
};
i18n.defaultLocale = "en_US.UTF-8";
#time settings
time.timeZone = "America/New_York";
# For `info` command.
documentation.info.enable = false;
# NixOS manual and such.
documentation.nixos.enable = false;
# Useless with flakes (without configuring)
programs.command-not-found.enable = false;
system.switch.enableNg = true;
};
}

66
nixosModules/nix.nix Normal file
View file

@ -0,0 +1,66 @@
{
nix,
inputs,
lib,
config,
}:
{
nix = {
#
# Disable usage of channels
#
channel.enable = false;
#
# Flake registry and $NIX_PATH pinning
#
registry = lib.pipe inputs [
(lib.filterAttrs (_: lib.isType "flake"))
(lib.mapAttrs (_: flake: { inherit flake; }))
(x: x // { nixpkgs.flake = inputs.unstable; })
];
nixPath = [ "/etc/nix/path" ];
#
# Ignore global registry
#
settings.flake-registry = "";
#
# Use nix directly from master
#
package = nix.packages.default;
#
# Other nix settings
#
settings = {
experimental-features = [
"auto-allocate-uids"
"ca-derivations"
"cgroups"
"daemon-trust-override"
"dynamic-derivations"
"fetch-closure"
"flakes"
"nix-command"
"no-url-literals"
"parse-toml-timestamps"
"read-only-local-store"
"recursive-nix"
"configurable-impure-env"
];
auto-optimise-store = true;
warn-dirty = false;
#
# Use for testing
#
#allow-import-from-derivation = false;
trusted-users = [ "root" ];
allowed-users = [ "@wheel" ];
use-xdg-base-directories = true;
auto-allocate-uids = true;
};
};
environment.etc = lib.mapAttrs' (name: value: {
name = "nix/path/${name}";
value.source = value.flake;
}) config.nix.registry;
}

View file

@ -0,0 +1,8 @@
{ lib, config }:
{
options.local.packages = lib.mkOption {
type = lib.types.attrsOf lib.types.package;
default = { };
};
config.environment.systemPackages = builtins.attrValues config.local.packages;
}

23
nixosModules/page.nix Normal file
View file

@ -0,0 +1,23 @@
{ pkgs, config }:
{
systemd.tmpfiles.rules = [ "d /tmp/neovim-page 0777 root root - -" ];
environment = {
systemPackages = [ pkgs.page ];
variables = {
PAGER = "page -WC -q 90000 -z 90000";
SYSTEMD_PAGERSECURE = "true";
MANPAGER = "page -t man";
};
shellAliases.page = config.environment.variables.PAGER;
};
programs.zsh.interactiveShellInit = ''
man () {
PROGRAM="''${@[-1]}"
SECTION="''${@[-2]}"
page -W "man://$PROGRAM''${SECTION:+($SECTION)}"
}
'';
}

22
nixosModules/security.nix Normal file
View file

@ -0,0 +1,22 @@
{
environment.shellAliases = {
sudo = "sudo ";
#make run0 use aliases
run0 = "run0 --background='' ";
s = "run0";
};
security = {
sudo = {
execWheelOnly = true;
extraConfig = ''
Defaults timestamp_timeout=1
Defaults env_keep += "EDITOR VISUAL PAGER SYSTEMD_PAGERSECURE MANPAGER"
Defaults lecture = never
'';
};
pam.services.systemd-run0 = {
setEnvironment = true;
pamMount = false;
};
};
}

91
nixosModules/shell.nix Normal file
View file

@ -0,0 +1,91 @@
{
fetch-rs,
pkgs,
}:
{
local.packages = {
inherit (pkgs) eza fzf;
inherit (fetch-rs.packages) fetch-rs;
};
environment = {
variables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
shellAliases = {
#paste link trick
pastebin = "curl -F 'clbin=<-' https://clbin.com";
termbin = "nc termbin.com 9999";
#nix stuff
gc-check = ''nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/w+-system|{memory|/proc)"'';
#vim stuff
vi = "nvim";
vim = "nvim";
vimdiff = "nvim -d";
#eza is 1 too many letters
ls = "eza";
l = "eza -lbF --git";
ll = "eza -lbGF --git";
llm = "eza -lbGd --git --sort=modified";
la = "eza -lbhHigUmuSa --time-style=long-iso --git --color-scale";
lx = "eza -lbhHigUmuSa@ --time-style=long-iso --git --color-scale";
lS = "eza -1";
lt = "eza --tree --level=2";
};
interactiveShellInit = "fetch-rs";
};
programs.starship = {
enable = true;
settings = {
add_newline = false;
format = ''
$cmd_duration$git_metrics$git_state$git_branch
$status$directory$character'';
right_format = "$sudo$nix_shell\${custom.direnv} $time";
continuation_prompt = " ";
character = {
success_symbol = "[\\$](#9ece6a bold)";
error_symbol = "[\\$](#db4b4b bold)";
};
status = {
disabled = false;
format = "[$status]($style) ";
};
nix_shell = {
format = "[󱄅 ](#74b2ff)";
heuristic = true;
};
directory = {
read_only = " ";
};
git_metrics = {
disabled = false;
};
git_branch = {
format = "[$symbol$branch(:$remote_branch)]($style)";
style = "bold red";
};
cmd_duration = {
min_time = 5000;
style = "bold #9ece6a";
};
custom.direnv = {
format = "[\\[direnv\\]]($style)";
style = "#36c692";
when = "printenv DIRENV_FILE";
};
time = {
format = ''
[$time]($style)
'';
time_format = "%I:%M %p";
disabled = false;
};
sudo = {
format = "[ ](#7aa2f7)";
disabled = false;
};
};
};
}

16
nixosModules/sops.nix Normal file
View file

@ -0,0 +1,16 @@
{
config,
lib,
sops-nix,
self',
}:
{
imports = [ sops-nix.nixosModules.sops ];
options.local.sops.disable = lib.mkEnableOption "";
config = lib.mkIf (!config.local.sops.disable) {
sops = {
defaultSopsFile = "${self'}/nixosConfigurations/${config.networking.hostName}/secrets.yaml";
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
};
};
}

105
nixosModules/theming.nix Normal file
View file

@ -0,0 +1,105 @@
{
pkgs,
config,
lib,
}:
let
cfg = config.local.theming;
in
{
options.local.theming = {
enable = lib.mkEnableOption "";
kmscon.enable = lib.mkEnableOption "";
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
environment = {
systemPackages = [
pkgs.flat-remix-gtk
pkgs.flat-remix-icon-theme
pkgs.quintom-cursor-theme
];
etc = {
"xdg/gtk-4.0/settings.ini".text = ''
[Settings]
gtk-cursor-theme-name=Quintom_Ink
gtk-cursor-theme-size=16
gtk-font-name=Overpass 10
gtk-icon-theme-name=Flat-Remix-Blue-Dark
gtk-theme-name=Flat-Remix-GTK-Blue-Darkest
'';
"xdg/gtk-3.0/settings.ini".text = ''
[Settings]
gtk-cursor-theme-name=Quintom_Ink
gtk-cursor-theme-size=16
gtk-font-name=Overpass 10
gtk-icon-theme-name=Flat-Remix-Blue-Dark
gtk-theme-name=Flat-Remix-GTK-Blue-Darkest
'';
"xdg/gtk-2.0/gtkrc".text = ''
gtk-cursor-theme-name = "Quintom_Ink"
gtk-cursor-theme-size = 16
gtk-font-name = "Overpass 10"
gtk-icon-theme-name = "Flat-Remix-Blue-Dark"
gtk-theme-name = "Flat-Remix-GTK-Blue-Darkest"
'';
"xdg/Xresources".text = ''
Xcursor.size: 16
Xcursor.theme: Quintom_Ink
'';
};
};
qt = {
enable = true;
style = "gtk2";
platformTheme = "gtk2";
};
services.xserver.displayManager.sessionCommands = ''
${lib.getExe pkgs.xorg.xrdb} -load /etc/xdg/Xresources
'';
programs.dconf.profiles.user.databases = [
{
lockAll = false;
settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
}
];
fonts = {
packages = [
pkgs.overpass
pkgs.nerd-fonts.symbols-only
];
enableDefaultPackages = false;
fontDir.enable = true;
fontconfig = {
enable = true;
defaultFonts = {
serif = [ "Overpass" ];
sansSerif = [ "Overpass" ];
monospace = [ "Overpass Mono" ];
};
hinting.enable = true;
antialias = true;
};
};
})
(lib.mkIf cfg.kmscon.enable {
services.kmscon = {
enable = true;
hwRender = false;
extraConfig = ''
font-size=10
'';
fonts = [
{
name = "OverpassMono";
package = pkgs.overpass;
}
];
};
systemd.services = {
"autovt@tty1".enable = false;
"kmsconvt@tty1".enable = false;
};
})
];
}

53
nixosModules/zsh.nix Normal file
View file

@ -0,0 +1,53 @@
{ pkgs }:
{
users.defaultUserShell = pkgs.zsh;
programs = {
zsh = {
enable = true;
autosuggestions.enable = true;
syntaxHighlighting.enable = true;
histSize = 20000;
histFile = "$HOME/.cache/zsh_history";
interactiveShellInit = ''
### zsh-history-substring-search ###
setopt HIST_IGNORE_ALL_DUPS
source ${pkgs.zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
### fzf-tab ###
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
### transient shell prompt ###
zle-line-init() {
emulate -L zsh
[[ $CONTEXT == start ]] || return 0
while true; do
zle .recursive-edit
local -i ret=$?
[[ $ret == 0 && $KEYS == $'\4' ]] || break
[[ -o ignore_eof ]] || exit 0
done
local saved_prompt=$PROMPT
local saved_rprompt=$RPROMPT
PROMPT='\$ '
RPROMPT='''
zle .reset-prompt
PROMPT=$saved_prompt
RPROMPT=$saved_rprompt
if (( ret )); then
zle .send-break
else
zle .accept-line
fi
return ret
}
zle -N zle-line-init
'';
};
};
}