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,20 +16,17 @@ 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
if 'ATUIN_HISTORY_ID' not-in $env { if 'ATUIN_HISTORY_ID' not-in $env {
return return
} }
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,8 +78,8 @@ $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,14 +91,13 @@ $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}
{send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') } {send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding')}
] ]
} }
} }
) )
) )
# =============================================================================

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)
@ -22,25 +18,13 @@ $env.config.completions = {
carapace $spans.0 nushell ...$spans carapace $spans.0 nushell ...$spans
| from json | from json
}
}
} }
$env.config.menus ++= [
{ mut current = (($env | default {} config).config | default {} completions)
marker: $"(ansi yellow)┣ " $current.completions = ($current.completions | default {} external)
name: completion_menu $current.completions.external = ($current.completions.external
only_buffer_difference: false | default true enable
style: { | default { $carapace_completer } completer)
description_text: yellow
selected_text: red_reverse $env.config = $current
text: yellow
}
type: {
col_padding: 2
col_width: 20
columns: 1
layout: columnar
}
}
]

View file

@ -33,7 +33,7 @@ $env.config.table = {
header_on_separator: false header_on_separator: false
index_mode: always index_mode: always
mode: light mode: light
padding: { left: 1 right: 1 } padding: {left: 1 right: 1}
show_empty: true show_empty: true
trim: { trim: {
methodology: wrapping methodology: wrapping
@ -43,17 +43,17 @@ $env.config.table = {
} }
$env.config.explore = { $env.config.explore = {
command_bar_text: { fg: "#C4C9C6" } command_bar_text: {fg: "#C4C9C6"}
highlight: { fg: black bg: yellow } highlight: {fg: black bg: yellow}
status: { status: {
error: { fg: white bg: red } error: {fg: white bg: red}
warn: {} warn: {}
info: {} info: {}
} }
status_bar_background: { fg: "#1D1F21" bg: "#C4C9C6" } status_bar_background: {fg: "#1D1F21" bg: "#C4C9C6"}
table: { table: {
split_line: { fg: "#404040" } split_line: {fg: "#404040"}
selected_cell: { bg: light_blue } selected_cell: {bg: light_blue}
selected_row: {} selected_row: {}
selected_column: {} selected_column: {}
} }
@ -72,7 +72,7 @@ $env.config.cursor_shape = {
} }
$env.config.hooks = { $env.config.hooks = {
command_not_found: {||} command_not_found: {|| }
pre_execution: [ pre_execution: [
{ {
@ -86,7 +86,6 @@ $env.config.hooks = {
} }
] ]
pre_prompt: [ pre_prompt: [
{ {
if (which direnv | is-empty) { if (which direnv | is-empty) {
@ -128,79 +127,66 @@ $env.config.keybindings = [
name: copy_commandline name: copy_commandline
modifier: alt modifier: alt
keycode: char_c keycode: char_c
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
send: executehostcommand send: executehostcommand
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
keycode: escape keycode: escape
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { send: esc } event: {send: esc}
} }
{ {
name: cancel_command name: cancel_command
modifier: control modifier: control
keycode: char_c keycode: char_c
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { send: ctrlc } event: {send: ctrlc}
} }
{ {
name: quit_shell name: quit_shell
modifier: control modifier: control
keycode: char_d keycode: char_d
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { send: ctrld } event: {send: ctrld}
} }
{ {
name: clear_screen name: clear_screen
modifier: control modifier: control
keycode: char_l keycode: char_l
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { send: clearscreen } event: {send: clearscreen}
} }
{ {
name: open_command_editor name: open_command_editor
modifier: control modifier: control
keycode: char_o keycode: char_o
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { send: openeditor } event: {send: openeditor}
} }
{ {
name: abbr name: abbr
modifier: control modifier: control
keycode: space keycode: space
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: " "}
] ]
} }
{ {
name: move_down name: move_down
modifier: none modifier: none
keycode: down keycode: down
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: menudown } {send: menudown}
{ send: down } {send: down}
] ]
} }
} }
@ -208,11 +194,11 @@ $env.config.keybindings = [
name: move_left name: move_left
modifier: none modifier: none
keycode: left keycode: left
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: menuleft } {send: menuleft}
{ send: left } {send: left}
] ]
} }
} }
@ -220,12 +206,12 @@ $env.config.keybindings = [
name: move_right_or_take_history_hint name: move_right_or_take_history_hint
modifier: none modifier: none
keycode: right keycode: right
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: historyhintcomplete } {send: historyhintcomplete}
{ send: menuright } {send: menuright}
{ send: right } {send: right}
] ]
} }
} }
@ -233,18 +219,18 @@ $env.config.keybindings = [
name: move_one_word_left name: move_one_word_left
modifier: control modifier: control
keycode: left keycode: left
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { edit: movewordleft } event: {edit: movewordleft}
} }
{ {
name: move_one_word_right_or_take_history_hint name: move_one_word_right_or_take_history_hint
modifier: control modifier: control
keycode: right keycode: right
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: historyhintwordcomplete } {send: historyhintwordcomplete}
{ edit: movewordright } {edit: movewordright}
] ]
} }
} }
@ -252,18 +238,18 @@ $env.config.keybindings = [
name: move_to_line_start name: move_to_line_start
modifier: control modifier: control
keycode: char_a keycode: char_a
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { edit: movetolinestart } event: {edit: movetolinestart}
} }
{ {
name: move_to_line_end_or_take_history_hint name: move_to_line_end_or_take_history_hint
modifier: control modifier: control
keycode: char_e keycode: char_e
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: historyhintcomplete } {send: historyhintcomplete}
{ edit: movetolineend } {edit: movetolineend}
] ]
} }
} }
@ -272,46 +258,56 @@ $env.config.keybindings = [
modifier: none modifier: none
keycode: backspace keycode: backspace
mode: vi_insert mode: vi_insert
event: { edit: backspace } event: {edit: backspace}
} }
{ {
name: delete_one_word_backward name: delete_one_word_backward
modifier: control modifier: control
keycode: backspace keycode: backspace
mode: vi_insert mode: vi_insert
event: { edit: backspaceword } event: {edit: backspaceword}
} }
{ {
name: newline_or_run_command name: newline_or_run_command
modifier: none modifier: none
keycode: enter keycode: enter
mode: vi_insert mode: vi_insert
event: { send: enter } event: {send: enter}
} }
{ {
name: take_history_hint name: take_history_hint
modifier: control modifier: control
keycode: char_f keycode: char_f
mode: [ vi_normal vi_insert ] mode: [vi_normal vi_insert]
event: { event: {
until: [ until: [
{ send: historyhintcomplete } {send: historyhintcomplete}
] ]
} }
} }
] ]
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,16 +1,17 @@
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 { "" }
$env.LAST_EXIT_CODE = 0 $env.LAST_EXIT_CODE = 0
let vcs_root = if not ($jj_root | is-empty ) { $jj_root } else {""} let vcs_root = if not ($jj_root | is-empty) { $jj_root } else { "" }
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,21 +33,23 @@ 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)┋ "
# PROMPT_MULTILINE_INDICATOR: "::: " # PROMPT_MULTILINE_INDICATOR: "::: "
PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ " PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " " 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 {
jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template ' jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template '
separate( separate(
@ -77,4 +79,6 @@ PROMPT_COMMAND_RIGHT: {||
"" ""
} }
$jj_status $jj_status
}}} }
}
}

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

@ -13,7 +13,7 @@ if not ($env_vars_file | path exists) {
| lines | lines
| parse 'export {name}="{value}"' | parse 'export {name}="{value}"'
| transpose --header-row --as-record | transpose --header-row --as-record
| tee {load-env $in} | tee { load-env $in }
| to nuon | to nuon
| save --force $env_vars_file | save --force $env_vars_file
} else { } else {

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 }
}
)
} }
} }
def "nu-complete zoxide path" [context: string] { module zoxide-commands {
let parts = $context | split row -r "[ /]" | skip 1 def "nu-complete zoxide path" [context: string] {
{ let parts = $context | str trim --left | split row " " | skip 1 | each { str downcase }
options: { let completions = (
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
# | each {|p| echo p | path basename | $"($in)/"}), 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
}
}
}
)
{
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.
export def --env --wrapped __zoxide_zi [...rest: string@"nu-complete zoxide path"] {
cd $'(^zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
}
alias cd = __zoxide_z
alias ci = __zoxide_zi
} }
# Jump to a directory using interactive search. use zoxide-commands *
def --env --wrapped __zoxide_zi [...rest:string@"nu-complete zoxide path"] {
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
}
alias cd = __zoxide_z
alias ci = __zoxide_zi