cleanup, modularise

This commit is contained in:
unexplrd
2025-02-06 21:56:18 +02:00
parent 2b6ff9f8e8
commit c7576dc1ee
98 changed files with 2 additions and 10091 deletions

View File

@ -0,0 +1,3 @@
{
imports = [./nushell.nix ./oh-my-posh.nix];
}

View File

@ -0,0 +1,100 @@
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.shell.nushell;
in {
options = {
shell.nushell.enable =
mkEnableOption "enable nushell";
};
config = mkIf cfg.enable {
programs.oh-my-posh.enableNushellIntegration = true;
programs.zoxide = {
enable = true;
enableNushellIntegration = true;
};
programs.carapace = {
enable = true;
enableNushellIntegration = true;
};
programs.atuin = {
enable = true;
enableNushellIntegration = true;
flags = [
"--disable-up-arrow"
];
};
programs.nushell = {
enable = true;
environmentVariables = {
CARAPACE_BRIDGES = "zsh,fish,bash,inshellisense";
CARAPACE_MATCH = 1;
EDITOR = "hx";
};
shellAliases = {
cd = "z";
cat = "bat";
l = "ls -l";
nix-shell = "nix-shell --command nu";
};
extraConfig = ''
$env.config = {
show_banner: false
shell_integration: {
# osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title
osc2: true
# osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory
osc7: true
# osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it. show_clickable_links is deprecated in favor of osc8
osc8: true
# osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal
osc9_9: false
# osc133 is several escapes invented by Final Term which include the supported ones below.
# 133;A - Mark prompt start
# 133;B - Mark prompt end
# 133;C - Mark pre-execution
# 133;D;exit - Mark execution finished with exit code
# This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is
osc133: true
# osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features
# 633;A - Mark prompt start
# 633;B - Mark prompt end
# 633;C - Mark pre-execution
# 633;D;exit - Mark execution finished with exit code
# 633;E - Explicitly set the command line with an optional nonce
# 633;P;Cwd=<path> - Mark the current working directory and communicate it to the terminal
# and also helps with the run recent menu in vscode
osc633: true
# reset_application_mode is escape \x1b[?1l and was added to help ssh work better
reset_application_mode: true
}
ls: {
use_ls_colors: true
clickable_links: true
}
rm: {
always_trash: true
}
edit_mode: 'vi'
completions: {
case_sensitive: false
quick: true
partial: true
algorithm: "fuzzy"
external: {
enable: true
# max_results: 100
# completer: $carapace_completer # check 'carapace_completer'
}
}
}
'';
};
};
}

View File

@ -0,0 +1,106 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.shell.oh-my-posh;
in {
options = {
shell.oh-my-posh.enable =
mkEnableOption "enable oh my posh";
};
config = mkIf cfg.enable {
programs.oh-my-posh = {
enable = true;
settings = {
version = 2;
final_space = true;
console_title_template = "{{ .Shell }} in {{ .Folder }}";
blocks = [
{
type = "prompt";
alignment = "left";
newline = true;
segments = [
{
type = "path";
style = "plain";
background = "transparent";
foreground = "blue";
template = "{{ .Path }}";
properties = {
style = "full";
};
}
{
type = "text";
style = "plain";
background = "transparent";
template = "{{ if .Env.BW_SESSION }} 󰞀{{ end }}";
}
{
type = "nix-shell";
style = "plain";
background = "transparent";
template = "{{ if ne .Type \"unknown\" }} {{ end }}";
}
{
type = "git";
style = "plain";
foreground = "p:grey";
background = "transparent";
template = " {{ .HEAD }}{{ if or (.Working.Changed) (.Staging.Changed) }}*{{ end }} <cyan>{{ if gt .Behind 0 }}{{ end }}{{ if gt .Ahead 0 }}{{ end }}</>";
properties = {
branch_icon = "";
commit_icon = "@";
fetch_status = true;
};
}
];
}
{
type = "rprompt";
overflow = "hidden";
segments = [
{
type = "executiontime";
style = "plain";
foreground = "yellow";
background = "transparent";
template = "{{ .FormattedMs }}";
properties = {
threshold = 5000;
};
}
];
}
{
type = "prompt";
alignment = "left";
newline = true;
segments = [
{
type = "text";
style = "plain";
foreground_templates = ["{{if gt .Code 0}}red{{end}}" "{{if eq .Code 0}}magenta{{end}}"];
background = "transparent";
template = "";
}
];
}
];
transient_prompt = {
foreground_templates = ["{{if gt .Code 0}}red{{end}}" "{{if eq .Code 0}}magenta{{end}}"];
background = "transparent";
template = " ";
};
secondary_prompt = {
foreground = "magenta";
background = "transparent";
template = " ";
};
};
};
};
}

View File

@ -0,0 +1,75 @@
{
pkgs,
config,
lib,
...
}: {
options = {
zsh.enable =
lib.mkEnableOption "enable z shell";
};
config = lib.mkIf config.zsh.enable {
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
initExtra = ''
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
'';
# promptInit = "oh-my-posh init zsh -c ~/.config/oh-my-posh/zen.toml";
enableCompletion = true;
autosuggestion.enable = true;
#autosuggestion.highlight = "fg=#ff00ff,bg=cyan,bold,underline";
shellAliases = {
ls = "eza";
cat = "bat";
cd = "z";
l = "eza -alh";
};
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
plugins = [
{
name = "zsh-autosuggestions";
file = "zsh-autosuggestions.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-autocomplete";
rev = "v0.7.0";
sha256 = "sha256-/6V6IHwB5p0GT1u5SAiUa20LjFDSrMo731jFBq/bnpw=";
};
}
{
name = "zsh-syntax-highlighting";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
rev = "0.8.0";
sha256 = "sha256-iJdWopZwHpSyYl5/FQXEW7gl/SrKaYDEtTH9cGP7iPo=";
};
}
{
name = "zsh-history-substring-search";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-history-substring-search";
rev = "v1.1.0";
sha256 = "sha256-GSEvgvgWi1rrsgikTzDXokHTROoyPRlU0FVpAoEmXG4=";
};
}
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsin.fromh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.8.0";
sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7";
};
}
];
};
};
}