mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
use .bash as extension for bash completions
* bash-completions have code to use only `foo`, `foo.bash` and `_foo` files for completion * /usr is proper place for system-wide stuff rather than /etc Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
This commit is contained in:
parent
c2c2a56a30
commit
bfcf5dd076
4 changed files with 7 additions and 7 deletions
|
@ -383,11 +383,11 @@ Unix and similar operating systems (such as GNU/Linux).
|
|||
|
||||
BASH:
|
||||
|
||||
Completion files are commonly stored in `/etc/bash_completion.d/`
|
||||
Completion files are commonly stored in `/usr/share/bash-completion/completions`
|
||||
|
||||
Run the command:
|
||||
|
||||
`rustup completions bash > /etc/bash_completion.d/rustup.bash-completion`
|
||||
`rustup completions bash > /usr/share/bash-completion/completions/rustup.bash`
|
||||
|
||||
This installs the completion script. You may have to log out and log
|
||||
back in to your shell session for the changes to take affect.
|
||||
|
|
|
@ -1375,9 +1375,9 @@ impl<'a, 'b> App<'a, 'b> {
|
|||
/// outdir); // Then say where write the completions to
|
||||
/// }
|
||||
/// ```
|
||||
/// Now, once we compile there will be a `{bin_name}.bash-completion` file in the directory.
|
||||
/// Now, once we compile there will be a `{bin_name}.bash` file in the directory.
|
||||
/// Assuming we compiled with debug mode, it would be somewhere similar to
|
||||
/// `<project>/target/debug/build/myapp-<hash>/out/myapp.bash-completion`.
|
||||
/// `<project>/target/debug/build/myapp-<hash>/out/myapp.bash`.
|
||||
///
|
||||
/// Fish shell completions will use the file format `{bin_name}.fish`
|
||||
pub fn gen_completions<T: Into<OsString>, S: Into<String>>(&mut self,
|
||||
|
@ -1419,7 +1419,7 @@ impl<'a, 'b> App<'a, 'b> {
|
|||
/// Usage:
|
||||
///
|
||||
/// ```shell
|
||||
/// $ myapp generate-bash-completions > /etc/bash_completion.d/myapp
|
||||
/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
|
||||
/// ```
|
||||
pub fn gen_completions_to<W: Write, S: Into<String>>(&mut self,
|
||||
bin_name: S,
|
||||
|
|
|
@ -114,7 +114,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
let out_dir = PathBuf::from(od);
|
||||
let name = &*self.meta.bin_name.as_ref().unwrap().clone();
|
||||
let file_name = match for_shell {
|
||||
Shell::Bash => format!("{}.bash-completion", name),
|
||||
Shell::Bash => format!("{}.bash", name),
|
||||
Shell::Fish => format!("{}.fish", name),
|
||||
Shell::Zsh => format!("_{}", name),
|
||||
Shell::PowerShell => format!("_{}.ps1", name),
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::fmt;
|
|||
#[cfg_attr(feature = "lints", allow(enum_variant_names))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Shell {
|
||||
/// Generates a .bash-completion completion file for the Bourne Again SHell (BASH)
|
||||
/// Generates a .bash completion file for the Bourne Again SHell (BASH)
|
||||
Bash,
|
||||
/// Generates a .fish completion file for the Friendly Interactive SHell (fish)
|
||||
Fish,
|
||||
|
|
Loading…
Reference in a new issue