config dump

This commit is contained in:
Bloxx12 2025-07-17 00:55:24 +02:00
commit cf8afe544a
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
6 changed files with 355 additions and 357 deletions

View file

@ -1,4 +1,3 @@
# =============================================================================
$env.ATUIN_SESSION = (atuin uuid) $env.ATUIN_SESSION = (atuin uuid)
hide-env -i ATUIN_HISTORY_ID hide-env -i ATUIN_HISTORY_ID
@ -17,7 +16,6 @@ let _atuin_pre_execution = {||
$env.ATUIN_HISTORY_ID = (atuin history start -- $cmd) $env.ATUIN_HISTORY_ID = (atuin history start -- $cmd)
} }
} }
# =============================================================================
let _atuin_pre_prompt = {|| let _atuin_pre_prompt = {||
let last_exit = $env.LAST_EXIT_CODE let last_exit = $env.LAST_EXIT_CODE
@ -26,11 +24,9 @@ let _atuin_pre_prompt = {||
} }
with-env {ATUIN_LOG: error} { with-env {ATUIN_LOG: error} {
do { atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID } | complete do { atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID } | complete
} }
hide-env ATUIN_HISTORY_ID hide-env ATUIN_HISTORY_ID
} }
# =============================================================================
def _atuin_search_cmd [...flags: string] { def _atuin_search_cmd [...flags: string] {
let nu_version = do { let nu_version = do {
@ -45,18 +41,19 @@ def _atuin_search_cmd [...flags: string] {
} }
} }
[ [
$ATUIN_KEYBINDING_TOKEN, $ATUIN_KEYBINDING_TOKEN
([ (
`with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`, [
(if $nu_version.0 <= 0 and $nu_version.1 <= 90 { 'commandline' } else { 'commandline edit' }), `with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`
(if $nu_version.1 >= 92 { '(run-external atuin search' } else { '(run-external --redirect-stderr atuin search' }), (if $nu_version.0 <= 0 and $nu_version.1 <= 90 { 'commandline' } else { 'commandline edit' })
($flags | append [--interactive] | each {|e| $'"($e)"'}), (if $nu_version.1 >= 92 { '(run-external atuin search' } else { '(run-external --redirect-stderr atuin search' })
(if $nu_version.1 >= 92 { ' e>| str trim)' } else {' | complete | $in.stderr | str substring ..-1)'}), ($flags | append [--interactive] | each {|e| $'"($e)"' })
`}`, (if $nu_version.1 >= 92 { ' e>| str trim)' } else { ' | complete | $in.stderr | str substring ..-1)' })
] | flatten | str join ' '), `}`
] | flatten | str join ' '
)
] | str join "\n" ] | str join "\n"
} }
# =============================================================================
$env.config = ($env | default {} config).config $env.config = ($env | default {} config).config
$env.config = ($env.config | default {} hooks) $env.config = ($env.config | default {} hooks)
@ -64,9 +61,11 @@ $env.config = (
$env.config | upsert hooks ( $env.config | upsert hooks (
$env.config.hooks $env.config.hooks
| upsert pre_execution ( | upsert pre_execution (
$env.config.hooks | get -i pre_execution | default [] | append $_atuin_pre_execution) $env.config.hooks | get -i pre_execution | default [] | append $_atuin_pre_execution
)
| upsert pre_prompt ( | upsert pre_prompt (
$env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt) $env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt
)
) )
) )
@ -79,7 +78,7 @@ $env.config = (
name: atuin name: atuin
modifier: control modifier: control
keycode: char_r keycode: char_r
mode: [emacs, vi_normal, vi_insert] mode: [emacs vi_normal vi_insert]
event: {send: executehostcommand cmd: (_atuin_search_cmd)} event: {send: executehostcommand cmd: (_atuin_search_cmd)}
} }
) )
@ -92,7 +91,7 @@ $env.config = (
name: atuin name: atuin
modifier: none modifier: none
keycode: up keycode: up
mode: [emacs, vi_normal, vi_insert] mode: [emacs vi_normal vi_insert]
event: { event: {
until: [ until: [
{send: menuup} {send: menuup}
@ -102,4 +101,3 @@ $env.config = (
} }
) )
) )
# =============================================================================

View file

@ -1,14 +1,10 @@
$env.config.completions = { $env.PATH = ($env.PATH | split row (char esep) | prepend "/home/cr/.config/carapace/bin")
algorithm: prefix
sort: smart def --env get-env [name] { $env | get $name }
case_sensitive: false def --env set-env [name, value] { load-env { $name: $value } }
quick: true def --env unset-env [name] { hide-env $name }
partial: true
use_ls_colors: true let carapace_completer = {|spans|
external: {
enable: true
max_results: 10
completer: {|spans: list<string>|
# if the current command is an alias, get it's expansion # if the current command is an alias, get it's expansion
let expanded_alias = (scope aliases | where name == $spans.0 | get -i 0 | get -i expansion) let expanded_alias = (scope aliases | where name == $spans.0 | get -i 0 | get -i expansion)
@ -23,24 +19,12 @@ $env.config.completions = {
carapace $spans.0 nushell ...$spans carapace $spans.0 nushell ...$spans
| from json | from json
} }
}
} mut current = (($env | default {} config).config | default {} completions)
$env.config.menus ++= [ $current.completions = ($current.completions | default {} external)
{ $current.completions.external = ($current.completions.external
marker: $"(ansi yellow)┣ " | default true enable
name: completion_menu | default { $carapace_completer } completer)
only_buffer_difference: false
style: { $env.config = $current
description_text: yellow
selected_text: red_reverse
text: yellow
}
type: {
col_padding: 2
col_width: 20
columns: 1
layout: columnar
}
}
]

View file

@ -86,7 +86,6 @@ $env.config.hooks = {
} }
] ]
pre_prompt: [ pre_prompt: [
{ {
if (which direnv | is-empty) { if (which direnv | is-empty) {
@ -134,19 +133,6 @@ $env.config.keybindings = [
cmd: 'commandline | nu-highlight | $"```ansi\n($in)\n```" | wl-copy $in' cmd: 'commandline | nu-highlight | $"```ansi\n($in)\n```" | wl-copy $in'
} }
} }
{
name: completion_menu
modifier: none
keycode: tab
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: menu name: completion_menu }
{ send: menunext }
{ edit: complete }
]
}
}
{ {
name: escape name: escape
modifier: none modifier: none
@ -189,7 +175,7 @@ $env.config.keybindings = [
mode: [vi_normal vi_insert] mode: [vi_normal vi_insert]
event: [ event: [
{send: menu name: abbr_menu} {send: menu name: abbr_menu}
{ edit: insertchar, value: " " } {edit: insertchar value: " "}
] ]
} }
{ {
@ -301,17 +287,27 @@ $env.config.keybindings = [
} }
] ]
source ./atuin.nu let autoload_dir = $nu.user-autoload-dirs.0
source ./zoxide.nu mkdir $autoload_dir
zoxide init nushell --cmd cd | save -f ($autoload_dir | path join zoxide.nu)
atuin init nu | save -f ($autoload_dir | path join atuin.nu)
carapace _carapace nushell | save -f ($autoload_dir | path join carapace.nu)
source ./source_profile.nu source ./source_profile.nu
source ./completions.nu
source ./prompt.nu source ./prompt.nu
# fix sudo by prepending /run/wrappers/bin to the PATH. # fix sudo by prepending /run/wrappers/bin to the PATH.
$env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin') $env.PATH = ($env.PATH | split row (char esep) | prepend '/run/wrappers/bin')
$env.LS_COLORS = (vivid generate lava) $env.LS_COLORS = (vivid generate lava)
$env.EDITOR = "hx" $env.EDITOR = "hx"
$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
$env.CARAPACE_BRIDGES = 'carapace,clap,inshellisense,fish'
$env.CARAPACE_MATCH = 1
# Set environment variables according to the path of the clone
$env.TOPIARY_CONFIG_FILE = ($env.HOME | path join .config | path join topiary languages.ncl)
$env.TOPIARY_LANGUAGE_DIR = ($env.HOME | path join .config | path join topiary languages)
# 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.

View file

@ -1,6 +1,7 @@
use std null_device use std null_device
export-env { load-env { export-env {
load-env {
PROMPT_COMMAND: {|| PROMPT_COMMAND: {||
let exit_code = $env.LAST_EXIT_CODE let exit_code = $env.LAST_EXIT_CODE
let jj_root = try { ^jj root err> $null_device } catch { "" } let jj_root = try { ^jj root err> $null_device } catch { "" }
@ -10,7 +11,7 @@ export-env { load-env {
mut path_segment = "" mut path_segment = ""
if not (($vcs_root | is-empty) or ($env.PWD == $vcs_root)) { if not (($vcs_root | is-empty) or ($env.PWD == $vcs_root)) {
# vcs_root is not empty, we're not in the vcs_root of the project # vcs_root is not empty, we're not in the vcs_root of the project
$path_segment = [($vcs_root | path basename), ($env.PWD | path basename)] | str join " @ " $path_segment = [($vcs_root | path basename) ($env.PWD | path basename)] | str join " @ "
} else { } else {
$path_segment = $env.PWD | path basename $path_segment = $env.PWD | path basename
} }
@ -21,8 +22,7 @@ export-env { load-env {
$"(ansi yellow)━┫(ansi red)($exit_code)(ansi yellow)┣━" $"(ansi yellow)━┫(ansi red)($exit_code)(ansi yellow)┣━"
} }
[$"(ansi yellow)┏",$exit_code_segment,"━ ", $path_segment, "\n"] | str join [$"(ansi yellow)┏" $exit_code_segment "━ " $path_segment "\n"] | str join
} }
TRANSIENT_PROMPT_COMMAND: {|| TRANSIENT_PROMPT_COMMAND: {||
let path_segment = $env.PWD | path basename let path_segment = $env.PWD | path basename
@ -33,7 +33,7 @@ export-env { load-env {
$"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━" $"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━"
} }
[$"(ansi yellow)━",$exit_code_segment,"━ ", $path_segment] | str join [$"(ansi yellow)━" $exit_code_segment "━ " $path_segment] | str join
} }
PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ " PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ "
PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ " PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ "
@ -43,9 +43,11 @@ TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " "
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " " TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " "
TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ " TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
config: ($env.config? | default {} | merge { config: (
$env.config? | default {} | merge {
render_right_prompt_on_last_line: true render_right_prompt_on_last_line: true
}) }
)
PROMPT_COMMAND_RIGHT: {|| PROMPT_COMMAND_RIGHT: {||
let jj_status = try { let jj_status = try {
@ -77,4 +79,6 @@ PROMPT_COMMAND_RIGHT: {||
"" ""
} }
$jj_status $jj_status
}}} }
}
}

0
nushell/source_profile.nu Executable file → Normal file
View file

View file

@ -11,50 +11,66 @@ export-env {
$env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } } $env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
) )
if not $__zoxide_hooked { if not $__zoxide_hooked {
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append { $env.config.hooks.env_change.PWD = (
__zoxide_hook: true, $env.config.hooks.env_change.PWD | append {
code: {|_, dir| zoxide add -- $dir} __zoxide_hook: true
}) code: {|_ dir| zoxide add -- $dir }
}
)
} }
} }
module zoxide-commands {
def "nu-complete zoxide path" [context: string] { def "nu-complete zoxide path" [context: string] {
let parts = $context | split row -r "[ /]" | skip 1 let parts = $context | str trim --left | split row " " | skip 1 | each { str downcase }
{ let completions = (
options: {
sort: false,
completion_algorithm: substring,
case_sensitive: false,
},
completions: (
^zoxide query --list --exclude $env.PWD -- ...$parts ^zoxide query --list --exclude $env.PWD -- ...$parts
| lines | lines
| first 10 | each {|dir|
| each {|p| $p | path relative-to $env.PWD | $"($in)/"} if ($parts | length) <= 1 {
$dir
# | each {|p| echo p | path basename} } else {
let dir_lower = $dir | str downcase
let rem_start = $parts | drop 1 | reduce --fold 0 {|part rem_start|
($dir_lower | str index-of --range $rem_start.. $part) + ($part | str length)
}
{
value: ($dir | str substring $rem_start..)
description: $dir
}
}
}
) )
# | each {|p| echo p | path basename | $"($in)/"}), {
options: {
sort: false
completion_algorithm: prefix
positional: false
case_sensitive: false
}
completions: $completions
} }
} }
# Jump to a directory using only keywords. # Jump to a directory using only keywords.
def --env --wrapped __zoxide_z [...rest: string@"nu-complete zoxide path"] { export def --env --wrapped __zoxide_z [...rest: string@"nu-complete zoxide path"] {
let path = match $rest { let path = match $rest {
[] => {'~'}, [] => { '~' }
[ '-' ] => {'-'}, ['-'] => { '-' }
[$arg] if ($arg | path expand | path type) == 'dir' => { $arg } [$arg] if ($arg | path expand | path type) == 'dir' => { $arg }
_ => { _ => {
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n" ^zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
} }
} }
cd $path cd $path
} }
# Jump to a directory using interactive search. # Jump to a directory using interactive search.
def --env --wrapped __zoxide_zi [...rest:string@"nu-complete zoxide path"] { export def --env --wrapped __zoxide_zi [...rest: string@"nu-complete zoxide path"] {
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")' cd $'(^zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
} }
alias cd = __zoxide_z alias cd = __zoxide_z
alias ci = __zoxide_zi alias ci = __zoxide_zi
}
use zoxide-commands *