- pj_completions: merge into $env.config instead of replacing it wholesale - pj_completions: use parse-time const for cache dir instead of pwd fallback - pj_fzf / pj_historyhintcomplete: null-safe keybindings access via ? and default - pj_helix: replace $env.OS (Windows-only) with $nu.os-info.name; extract shared launcher - pj_prompt: fix off-by-one in git OID substring (0..7 -> 0..<7) - pj_prompt: use $nu.os-info.name for OS detection instead of sys host hostname - pj_prompt: cache git availability in static base, skip per-render which call - pj_prompt: bind LAST_EXIT_CODE once in right-prompt closure - pj_brew / pj_uv: add --ignore-errors to hide-env calls - pj_aliases: convert quote/dadjoke to defs with try/catch error handling - pj_deepseek: guard curl availability before invoking - pj_zoxide: add ? to $nu.os-info.name access - pj_starship: fix null-to-nuon producing "null" string; broaden detection - nu_polyjuice: load pj_starship module
76 lines
2.1 KiB
Nu
76 lines
2.1 KiB
Nu
# History
|
|
const fzf_history_selector = {
|
|
name: fzf_history_selector
|
|
modifier: alt
|
|
keycode: char_r
|
|
mode: [emacs, vi_insert, vi_normal]
|
|
event: [
|
|
{
|
|
send: executehostcommand
|
|
cmd: "
|
|
let result = history
|
|
| reverse
|
|
| get command
|
|
| str replace --all (char newline) ' '
|
|
| to text
|
|
| fzf --height 40% --reverse --border;
|
|
commandline edit --append $result;
|
|
commandline set-cursor --end
|
|
"
|
|
}
|
|
]
|
|
}
|
|
|
|
const fzf_file_selector = {
|
|
name: fzf_file_selector
|
|
modifier: alt
|
|
keycode: char_f
|
|
mode: [emacs, vi_insert, vi_normal]
|
|
event: [
|
|
{
|
|
send: executehostcommand
|
|
cmd: "
|
|
let result = (ls **/* | where type == 'file' | get name | to text | fzf --height 40% --reverse --border);
|
|
commandline edit --append $result;
|
|
commandline set-cursor --end
|
|
"
|
|
}
|
|
]
|
|
}
|
|
|
|
const fzf_dir_selector = {
|
|
name: fzf_dir_selector
|
|
modifier: alt
|
|
keycode: char_d
|
|
mode: [emacs, vi_insert, vi_normal]
|
|
event: [
|
|
{
|
|
send: executehostcommand
|
|
cmd: "
|
|
let result = (ls **/ | where type == 'dir' | get name | to text | fzf --height 40% --reverse --border);
|
|
commandline edit --append $result;
|
|
commandline set-cursor --end
|
|
"
|
|
}
|
|
]
|
|
}
|
|
|
|
# Append fzf keybindings to $env.config (defensive: works even if keybindings is absent).
|
|
export-env {
|
|
mut existing = ($env.config.keybindings? | default [])
|
|
|
|
if not ($existing | any {|kb| $kb.name == "fzf_history_selector"}) {
|
|
$existing = ($existing | append [$fzf_history_selector])
|
|
}
|
|
if not ($existing | any {|kb| $kb.name == "fzf_file_selector"}) {
|
|
$existing = ($existing | append [$fzf_file_selector])
|
|
}
|
|
if not ($existing | any {|kb| $kb.name == "fzf_dir_selector"}) {
|
|
$existing = ($existing | append [$fzf_dir_selector])
|
|
}
|
|
|
|
$env.config = ($env.config? | default {} | upsert keybindings $existing)
|
|
}
|
|
|
|
export alias cdi = cd (ls **/ | get name | str join "\n" | fzf)
|