config dump
This commit is contained in:
parent
655dfe3d48
commit
cf8afe544a
6 changed files with 355 additions and 357 deletions
150
nushell/atuin.nu
150
nushell/atuin.nu
|
@ -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
|
||||||
|
|
||||||
|
@ -6,100 +5,99 @@ hide-env -i ATUIN_HISTORY_ID
|
||||||
let ATUIN_KEYBINDING_TOKEN = $"# (random uuid)"
|
let ATUIN_KEYBINDING_TOKEN = $"# (random uuid)"
|
||||||
|
|
||||||
let _atuin_pre_execution = {||
|
let _atuin_pre_execution = {||
|
||||||
if ($nu | get -i history-enabled) == false {
|
if ($nu | get -i history-enabled) == false {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let cmd = (commandline)
|
let cmd = (commandline)
|
||||||
if ($cmd | is-empty) {
|
if ($cmd | is-empty) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if not ($cmd | str starts-with $ATUIN_KEYBINDING_TOKEN) {
|
if not ($cmd | str starts-with $ATUIN_KEYBINDING_TOKEN) {
|
||||||
$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 {
|
||||||
let version = version
|
let version = version
|
||||||
let major = $version.major?
|
let major = $version.major?
|
||||||
if $major != null {
|
if $major != null {
|
||||||
# These members are only available in versions > 0.92.2
|
# These members are only available in versions > 0.92.2
|
||||||
[$major $version.minor $version.patch]
|
[$major $version.minor $version.patch]
|
||||||
} else {
|
} else {
|
||||||
# So fall back to the slower parsing when they're missing
|
# So fall back to the slower parsing when they're missing
|
||||||
$version.version | split row '.' | into int
|
$version.version | split row '.' | into int
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[
|
}
|
||||||
$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' }),
|
[
|
||||||
(if $nu_version.1 >= 92 { '(run-external atuin search' } else { '(run-external --redirect-stderr atuin search' }),
|
`with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`
|
||||||
($flags | append [--interactive] | each {|e| $'"($e)"'}),
|
(if $nu_version.0 <= 0 and $nu_version.1 <= 90 { 'commandline' } else { 'commandline edit' })
|
||||||
(if $nu_version.1 >= 92 { ' e>| str trim)' } else {' | complete | $in.stderr | str substring ..-1)'}),
|
(if $nu_version.1 >= 92 { '(run-external atuin search' } else { '(run-external --redirect-stderr atuin search' })
|
||||||
`}`,
|
($flags | append [--interactive] | each {|e| $'"($e)"' })
|
||||||
] | flatten | str join ' '),
|
(if $nu_version.1 >= 92 { ' e>| str trim)' } else { ' | complete | $in.stderr | str substring ..-1)' })
|
||||||
] | str join "\n"
|
`}`
|
||||||
|
] | flatten | str join ' '
|
||||||
|
)
|
||||||
|
] | 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)
|
||||||
$env.config = (
|
$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 (
|
|
||||||
$env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt)
|
|
||||||
)
|
)
|
||||||
|
| upsert pre_prompt (
|
||||||
|
$env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
$env.config = ($env.config | default [] keybindings)
|
$env.config = ($env.config | default [] keybindings)
|
||||||
|
|
||||||
$env.config = (
|
$env.config = (
|
||||||
$env.config | upsert keybindings (
|
$env.config | upsert keybindings (
|
||||||
$env.config.keybindings
|
$env.config.keybindings
|
||||||
| append {
|
| append {
|
||||||
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)}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
$env.config = (
|
$env.config = (
|
||||||
$env.config | upsert keybindings (
|
$env.config | upsert keybindings (
|
||||||
$env.config.keybindings
|
$env.config.keybindings
|
||||||
| append {
|
| append {
|
||||||
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')}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# =============================================================================
|
|
||||||
|
|
|
@ -1,46 +1,30 @@
|
||||||
$env.config.completions = {
|
$env.PATH = ($env.PATH | split row (char esep) | prepend "/home/cr/.config/carapace/bin")
|
||||||
algorithm: prefix
|
|
||||||
sort: smart
|
|
||||||
case_sensitive: false
|
|
||||||
quick: true
|
|
||||||
partial: true
|
|
||||||
use_ls_colors: true
|
|
||||||
external: {
|
|
||||||
enable: true
|
|
||||||
max_results: 10
|
|
||||||
completer: {|spans: list<string>|
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# overwrite
|
def --env get-env [name] { $env | get $name }
|
||||||
let spans = (if $expanded_alias != null {
|
def --env set-env [name, value] { load-env { $name: $value } }
|
||||||
# put the first word of the expanded alias first in the span
|
def --env unset-env [name] { hide-env $name }
|
||||||
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1)
|
|
||||||
} else {
|
|
||||||
$spans | skip 1 | prepend ($spans.0)
|
|
||||||
})
|
|
||||||
|
|
||||||
carapace $spans.0 nushell ...$spans
|
let carapace_completer = {|spans|
|
||||||
| from json
|
# 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)
|
||||||
}
|
|
||||||
|
|
||||||
|
# overwrite
|
||||||
|
let spans = (if $expanded_alias != null {
|
||||||
|
# put the first word of the expanded alias first in the span
|
||||||
|
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1)
|
||||||
|
} else {
|
||||||
|
$spans | skip 1 | prepend ($spans.0)
|
||||||
|
})
|
||||||
|
|
||||||
|
carapace $spans.0 nushell ...$spans
|
||||||
|
| 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
$env.config = {
|
$env.config = {
|
||||||
bracketed_paste: true
|
bracketed_paste: true
|
||||||
buffer_editor: "hx"
|
buffer_editor: "hx"
|
||||||
datetime_format: {}
|
datetime_format: {}
|
||||||
edit_mode: vi
|
edit_mode: vi
|
||||||
error_style: fancy
|
error_style: fancy
|
||||||
float_precision: 2
|
float_precision: 2
|
||||||
footer_mode: 25
|
footer_mode: 25
|
||||||
render_right_prompt_on_last_line: false
|
render_right_prompt_on_last_line: false
|
||||||
show_banner: false
|
show_banner: false
|
||||||
use_ansi_coloring: true
|
use_ansi_coloring: true
|
||||||
use_kitty_protocol: true
|
use_kitty_protocol: true
|
||||||
|
|
||||||
shell_integration: {
|
shell_integration: {
|
||||||
osc2: false
|
osc2: false
|
||||||
osc7: true
|
osc7: true
|
||||||
osc8: true
|
osc8: true
|
||||||
osc9_9: false
|
osc9_9: false
|
||||||
osc133: true
|
osc133: true
|
||||||
osc633: true
|
osc633: true
|
||||||
reset_application_mode: true
|
reset_application_mode: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,37 +32,37 @@ $env.config.rm.always_trash = true
|
||||||
$env.config.table = {
|
$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
|
||||||
wrapping_try_keep_words: true
|
wrapping_try_keep_words: true
|
||||||
truncating_suffix: "..."
|
truncating_suffix: "..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$env.config.history = {
|
$env.config.history = {
|
||||||
file_format: sqlite
|
file_format: sqlite
|
||||||
isolation: false
|
isolation: false
|
||||||
max_size: 100_000
|
max_size: 100_000
|
||||||
sync_on_enter: true
|
sync_on_enter: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,39 +86,38 @@ $env.config.hooks = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
pre_prompt: [
|
pre_prompt: [
|
||||||
{
|
{
|
||||||
if (which direnv | is-empty) {
|
if (which direnv | is-empty) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
direnv export json | from json | default {} | load-env
|
direnv export json | from json | default {} | load-env
|
||||||
# Direnv outputs $PATH as a string, but nushell silently breaks if isn't a list-like table.
|
# Direnv outputs $PATH as a string, but nushell silently breaks if isn't a list-like table.
|
||||||
# The following behemoth of Nu code turns this into nu's format while following the standards of how to handle quotes, use it if you need quote handling instead of the line below it:
|
# The following behemoth of Nu code turns this into nu's format while following the standards of how to handle quotes, use it if you need quote handling instead of the line below it:
|
||||||
# $env.PATH = $env.PATH | parse --regex ('' + `((?:(?:"(?:(?:\\[\\"])|.)*?")|(?:'.*?')|[^` + (char env_sep) + `]*)*)`) | each {|x| $x.capture0 | parse --regex `(?:"((?:(?:\\"|.))*?)")|(?:'(.*?)')|([^'"]*)` | each {|y| if ($y.capture0 != "") { $y.capture0 | str replace -ar `\\([\\"])` `$1` } else if ($y.capture1 != "") { $y.capture1 } else $y.capture2 } | str join }
|
# $env.PATH = $env.PATH | parse --regex ('' + `((?:(?:"(?:(?:\\[\\"])|.)*?")|(?:'.*?')|[^` + (char env_sep) + `]*)*)`) | each {|x| $x.capture0 | parse --regex `(?:"((?:(?:\\"|.))*?)")|(?:'(.*?)')|([^'"]*)` | each {|y| if ($y.capture0 != "") { $y.capture0 | str replace -ar `\\([\\"])` `$1` } else if ($y.capture1 != "") { $y.capture1 } else $y.capture2 } | str join }
|
||||||
$env.PATH = $env.PATH | split row (char env_sep)
|
$env.PATH = $env.PATH | split row (char env_sep)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
$env.config.menus = [
|
$env.config.menus = [
|
||||||
{
|
{
|
||||||
marker: $"(ansi yellow)╋ "
|
marker: $"(ansi yellow)╋ "
|
||||||
name: help_menu
|
name: help_menu
|
||||||
only_buffer_difference: true
|
only_buffer_difference: true
|
||||||
style: {
|
style: {
|
||||||
description_text: yellow
|
description_text: yellow
|
||||||
selected_text: red_reverse
|
selected_text: red_reverse
|
||||||
text: yellow
|
text: yellow
|
||||||
}
|
}
|
||||||
type: {
|
type: {
|
||||||
col_padding: 2
|
col_padding: 2
|
||||||
col_width: 20
|
col_width: 20
|
||||||
columns: 4
|
columns: 4
|
||||||
description_rows: 10
|
description_rows: 10
|
||||||
layout: description
|
layout: description
|
||||||
selection_rows: 4
|
selection_rows: 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -128,190 +127,187 @@ $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
|
name: escape
|
||||||
modifier: none
|
modifier: none
|
||||||
keycode: tab
|
keycode: escape
|
||||||
mode: [ vi_normal vi_insert ]
|
mode: [vi_normal vi_insert]
|
||||||
event: {
|
event: {send: esc}
|
||||||
until: [
|
|
||||||
{ send: menu name: completion_menu }
|
|
||||||
{ send: menunext }
|
|
||||||
{ edit: complete }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name: escape
|
name: cancel_command
|
||||||
modifier: none
|
|
||||||
keycode: escape
|
|
||||||
mode: [ vi_normal vi_insert ]
|
|
||||||
event: { send: esc }
|
|
||||||
}
|
|
||||||
{
|
|
||||||
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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name: delete_one_character_backward
|
name: delete_one_character_backward
|
||||||
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.
|
||||||
|
|
|
@ -1,55 +1,57 @@
|
||||||
use std null_device
|
use std null_device
|
||||||
|
|
||||||
export-env { load-env {
|
export-env {
|
||||||
PROMPT_COMMAND: {||
|
load-env {
|
||||||
let exit_code = $env.LAST_EXIT_CODE
|
PROMPT_COMMAND: {||
|
||||||
let jj_root = try { ^jj root err> $null_device } catch { "" }
|
let exit_code = $env.LAST_EXIT_CODE
|
||||||
$env.LAST_EXIT_CODE = 0
|
let jj_root = try { ^jj root err> $null_device } catch { "" }
|
||||||
let vcs_root = if not ($jj_root | is-empty ) { $jj_root } else {""}
|
$env.LAST_EXIT_CODE = 0
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
let exit_code_segment = if ($exit_code == 0) {
|
let exit_code_segment = if ($exit_code == 0) {
|
||||||
""
|
""
|
||||||
} else {
|
} else {
|
||||||
$"(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: {||
|
||||||
|
let path_segment = $env.PWD | path basename
|
||||||
|
|
||||||
}
|
let exit_code_segment = if ($env.LAST_EXIT_CODE == 0) {
|
||||||
TRANSIENT_PROMPT_COMMAND: {||
|
""
|
||||||
let path_segment = $env.PWD | path basename
|
} else {
|
||||||
|
$"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━"
|
||||||
|
}
|
||||||
|
|
||||||
let exit_code_segment = if ($env.LAST_EXIT_CODE == 0) {
|
[$"(ansi yellow)━" $exit_code_segment "━ " $path_segment] | str join
|
||||||
""
|
}
|
||||||
} else {
|
PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ "
|
||||||
$"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━"
|
PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ "
|
||||||
}
|
# PROMPT_MULTILINE_INDICATOR: "::: "
|
||||||
|
PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
||||||
|
TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " "
|
||||||
|
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " "
|
||||||
|
TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
||||||
|
|
||||||
[$"(ansi yellow)━",$exit_code_segment,"━ ", $path_segment] | str join
|
config: (
|
||||||
}
|
$env.config? | default {} | merge {
|
||||||
PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ "
|
render_right_prompt_on_last_line: true
|
||||||
PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ "
|
}
|
||||||
# PROMPT_MULTILINE_INDICATOR: "::: "
|
)
|
||||||
PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
|
||||||
TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " "
|
|
||||||
TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " "
|
|
||||||
TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ "
|
|
||||||
|
|
||||||
config: ($env.config? | default {} | merge {
|
PROMPT_COMMAND_RIGHT: {||
|
||||||
render_right_prompt_on_last_line: true
|
let jj_status = try {
|
||||||
})
|
jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template '
|
||||||
|
|
||||||
PROMPT_COMMAND_RIGHT: {||
|
|
||||||
let jj_status = try {
|
|
||||||
jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template '
|
|
||||||
separate(
|
separate(
|
||||||
" ",
|
" ",
|
||||||
if(empty, label("empty", "(empty)")),
|
if(empty, label("empty", "(empty)")),
|
||||||
|
@ -73,8 +75,10 @@ PROMPT_COMMAND_RIGHT: {||
|
||||||
if(hidden, label("hidden prefix", "(hidden)")),
|
if(hidden, label("hidden prefix", "(hidden)")),
|
||||||
)
|
)
|
||||||
' err> $null_device
|
' err> $null_device
|
||||||
} catch {
|
} catch {
|
||||||
""
|
""
|
||||||
|
}
|
||||||
|
$jj_status
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$jj_status
|
}
|
||||||
}}}
|
|
||||||
|
|
2
nushell/source_profile.nu
Executable file → Normal file
2
nushell/source_profile.nu
Executable file → Normal 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 {
|
||||||
|
|
|
@ -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] {
|
|
||||||
let parts = $context | split row -r "[ /]" | skip 1
|
|
||||||
{
|
|
||||||
options: {
|
|
||||||
sort: false,
|
|
||||||
completion_algorithm: substring,
|
|
||||||
case_sensitive: false,
|
|
||||||
},
|
|
||||||
completions: (
|
|
||||||
^zoxide query --list --exclude $env.PWD -- ...$parts
|
|
||||||
| lines
|
|
||||||
| first 10
|
|
||||||
| each {|p| $p | path relative-to $env.PWD | $"($in)/"}
|
|
||||||
|
|
||||||
# | each {|p| echo p | path basename}
|
|
||||||
)
|
)
|
||||||
# | each {|p| echo p | path basename | $"($in)/"}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Jump to a directory using only keywords.
|
module zoxide-commands {
|
||||||
def --env --wrapped __zoxide_z [...rest: string@"nu-complete zoxide path"] {
|
def "nu-complete zoxide path" [context: string] {
|
||||||
let path = match $rest {
|
let parts = $context | str trim --left | split row " " | skip 1 | each { str downcase }
|
||||||
[] => {'~'},
|
let completions = (
|
||||||
[ '-' ] => {'-'},
|
^zoxide query --list --exclude $env.PWD -- ...$parts
|
||||||
[ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
|
| lines
|
||||||
_ => {
|
| each {|dir|
|
||||||
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
|
if ($parts | length) <= 1 {
|
||||||
|
$dir
|
||||||
|
} 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
sort: false
|
||||||
|
completion_algorithm: prefix
|
||||||
|
positional: false
|
||||||
|
case_sensitive: false
|
||||||
|
}
|
||||||
|
completions: $completions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cd $path
|
|
||||||
|
# Jump to a directory using only keywords.
|
||||||
|
export def --env --wrapped __zoxide_z [...rest: string@"nu-complete zoxide path"] {
|
||||||
|
let path = match $rest {
|
||||||
|
[] => { '~' }
|
||||||
|
['-'] => { '-' }
|
||||||
|
[$arg] if ($arg | path expand | path type) == 'dir' => { $arg }
|
||||||
|
_ => {
|
||||||
|
^zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue