Skip to content

Commit

Permalink
Improve filename completion behaviour
Browse files Browse the repository at this point in the history
Set the `filenames` option when completing filenames which allows more
ergonomic completion of paths.

Signed-off-by: Stephen Sherratt <[email protected]>
  • Loading branch information
gridbugs committed Nov 28, 2024
1 parent 31e2c40 commit 021ba83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/fake_git.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ let commit =
let open Arg_parser in
let+ _amend = flag [ "amend"; "a" ]
and+ _branch = named_opt [ "b"; "branch" ] branch_conv
and+ _message = named_opt [ "m"; "message" ] string in
and+ _message = named_opt [ "m"; "message" ] string
and+ _files = pos_all file in
()
;;

Expand Down
6 changes: 6 additions & 0 deletions src/climate/completion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ module Add_reply = struct
"Takes the word under the cursor (just the portion up to the cursor) and \
completes with files in the current directory."
; raw "COMPREPLY+=($(compgen -A file -- \"$1\"))"
; comment
"Tell the shell that completions will be filenames. This allows for ergonomic \
improvements such as appending a slash to directories and omitting the space \
after completions so completion of paths can continue if the user presses tab \
again."
; raw "compopt -o filenames"
]
;;

Expand Down

0 comments on commit 021ba83

Please sign in to comment.