-
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.
- Loading branch information
1 parent
a3127a2
commit 92ced54
Showing
2 changed files
with
61 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,25 @@ | ||
# Autocompletion for nushell. | ||
# | ||
# Documentation: https://www.nushell.sh/book/externs.html | ||
|
||
# Either add this to your existing completions or copy this to | ||
# your nu config file (Use 'config nu' in the nushell to open it). | ||
|
||
module completions { | ||
export extern "lf" [ | ||
--command # command to execute on client initialization | ||
--config # path to the config file (instead of the usual paths) | ||
--cpuprofile # path to the file to write the CPU profile | ||
--doc # show documentation | ||
--last-dir-path # path to the file to write the last dir on exit (to use for cd) | ||
--log # path to the log file to write messages | ||
--memprofile # path to the file to write the memory profile | ||
--remote # send remote command to server | ||
--selection-path # 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 | ||
] | ||
} | ||
use completions * |
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,36 @@ | ||
# 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)"; | ||
let cmd = $'-last-dir-path=($tmp)'; | ||
run-external 'lf' $cmd; | ||
if ($tmp | path exists) { | ||
let dir = $"(cat $tmp)"; | ||
rm -f $"$tmp"; | ||
if ($dir | path exists) { | ||
if ( $dir != $"pwd" ) { | ||
cd $dir; | ||
} | ||
} | ||
} | ||
} |