Skip to content

Instantly share code, notes, and snippets.

@EvanLovely
Created September 4, 2013 18:36
Show Gist options
  • Select an option

  • Save EvanLovely/6440960 to your computer and use it in GitHub Desktop.

Select an option

Save EvanLovely/6440960 to your computer and use it in GitHub Desktop.
Bash Function to search through your Bash Aliases and Functions and display helpful text in the prompt.
# search bash aliases
sba() {
cat ~/.bash_aliases | grep -i -A 1 "^#.*$*"
cat ~/.bash_aliases | grep -i -B 1 "^alias.*$*"
cat ~/.bash_functions | grep -i -A 1 "^#.*$*"
}
@EvanLovely

Copy link
Copy Markdown
Author

I would like it to work when I have several under a header like this:

# ls better
alias la="ls -aF"
alias ld="ls -ld"
alias ll="ls -l"
alias lt='ls -At1 && echo "------Oldest--"'
alias ltr='ls -Art1 && echo "------Newest--"'

Hat tip to Brett Terpstra for some of the aliases

@EvanLovely

Copy link
Copy Markdown
Author

I would also like it if one could retrieve multi-line comments before a function/alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment