Changed . token to _dot

This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
This commit is contained in:
2024-11-07 13:52:17 +00:00
parent 83b02bd753
commit 896af887ca
2351 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Fuzzy all the things
### Purpose
This contains a few scripts that add fuzzy search interfaces to built-in nu functionalities. Often you
want to search commands/your history interactively, which is where [fzf](https://github.com/junegunn/fzf) excels at.
### How to use
`./fuzzy_history_search.nu` searches your command history and, after pressing `enter`, copies the selected command into the clipboard
`./fuzzy_command_search.nu` searches both commands and subcommands for both a) names and b) their description, and, after pressing `enter`, copies the selected command into the clipboard
To use them in your day-to-day workflow, add
```
source <absolute-path-to-nu_scripts>/fuzzy/fuzzy_history_search.nu
source <absolute-path-to-nu_scripts>/fuzzy/fuzzy_command_search.nu
```
to your `config.nu`
It's likely a good idea to also add some short and sweet aliases, e.g.
```
alias hi = fuzzy-history-search
alias hf = fuzzy-command-search
```

View File

@@ -0,0 +1,25 @@
const tablen = 8
# calculate required tabs/spaces to get a nicely aligned table
def pad-tabs [input_name max_indent] {
let input_length = ($input_name | str length)
let required_tabs = $max_indent - ($input_length / $tablen | into int)
seq 0 $required_tabs | reduce -f "" {|it, acc| $acc + (char tab)}
}
# fuzzy search a) commands b) subcommands
# on selection, will display `help` for the commands
# and paste command into clipboard for you to paste right away
export def fuzzy-command-search [] {
let max_len = (help commands | each { $in.name | str length } | math max)
let max_indent = ($max_len / $tablen | into int)
let command = ((help commands | each {|it|
let name = ($it.name | str trim | ansi strip)
$"($name)(pad-tabs $name $max_indent)($it.usage)"
}) | str join (char nl) | fzf | split column (char tab) | get column1.0)
if ($command | is-not-empty) {
help $command
}
}

View File

@@ -0,0 +1 @@
export def fuzzy-history-search [] { cat $nu.history-path | fzf | clip }