feat: added fzf command history keybinding to ctrl+r key
This commit is contained in:
parent
74a6c74867
commit
a0a02e743f
1 changed files with 40 additions and 22 deletions
|
|
@ -15,6 +15,28 @@ $env.config = {
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keybindings: [
|
||||||
|
{
|
||||||
|
name: fuzzy_history_fzf
|
||||||
|
modifier: control
|
||||||
|
keycode: char_r
|
||||||
|
mode: [emacs , vi_normal, vi_insert]
|
||||||
|
event: {
|
||||||
|
send: executehostcommand
|
||||||
|
cmd: "commandline edit --replace (
|
||||||
|
history
|
||||||
|
| get command
|
||||||
|
| reverse
|
||||||
|
| uniq
|
||||||
|
| str join (char -i 0)
|
||||||
|
| fzf --scheme=history --read0 --tiebreak=chunk --layout=reverse --preview='echo {..}' --preview-window='bottom:3:wrap' --bind alt-up:preview-up,alt-down:preview-down --height=70% -q (commandline) --preview='echo -n {} | nu --stdin -c \'nu-highlight'''
|
||||||
|
| decode utf-8
|
||||||
|
| str trim
|
||||||
|
)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir ($nu.data-dir | path join "vendor/autoload")
|
mkdir ($nu.data-dir | path join "vendor/autoload")
|
||||||
|
|
@ -26,37 +48,33 @@ source ~/.cache/carapace/init.nu
|
||||||
|
|
||||||
# gitignore.io command
|
# gitignore.io command
|
||||||
def _gitignoreio_list [] {
|
def _gitignoreio_list [] {
|
||||||
http get https://www.toptal.com/developers/gitignore/api/list
|
http get https://www.toptal.com/developers/gitignore/api/list
|
||||||
| str replace -a "\n" ","
|
| str replace -a "\n" ","
|
||||||
| split row ","
|
| split row ","
|
||||||
| str trim
|
| str trim
|
||||||
| where {|x| $x != ""}
|
| where {|x| $x != ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete gi" [] {
|
def "nu-complete gi" [] {
|
||||||
_gitignoreio_list
|
let fixed = ["list"]
|
||||||
|
let templates = _gitignoreio_list
|
||||||
|
$fixed ++ $templates
|
||||||
}
|
}
|
||||||
|
|
||||||
def gi [...args: string@"nu-complete gi"] {
|
def gi [...args: string@"nu-complete gi"] {
|
||||||
if ($args | where {|x| $x == "list"} | length) > 0 {
|
if ($args | where {|x| $x == "list"} | length) > 0 {
|
||||||
return (_gitignoreio_list)
|
return (_gitignoreio_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Join templates with commas and fetch .gitignore
|
# Join templates with commas and fetch .gitignore
|
||||||
let joined = ($args | sort | str join ",")
|
let joined = ($args | sort | str join ",")
|
||||||
http get $"https://www.toptal.com/developers/gitignore/api/($joined)"
|
http get $"https://www.toptal.com/developers/gitignore/api/($joined)"
|
||||||
}
|
|
||||||
|
|
||||||
# take command
|
|
||||||
def take [path: string] {
|
|
||||||
mkdir $path
|
|
||||||
cd $path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# secret copy command
|
# secret copy command
|
||||||
def sc [path: string] {
|
def sc [path: string] {
|
||||||
["/run/secrets" $path]
|
["/run/secrets" ($path)]
|
||||||
| path join
|
| path join
|
||||||
| open
|
| open
|
||||||
| wl-copy
|
| wl-copy
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue