Invokes completion of various frameworks and provides bridge actions for carapace-bin.
Supported inputs:
- argcomplete
- bash
- carapace
- carapace-bin
- clap
- click
- cobra
- complete
- fish
- inshellisense
- kingpin
- powershell
- urfavecli
- yargs
- zsh
Supported outputs:
completion bridge
Home Page: https://carapace.sh
License: MIT License
Invokes completion of various frameworks and provides bridge actions for carapace-bin.
Supported inputs:
Supported outputs:
In the bash.go file, when creating the list of locations to look for completions, if the user doesn't have BASH_COMPLETION_USER_DIR
set, but does have XDG_DATA_HOME
set, then the location it adds to the list ends up being XDG_DATA_HOME/.local/share/bash-completion/completions
. However, in most cases, the value of XDG_DATA_HOME
itself is set to /home/user/.local/share
. So, the location ends up being, /home/user/.local/share/.local/share/bash-completion/completions
, which is incorrect as the directory doesn't exist.
The fix is pretty small, and easy to implement. Please let me know if I should raise a PR for it.
Any idea why this entire script, line by line, goes into the bash history when I try to complete a command using bash bridge in both nushell
and fish
?
carapace-bridge/pkg/actions/bridge/bash.sh
Lines 1 to 25 in a3a0a46
Every time I try to get a complete for the arguments of nix-store
, it causes the bash history to be filled with the contents of the script:
# ~/.bash_history
j n c
fish
git st
fish
bash
vi ~/.bash_history
ls
#!/bin/bash
COMP_WORDS=($COMP_LINE)
if [ "${COMP_LINE: -1}" = " " ]; then COMP_WORDS+=(""); fi
COMP_CWORD=$((${#COMP_WORDS[@]} - 1))
COMP_POINT=${#COMP_LINE}
# bash-completions
[ -f /data/data/com.termux/files/usr/share/bash-completion/bash_completion ] && source /data/data/com.termux/files/usr/share/bash-completion/bash_completion # termux
[ -f /usr/local/share/bash-completion/bash_completion ] && source /usr/local/share/bash-completion/bash_completion # osx
[ -f /usr/share/bash-completion/bash_completion ] && source /usr/share/bash-completion/bash_completion # linux
__load_completion "${COMP_WORDS[0]}"
$"$(complete -p "${COMP_WORDS[0]}" | sed -r 's/.* -F ([^ ]+).*/\1/')"
for i in "${COMPREPLY[@]}"; do if [[ -d "${i}" && "${i}" != */ ]]; then echo "${i}/"; else echo "${i}"; fi; done
#!/bin/bash
COMP_WORDS=($COMP_LINE)
if [ "${COMP_LINE: -1}" = " " ]; then COMP_WORDS+=(""); fi
COMP_CWORD=$((${#COMP_WORDS[@]} - 1))
COMP_POINT=${#COMP_LINE}
# bash-completions
[ -f /data/data/com.termux/files/usr/share/bash-completion/bash_completion ] && source /data/data/com.termux/files/usr/share/bash-completion/bash_completion # termux
[ -f /usr/local/share/bash-completion/bash_completion ] && source /usr/local/share/bash-completion/bash_completion # osx
[ -f /usr/share/bash-completion/bash_completion ] && source /usr/share/bash-completion/bash_completion # linux
__load_completion "${COMP_WORDS[0]}"
$"$(complete -p "${COMP_WORDS[0]}" | sed -r 's/.* -F ([^ ]+).*/\1/')"
for i in "${COMPREPLY[@]}"; do if [[ -d "${i}" && "${i}" != */ ]]; then echo "${i}/"; else echo "${i}"; fi; done
#~/.config/carapace/bridge/bash/.bashrc
export HISTFILE=/dev/null
> carapace --version
1.0.2
source <(/nix/store/3wrri355w1kdcd5rc0lg2jscq733hyy6-carapace-1.0.2/bin/carapace _carapace bash)
export CARAPACE_BRIDGES='fish,bash,zsh'
export CARAPACE_EXCLUDES='nix'
On NixOS, completions are often surfaced to bash
(and shells with compatible completers) via $XDG_DATA_DIRS. I tried to use nushell
with carapace
's bridge to bash
enabled, but none of these completions were found, since carapace
only looks in the directories listed here.
Contrast this with where bash
looks for completions, listed in the bash-completion
FAQ:
Q. What is the search order for the completion file of each target command?
A. The completion files of commands are looked up by the shell function
__load_completion
. Here, the search order in bash-completion >= 2.12 is
explained.
BASH_COMPLETION_USER_DIR
. The subdirectorycompletions
of each paths
inBASH_COMPLETION_USER_DIR
separated by colons is considered for a
completion directory.- The location of the main
bash_completion
file. The subdirectory
completions
in the same directory asbash_completion
is considered.- The location of the target command. When the real location of the command
is in the directory<prefix>/bin
or<prefix>/sbin
, the directory
<prefix>/share/bash-completion/completions
is considered.XDG_DATA_DIRS
(or the system directories/usr/local/share:/usr/share
if empty). The subdirectorybash-completion/completions
of each paths
inXDG_DATA_DIRS
separated by colons is considered.The completion files of the name
<cmd>
or<cmd>.bash
, where<cmd>
is
the name of the target command, are searched in the above completion
directories in order. The file that is found first is used. When no
completion file is found in any completion directories in this process, the
completion files of the name_<cmd>
is next searched in the completion
directories in order.
The relevant code in the bashrc
file is here.
It would be great if carapace
could look in all of these directories as well. I'm not familiar with go
, otherwise I'd just directly submit a PR. Do you have time to look into this? Otherwise I might try to figure this out myself some time later, and submit a PR, but that could take a while.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.