nushell completion, zoxide added
This commit is contained in:
+1
-4
@@ -31,11 +31,8 @@ yay -S mint-themes mint-y-icons kvantum-theme-catppuccin-git catppuccin-gtk-them
|
|||||||
yay -S lxinput-gtk3 qt6ct pamac-gtk3
|
yay -S lxinput-gtk3 qt6ct pamac-gtk3
|
||||||
|
|
||||||
# terminal and shell
|
# terminal and shell
|
||||||
yay -S nushell
|
yay -S nushell oh-my-posh carapace-bin zoxide
|
||||||
chsh -s /usr/bin/nu
|
chsh -s /usr/bin/nu
|
||||||
|
|
||||||
# nushell
|
|
||||||
yay -S oh-my-posh carapace-bin
|
|
||||||
oh-my-posh init nu --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/refs/heads/main/themes/peru.omp.json
|
oh-my-posh init nu --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/refs/heads/main/themes/peru.omp.json
|
||||||
|
|
||||||
# code
|
# code
|
||||||
|
|||||||
+60
-29
@@ -1,18 +1,44 @@
|
|||||||
$env.config.buffer_editor = "/usr/bin/nvim"
|
|
||||||
$env.SYSTEMD_EDITOR = "/usr/bin/nvim"
|
$env.SYSTEMD_EDITOR = "/usr/bin/nvim"
|
||||||
$env.EDITOR = "/usr/bin/nvim"
|
$env.EDITOR = "/usr/bin/nvim"
|
||||||
$env.VISUAL = "/usr/bin/nvim"
|
$env.VISUAL = "/usr/bin/nvim"
|
||||||
$env.config.show_banner = false
|
|
||||||
$env.config.edit_mode = 'vi'
|
|
||||||
$env.config = {
|
$env.config = {
|
||||||
|
buffer_editor: "/usr/bin/nvim"
|
||||||
|
completions: {
|
||||||
|
external: {
|
||||||
|
enable: true
|
||||||
|
max_results: 100
|
||||||
|
completer: {|spans|
|
||||||
|
let carapace_completer = {|spans: list<string>|
|
||||||
|
carapace $spans.0 nushell ...$spans
|
||||||
|
| from json
|
||||||
|
| if ($in | default [] | where value =~ '^-.*ERR$' | is-empty) { $in } else { null }
|
||||||
|
}
|
||||||
|
|
||||||
|
match $spans.0 {
|
||||||
|
_ => $carapace_completer
|
||||||
|
} | do $in $spans
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
cursor_shape: {
|
cursor_shape: {
|
||||||
vi_insert: line
|
vi_insert: line
|
||||||
vi_normal: block
|
vi_normal: block
|
||||||
}
|
}
|
||||||
|
edit_mode: 'vi'
|
||||||
history: {
|
history: {
|
||||||
file_format: sqlite
|
file_format: sqlite
|
||||||
isolation: true
|
isolation: true
|
||||||
}
|
}
|
||||||
|
hooks: {
|
||||||
|
env_change: {
|
||||||
|
PWD: [
|
||||||
|
{
|
||||||
|
__zoxide_hook: true,
|
||||||
|
code: {|_, dir| zoxide add -- $dir}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
keybindings: [
|
keybindings: [
|
||||||
{
|
{
|
||||||
name: fuzzy_history_fzf
|
name: fuzzy_history_fzf
|
||||||
@@ -23,7 +49,7 @@ $env.config = {
|
|||||||
send: ExecuteHostCommand
|
send: ExecuteHostCommand
|
||||||
cmd: "commandline edit --insert (
|
cmd: "commandline edit --insert (
|
||||||
history
|
history
|
||||||
| where exit_status == 0
|
# | where exit_status == 0
|
||||||
| get command
|
| get command
|
||||||
| reverse
|
| reverse
|
||||||
| uniq
|
| uniq
|
||||||
@@ -80,6 +106,7 @@ $env.config = {
|
|||||||
event: {edit: backspaceword}
|
event: {edit: backspaceword}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
show_banner: false
|
||||||
}
|
}
|
||||||
|
|
||||||
# from: https://github.com/nushell/nushell/issues/8166
|
# from: https://github.com/nushell/nushell/issues/8166
|
||||||
@@ -111,29 +138,33 @@ def monitor [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Jump to a directory using only keywords.
|
||||||
|
def --env --wrapped z [...rest: string@zoxide_completer] {
|
||||||
|
let path = match $rest {
|
||||||
|
[] => {'~'},
|
||||||
|
[ '-' ] => {'-'},
|
||||||
|
[ $arg ] if ($arg | path type) == 'dir' => {$arg}
|
||||||
|
_ => {
|
||||||
|
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cd $path
|
||||||
|
}
|
||||||
|
# Jump to a directory using interactive search.
|
||||||
|
def --env --wrapped zi [...rest:string] {
|
||||||
|
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
|
||||||
|
}
|
||||||
|
def zoxide_completer [context: string] {
|
||||||
|
let parts = $context | split row " " | skip 1
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
sort: false
|
||||||
|
completion_algorithm: prefix
|
||||||
|
positional: false
|
||||||
|
case_sensitive: false
|
||||||
|
}
|
||||||
|
completions: (zoxide query --list --exclude $env.PWD -- ...$parts | lines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
source ~/.oh-my-posh.nu
|
source ~/.oh-my-posh.nu
|
||||||
|
|
||||||
let carapace_completer = {|spans|
|
|
||||||
carapace $spans.0 nushell ...$spans | from json
|
|
||||||
# carapace doesn't give completions if you don't give it any additional
|
|
||||||
# args
|
|
||||||
mut spans = $spans
|
|
||||||
if ($spans | is-empty) {
|
|
||||||
$spans = [""]
|
|
||||||
}
|
|
||||||
|
|
||||||
carapace $spans.0 nushell ...$spans | from json
|
|
||||||
# sort by color
|
|
||||||
| sort-by {
|
|
||||||
let fg = $in | get -i style.fg
|
|
||||||
let attr = $in | get -i style.attr
|
|
||||||
|
|
||||||
# the ~ there to make "empty" results appear at the end
|
|
||||||
$"($fg)~($attr)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$env.config.completions.external = {
|
|
||||||
enable: true
|
|
||||||
max_results: 100
|
|
||||||
completer: $carapace_completer
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user