nu: init autoload files

These might be better as part of the configuration but I find these to
be easier to setup for modular configurations.
This commit is contained in:
Gabriel Arazas 2025-01-21 15:03:36 +08:00
parent be96d5bdce
commit 2053483224
3 changed files with 105 additions and 0 deletions

63
nu/autoload/fzf.nu Normal file
View File

@ -0,0 +1,63 @@
# Nushell module based from the `fzf --bash` output.
#
# This port takes some liberty from the Bash script and does not have the same
# integrations such as tmux for now.
#
# It accepts the following envvars and their following description:
#
# - FZF_TMUX_HEIGHT should be the height of the prompt interface and mainly
# used in considering for opening inside of tmux env.
# - FZF_CTRL_T_COMMAND is the default command for Ctrl+T keybinding set for
# this Nu script.
# - FZF_DEFAULT_OPTS is a string
let __fzf_defaults = [
--height ($env.FZF_TMUX_HEIGHT? | default "40%")
--bind=ctrl-z:ignore
]
def __fzf_select [...flags: string] {
with-env {
FZF_CTRL_T_COMMAND: ($env.FZF_CTRL_T_COMMAND? | default "fzf")
FZF_DEFAULT_OPTS: ($env.FZF_DEFAULT_OPTS? | default $__fzf_defaults)
} {
fzf ...$flags ...$env.FZF_DEFAULT_OPTS
}
}
def __fzf_cd [...flags: string] {
with-env {
FZF_CTRL_T_COMMAND: ($env.FZF_CTRL_T_COMMAND? | default "fzf")
FZF_DEFAULT_OPTS: ($env.FZF_DEFAULT_OPTS? | default $__fzf_defaults)
} {
fzf ...$env.FZF_DEFAULT_OPTS --reverse --walker=dir,hidden,follow ...$flags
}
}
$env.config.keybindings = $env.config.keybindings | append [
{
name: fzf_select
modifier: control
keycode: char_t
mode: [emacs vi_normal vi_insert]
event: {
send: ExecuteHostCommand
cmd: "commandline edit --insert (
__fzf_select '--multi'
| lines
| str join ' '
)"
}
}
{
name: fzf_cd
modifier: alt
keycode: char_c
mode: [emacs vi_normal vi_insert]
event: {
send: ExecuteHostCommand
cmd: "cd (__fzf_cd)"
}
}
]

34
nu/autoload/qol.nu Normal file
View File

@ -0,0 +1,34 @@
$env.config.menus = $env.config.menus | append [
{
name: vars_menu
only_buffer_difference: true
marker: "var "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
scope variables
| where name =~ $buffer
| sort-by name
| each { |row| {value: $row.name description: $row.type} }
}
}
]
$env.config.keybindings = $env.config.keybindings | append [
{
name: vars_menu
modifier: control
keycode: char_u
mode: [emacs vi_normal vi_insert]
event: {
send: menu name: vars_menu
}
}
]

8
nu/autoload/wezterm.nu Normal file
View File

@ -0,0 +1,8 @@
$env.config = $env.config | merge deep --strategy=append {
show_banner: false
shell_integration: {
osc7: true
osc133: true
osc633: true
}
}