ockam icon indicating copy to clipboard operation
ockam copied to clipboard

Explore if we can setup shell completion as part of install.sh

Open mrinalwadhwa opened this issue 1 year ago • 6 comments

https://github.com/build-trust/ockam/blob/develop/install.sh


We love helping new contributors! ❤️ If you have questions or need help as you explore, please join us on Discord. If you're looking for other issues to contribute to, please checkout our good first issues.

mrinalwadhwa avatar Sep 21 '23 16:09 mrinalwadhwa

More information on how to implement shell completion:

  • https://github.com/build-trust/ockam/pull/5690

nazmulidris avatar Sep 21 '23 17:09 nazmulidris

@mrinalwadhwa Hi! Please, could you clarify if the shell completion described in the following articles is the same referred to in this issue?

  1. How to create a Bash completion script
  2. Shell Auto Completion in Linux

If so, could I be assigned? I'd love to try my hand at this.

PS: The link to install.sh above is broken. Found it in the tools directory, though.

Wryhder avatar May 08 '24 18:05 Wryhder

@mrinalwadhwa Hi! Please, could you clarify if the shell completion described in the following articles is the same referred to in this issue?

  1. How to create a Bash completion script
  2. Shell Auto Completion in Linux

If so, could I be assigned? I'd love to try my hand at this.

PS: The link to install.sh above is broken. Found it in the tools directory, though.

@mrinalwadhwa Hi! Wanted to check if you've gotten a chance to check out my previous comment.

Wryhder avatar May 21 '24 18:05 Wryhder

@Wryhder sorry for the slow response. I've ben traveling.. I'll share some thoughts later today

mrinalwadhwa avatar May 21 '24 18:05 mrinalwadhwa

@Wryhder there's a detailed step on how to setup shell completion in this comment, Homebrew also has a writeup on how they setup bash completion https://docs.brew.sh/Shell-Completion. Here's how I will setup shell completion if it's only for zsh which I use In the install.sh script, I will

  • create a new function called install_autocomplete_zsh
  • Check if the ~/.zshrc file exist
  • Create a file $HOME/.ockam/autocomplete/zsh/_ockam which will contain the autocomplete commands
  • Add autocomplete path to zshrc
install_autocomplete_zsh() {
  mkdir $HOME/.ockam/autocomplete

  if [[ ! -f "~/.zshrc" ]]; then
     echo "system doesn't support zsh shell"
     return
  fi
  
  mkdir $HOME/.ockam/autocomplete/zsh
  ockam autocomplete zsh > $HOME/.ockam/autocomplete/zsh/_ockam 
  info "Adding autocomplete to zsh"
  echo >>"~/.zshrc"
  echo "FPATH="$HOME/.ockam/autocomplete/zsh:${FPATH}" >> "~/.zshrc"
  echo "autoload -Uz compinit" >> "~/.zshrc"
  echo "compinit" >> "~/.zshrc"
}

I hope this helps

metaclips avatar May 22 '24 09:05 metaclips

@Wryhder there's a detailed step on how to setup shell completion in this comment, Homebrew also has a writeup on how they setup bash completion https://docs.brew.sh/Shell-Completion. Here's how I will setup shell completion if it's only for zsh which I use In the install.sh script, I will

  • create a new function called install_autocomplete_zsh
  • Check if the ~/.zshrc file exist
  • Create a file $HOME/.ockam/autocomplete/zsh/_ockam which will contain the autocomplete commands
  • Add autocomplete path to zshrc
install_autocomplete_zsh() {
  mkdir $HOME/.ockam/autocomplete

  if [[ ! -f "~/.zshrc" ]]; then
     echo "system doesn't support zsh shell"
     return
  fi
  
  mkdir $HOME/.ockam/autocomplete/zsh
  ockam autocomplete zsh > $HOME/.ockam/autocomplete/zsh/_ockam 
  info "Adding autocomplete to zsh"
  echo >>"~/.zshrc"
  echo "FPATH="$HOME/.ockam/autocomplete/zsh:${FPATH}" >> "~/.zshrc"
  echo "autoload -Uz compinit" >> "~/.zshrc"
  echo "compinit" >> "~/.zshrc"
}

I hope this helps

@metaclips This helps a lot, thank you!

Wryhder avatar May 22 '24 19:05 Wryhder