Skip to content

Commit

Permalink
fix: unix completions
Browse files Browse the repository at this point in the history
  • Loading branch information
pxseu committed Sep 30, 2022
1 parent 80611b6 commit 224cadf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/commands/update/util.rs
Expand Up @@ -212,36 +212,36 @@ pub async fn create_completions_commands(
exe_path: PathBuf,
) {
let command = format!(
"mkdir -p /usr/share/zsh/site-functions && {} completions zsh > /usr/share/zsh/site-functions/_hop 2> /dev/null && chmod 644 /usr/share/zsh/site-functions/_hop",
"&& mkdir -p /usr/share/zsh/site-functions && {} completions zsh > /usr/share/zsh/site-functions/_hop 2> /dev/null && chmod 644 /usr/share/zsh/site-functions/_hop",
exe_path.display()
);

if is_writable(&PathBuf::from("/usr/share/zsh/site-functions/_hop")).await {
non_elevated_args.extend(["&&", command]);
non_elevated_args.push(command.into());
} else {
elevated_args.extend(["&&", command]);
elevated_args.push(command.into());
};

let command = format!(
"mkdir -p /usr/share/fish/completions && {} completions fish > /usr/share/fish/completions/hop.fish 2> /dev/null && chmod 644 /usr/share/fish/completions/hop.fish",
"&& mkdir -p /usr/share/fish/completions && {} completions fish > /usr/share/fish/completions/hop.fish 2> /dev/null && chmod 644 /usr/share/fish/completions/hop.fish",
exe_path.display()
);

if is_writable(&PathBuf::from("/usr/share/fish/completions/hop.fish")).await {
non_elevated_args.extend(["&&", command]);
non_elevated_args.push(command.into());
} else {
elevated_args.extend(["&&", command]);
elevated_args.push(command.into());
};

let command = format!(
"mkdir -p /usr/share/bash-completion/completions && {} completions bash > /usr/share/bash-completion/completions/hop 2> /dev/null && chmod 644 /usr/share/bash-completion/completions/hop",
"&& mkdir -p /usr/share/bash-completion/completions && {} completions bash > /usr/share/bash-completion/completions/hop 2> /dev/null && chmod 644 /usr/share/bash-completion/completions/hop",
exe_path.display()
);

if is_writable(&PathBuf::from("/usr/share/bash-completion/completions/hop")).await {
non_elevated_args.extend(["&&", command]);
non_elevated_args.push(command.into());
} else {
elevated_args.extend(["&&", command]);
elevated_args.push(command.into());
};
}

Expand Down

0 comments on commit 224cadf

Please sign in to comment.