awesome-bashrc icon indicating copy to clipboard operation
awesome-bashrc copied to clipboard

Add a command to exact search through your aliases

Open mohitkyadav opened this issue 2 years ago • 0 comments

@aashutoshrathi following func is what I use, but as you can see it only reads the .zshrc file. We can check for the shell and determine where to look. I was also 🤔 if it's possible to check the self file name? If so same function could be used in any number of rc files.

cmdmatch () {
  # --help
  if [[ $1 == '--help' ]]; then
    echo "Usage: cmdmatch <pattern>";
    return 0;
  fi

  # Return matching aliases
  grep "alias" ~/.zshrc | grep "$1";

  # error if no arguments
  if [ $# -eq 0 ]; then
    echo "No arguments supplied"
    return 1
  fi
}

mohitkyadav avatar May 12 '22 18:05 mohitkyadav