mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2024-11-05 15:16:23 +01:00
do flag thing help
This commit is contained in:
parent
3d2719f2f7
commit
62539db84d
|
@ -12,6 +12,10 @@
|
||||||
home.packages = [
|
home.packages = [
|
||||||
pkgs.pueue
|
pkgs.pueue
|
||||||
];
|
];
|
||||||
|
home.file."shell-startup" = {
|
||||||
|
source = ../../other/scripts/desktop/shell-startup.nu;
|
||||||
|
target = ".config/nushell/shell-startup.nu";
|
||||||
|
};
|
||||||
programs.nushell = {
|
programs.nushell = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = config.users.defaultUserShell;
|
package = config.users.defaultUserShell;
|
||||||
|
@ -28,8 +32,10 @@
|
||||||
|
|
||||||
nu ${../../other/scripts/desktop/shell-startup.nu};
|
nu ${../../other/scripts/desktop/shell-startup.nu};
|
||||||
'';
|
'';
|
||||||
|
extraEnv = ''
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
programs.starship.enableNushellIntegration = true;
|
# programs.starship.enableNushellIntegration = true;
|
||||||
programs.carapace.enableNushellIntegration = true;
|
programs.carapace.enableNushellIntegration = true;
|
||||||
programs.direnv.enableNushellIntegration = true;
|
programs.direnv.enableNushellIntegration = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
home-manager.users.jade = {pkgs, ...}: {
|
home-manager.users.jade = {pkgs, ...}: {
|
||||||
programs.starship = {
|
programs.starship = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
enableNushellIntegration = false;
|
||||||
settings = {
|
settings = {
|
||||||
format = "$all$directory$character";
|
format = "$all$directory$character";
|
||||||
character = {
|
character = {
|
||||||
|
|
|
@ -272,7 +272,8 @@ $env.config = {
|
||||||
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
||||||
|
|
||||||
hooks: {
|
hooks: {
|
||||||
pre_execution: [{ null }] # run before the repl input is run
|
pre_prompt: { null }
|
||||||
|
pre_execution: [{ $env.CMD_COUNT = $env.CMD_COUNT + 1; }] # run before the repl input is run
|
||||||
env_change: {
|
env_change: {
|
||||||
PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input
|
PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input
|
||||||
}
|
}
|
||||||
|
|
54
other/env.nu
54
other/env.nu
|
@ -2,36 +2,18 @@
|
||||||
#
|
#
|
||||||
# version = "0.84.0"
|
# version = "0.84.0"
|
||||||
|
|
||||||
def create_left_prompt [] {
|
source /home/jade/.config/nushell/shell-startup.nu;
|
||||||
mut home = ""
|
$env.STARSHIP_SHELL = "nu";
|
||||||
try {
|
$env.CMD_COUNT = 0;
|
||||||
if $nu.os-info.name == "windows" {
|
|
||||||
$home = $env.USERPROFILE
|
|
||||||
} else {
|
|
||||||
$home = $env.HOME
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let dir = ([
|
|
||||||
($env.PWD | str substring 0..($home | str length) | str replace $home "~"),
|
|
||||||
($env.PWD | str substring ($home | str length)..)
|
|
||||||
] | str join)
|
|
||||||
|
|
||||||
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
|
|
||||||
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
|
|
||||||
let path_segment = $"($path_color)($dir)"
|
|
||||||
|
|
||||||
$path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)"
|
|
||||||
}
|
|
||||||
|
|
||||||
def create_right_prompt [] {
|
def create_right_prompt [] {
|
||||||
# create a right prompt in magenta with green separators and am/pm underlined
|
# create a right prompt in magenta with green separators and am/pm underlined
|
||||||
|
|
||||||
let time_segment = ([
|
let time_segment = ([
|
||||||
(ansi reset)
|
(ansi reset)
|
||||||
(ansi magenta)
|
(ansi purple)
|
||||||
(date now | format date '%Y/%m/%d %r')
|
(date now | format date '%Y/%m/%d %R')
|
||||||
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
|
]) | str join;
|
||||||
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
|
|
||||||
|
|
||||||
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
|
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
|
||||||
(ansi rb)
|
(ansi rb)
|
||||||
|
@ -43,8 +25,26 @@ def create_right_prompt [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use nushell functions to define your right and left prompt
|
# Use nushell functions to define your right and left prompt
|
||||||
$env.PROMPT_COMMAND = {|| create_left_prompt }
|
$env.PROMPT_COMMAND = {||
|
||||||
# $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
|
starship prompt --cmd-duration $env.CMD_DURATION_MS $'--status=($env.LAST_EXIT_CODE)'
|
||||||
|
| lines
|
||||||
|
| filter { is-not-empty }
|
||||||
|
| update 0 {|item|
|
||||||
|
let len = (term size | get columns) - ($item | ansi strip | str length --grapheme-clusters) - (create_right_prompt | ansi strip | str length --grapheme-clusters);
|
||||||
|
# $item | append (flag $TRANS "-" $len) | str join
|
||||||
|
let deco = if ($env.CMD_COUNT == 0) {
|
||||||
|
flag $LESBIAN "=" $len
|
||||||
|
} else if ($env.CMD_COUNT | is even) {
|
||||||
|
flag $LESBIAN "-" $len
|
||||||
|
} else {
|
||||||
|
flag $TRANS "-" $len
|
||||||
|
};
|
||||||
|
|
||||||
|
$item | append $deco | str join
|
||||||
|
}
|
||||||
|
| str join "\n"
|
||||||
|
}
|
||||||
|
$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
|
||||||
|
|
||||||
# The prompt indicators are environmental variables that represent
|
# The prompt indicators are environmental variables that represent
|
||||||
# the state of the prompt
|
# the state of the prompt
|
||||||
|
|
|
@ -10,11 +10,17 @@ const ENBY = [ FCF434 FFFFFF 9C59D1 2C2C2C ];
|
||||||
|
|
||||||
def flag [
|
def flag [
|
||||||
colors: list<string>
|
colors: list<string>
|
||||||
|
character = "="
|
||||||
|
width = -1,
|
||||||
] {
|
] {
|
||||||
use std;
|
use std;
|
||||||
|
|
||||||
let col_size = (term size | get columns) / ($colors | length) | math floor;
|
let out_size = if ($width == -1) {
|
||||||
mut rest = (term size | get columns) - ($col_size * ($colors | length));
|
term size | get columns
|
||||||
|
} else { $width };
|
||||||
|
|
||||||
|
let col_size = $out_size / ($colors | length) | math floor;
|
||||||
|
mut rest = $out_size - ($col_size * ($colors | length));
|
||||||
|
|
||||||
mut cols = $colors | wrap color | insert width $col_size | flatten;
|
mut cols = $colors | wrap color | insert width $col_size | flatten;
|
||||||
let last = ($colors | length) - 1;
|
let last = ($colors | length) - 1;
|
||||||
|
@ -35,14 +41,14 @@ def flag [
|
||||||
|
|
||||||
$cols = ($cols | update 0 { $in | update width {|w| ($w.width + $amount) } } | update $last { $in | update width {|w| ($w.width + $amount) } });
|
$cols = ($cols | update 0 { $in | update width {|w| ($w.width + $amount) } } | update $last { $in | update width {|w| ($w.width + $amount) } });
|
||||||
|
|
||||||
print ($cols | each {|col|
|
$cols | each {|col|
|
||||||
"=" | std repeat $col.width | prepend (ansi {fg: $"#($col.color)" }) | str join
|
$character | std repeat $col.width | prepend (ansi {fg: $"#($col.color)" }) | str join
|
||||||
} | prepend (ansi attr_bold) | append (ansi reset) | str join)
|
} | prepend (ansi attr_bold) | append (ansi reset) | str join
|
||||||
}
|
}
|
||||||
|
|
||||||
def main [] {
|
def main [] {
|
||||||
flag $TRANS;
|
print (flag $TRANS);
|
||||||
print $"(ansi attr_bold) Hi jade, you're on HRT for ((date now) - ('2024-02-18T20:53' | into datetime) | format duration month)s now!";
|
print $"(ansi attr_bold) Hi jade, you're on HRT for ((date now) - ('2024-02-18T20:53' | into datetime) | format duration month)s now!";
|
||||||
flag $LESBIAN;
|
# print (flag $LESBIAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ pub fn list_entries(path: PathBuf) -> io::Result<()> {
|
||||||
|
|
||||||
println!("{}{r}{padding}{}", n.cyan(), l.white())
|
println!("{}{r}{padding}{}", n.cyan(), l.white())
|
||||||
}
|
}
|
||||||
|
println!("d");
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Parsing error...");
|
eprintln!("Parsing error...");
|
||||||
|
|
Loading…
Reference in a new issue