nushell / nushell/nushell.github.io
Script for adding curent path to `zoxide` complete
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 258
- Fork
- 561
- Merge medio
- 3h 20m
- PR unite (30g)
- 15
Descrizione
I like using zoxide as a replacement for cd, so I also like having the tab complete have the current dirs in the directory in addition to the zoxide complete.
I'm not too sure in my own nushell code, so I don't want to make a pull request, but I'd like to share how I added the current dir to my zoxide complete.
let zoxide_completer = {|spans|
let path = ($spans.1 | glob $"\(?i\)($in)*" | where {path type | $in == dir} | each {path relative-to (glob "." | first)})
let zoxide = ($spans | skip 1 | zoxide query -l ...$in | lines | where {|x| $x != $env.PWD})
($zoxide | prepend $path)
}
this addition to the completer allows you to do this:
The first two entries are from the current dir, the second two are from zoxide.
There are a few places this script can fail. Firstly being with the path relative-to command. It will straight up fail if the prefix can't be found. I have an immutable distro so my /home/user folder is linked to the /var/home/user folder. This makes it unreliable to use $env.PWD as this will be different from what glob returns, so I just glob . instead, lol. Also, I'm unsure if spans always return more than one element. It seems to work with no arguments, but I don't know how it works.
I'm sure there are better ways of doing this and such, but it works for me. Just wanted to share if anyone wanted to refine it and add it to the external_completers.md file.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo external_completers.md e verificando come vengono presentati gli esempi di completer esterni. Convalida lo snippet Nushell proposto, inclusi i casi senza argomenti e con prefisso del percorso menzionati nell’issue. Il lavoro è completato quando l’esempio documentato aggiunge in modo affidabile le voci della directory corrente insieme ai completamenti di zoxide.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- shell
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100