1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-08-01 12:37:46 +00:00

Compare commits

...

4 commits

2 changed files with 34 additions and 31 deletions

View file

@ -3,6 +3,9 @@ use std null_device
source ~/.config/nushell/zoxide.nu
$env.CARAPACE_BRIDGES = "inshellisense,carapace,zsh,fish,bash"
source ~/.config/nushell/carapace.nu
# Retrieve the output of the last command.
def _ []: nothing -> any {
$env.last?
@ -54,29 +57,6 @@ $env.config.completions.case_sensitive = false
$env.config.completions.quick = true
$env.config.completions.partial = true
$env.config.completions.use_ls_colors = true
$env.config.completions.external.enable = true
$env.config.completions.external.max_results = 100
$env.config.completions.external.completer = {|tokens: list<string>|
let expanded = scope aliases
| where name == $tokens.0
| get --ignore-errors 0.expansion
mut tokens = if $expanded != null and $tokens.0 != "cd" {
$expanded | split row " " | append ($tokens | skip 1)
} else {
$tokens
}
$tokens.0 = $tokens.0 | str trim --left --char "^"
let command = $tokens
| str join " "
| str replace --all (char single_quote) $"\\(char single_quote)"
fish --command $"complete '--do-complete=($command)'"
| $"value(char tab)description(char newline)" + $in
| from tsv --flexible --no-infer
}
$env.config.use_kitty_protocol = true
@ -199,19 +179,33 @@ do --env {
def prompt-header [
--left-char: string
]: nothing -> string {
let code = $env.LAST_EXIT_CODE
let jj_workspace_root = try {
jj workspace root err> $null_device
} catch {
""
}
let hostname = if ($env.SSH_CONNECTION? | is-not-empty) {
let hostname = try {
hostname
} catch {
"remote"
}
$"(ansi light_green_bold)@($hostname)(ansi reset) "
} else {
""
}
let body = if ($jj_workspace_root | is-not-empty) {
let subpath = pwd | path relative-to $jj_workspace_root
let subpath = if ($subpath | is-not-empty) {
$"(ansi magenta_bold) → (ansi reset)(ansi blue)($subpath)"
}
$"(ansi light_yellow_bold)($jj_workspace_root | path basename)($subpath)(ansi reset)"
$"($hostname)(ansi light_yellow_bold)($jj_workspace_root | path basename)($subpath)(ansi reset)"
} else {
let pwd = if (pwd | str starts-with $env.HOME) {
"~" | path join (pwd | path relative-to $env.HOME)
@ -219,7 +213,7 @@ do --env {
pwd
}
$"(ansi cyan)($pwd)(ansi reset)"
$"($hostname)(ansi cyan)($pwd)(ansi reset)"
}
let command_duration = ($env.CMD_DURATION_MS | into int) * 1ms
@ -229,10 +223,10 @@ do --env {
$"┫(ansi light_magenta_bold)($command_duration)(ansi light_yellow_bold)┣━"
}
let exit_code = if $env.LAST_EXIT_CODE == 0 {
let exit_code = if $code == 0 {
""
} else {
$"┫(ansi light_red_bold)($env.LAST_EXIT_CODE)(ansi light_yellow_bold)┣━"
$"┫(ansi light_red_bold)($code)(ansi light_yellow_bold)┣━"
}
let middle = if $command_duration == "" and $exit_code == "" {
@ -303,6 +297,7 @@ let menus = [
layout: ide
border: false
correct_cursor_pos: true
max_completion_height: 25
}
style: {
text: white

View file

@ -1,5 +1,5 @@
{ config, lib, pkgs, ... }: let
inherit (lib) attrValues const disabled enabled getExe mapAttrs mkIf optionalAttrs readFile removeAttrs replaceString;
inherit (lib) attrValues const enabled getExe mapAttrs mkIf optionalAttrs readFile removeAttrs replaceString;
in {
environment = optionalAttrs config.isLinux {
sessionVariables.SHELLS = getExe pkgs.nushell;
@ -8,6 +8,7 @@ in {
shellAliases = {
la = "ls --all";
ll = "ls --long";
lla = "ls --long --all";
sl = "ls";
@ -22,8 +23,12 @@ in {
systemPackages = attrValues {
inherit (pkgs)
fish # For completions.
zoxide # For completions and better cd.
carapace # For completions.
fish # For completions.
zsh # For completions.
inshellisense # For completions.
zoxide # For better cd.
;
};
};
@ -32,6 +37,10 @@ in {
homeConfig = homeArgs.config;
in {
xdg.configFile = {
"nushell/carapace.nu".source = pkgs.runCommand "carapace.nu" {} ''
${getExe pkgs.carapace} _carapace nushell > $out
'';
"nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} ''
${getExe pkgs.zoxide} init nushell --cmd cd > $out
'';
@ -74,7 +83,6 @@ in {
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
cdtmp = "cd (mktemp --directory)";
ll = "ls --long";
};
};
})];