-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added autocompletion and a simple lfcd script for nushell. (#1341)
* Added autocompletion and a simple lfcd script for nushell. * nu-lfcd script & small style improvements. Moved the autocompletion to a seperate file. * Update lfcd.nu to print to stderr instead of stdout * Fixed the comments inside lf.nu
- Loading branch information
1 parent
a3127a2
commit 3c681c2
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Autocompletion for nushell. | ||
# | ||
# Documentation: https://www.nushell.sh/book/externs.html | ||
|
||
# To enable autocompletion you may put this file into a directory: | ||
# | ||
# mkdir -p ~/.config/nushell/completions | ||
# ln -s "/path/to/lf.nu" ~/.config/nushell/completions | ||
# | ||
# Then you need to source this file in your nu config (Open the config with the | ||
# command 'config nu' inside the nushell) by adding: | ||
# | ||
# source ~/.config/nushell/completions/lf.nu | ||
|
||
export extern "lf" [ | ||
--command # command to execute on client initialization | ||
--config: string # path to the config file (instead of the usual paths) | ||
--cpuprofile: string # path to the file to write the CPU profile | ||
--doc # show documentation | ||
--last-dir-path: string # path to the file to write the last dir on exit (to use for cd) | ||
--log: string # path to the log file to write messages | ||
--memprofile: string # path to the file to write the memory profile | ||
--remote: string # send remote command to server | ||
--selection-path: string # path to the file to write selected files on open (to use as open file dialog) | ||
--server # start server (automatic) | ||
--single # start a client without server | ||
--version # show version | ||
--help # show help | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Change working dir in shell to last dir in lf on exit (adapted from ranger). | ||
# | ||
# You need to add this to your Nushell Enviroment Config File | ||
# (Execute 'config env' in the nushell to open it). | ||
|
||
# You may also like to assign a key (Ctrl-O) to this command: | ||
# See the documentation: https://www.nushell.sh/book/line_editor.html#keybindings | ||
# | ||
# keybindings: [ | ||
# { | ||
# name: lfcd | ||
# modifier: control | ||
# keycode: char_o | ||
# mode: [emacs, vi_normal, vi_insert] | ||
# event: { | ||
# send: executehostcommand | ||
# cmd: "lfcd" | ||
# } | ||
# } | ||
# ] | ||
|
||
def-env lfcd [] { | ||
let tmp = (mktemp) | ||
lf -last-dir-path $tmp | ||
try { | ||
let target_dir = (open --raw $tmp) | ||
rm -f $tmp | ||
try { | ||
if ($target_dir != $env.PWD) { cd $target_dir } | ||
} catch { |e| print -e $'lfcd: Can not change to ($target_dir): ($e | get debug)' } | ||
} catch { | ||
|e| print -e $'lfcd: Reading ($tmp) returned an error: ($e | get debug)' | ||
} | ||
} |