Skip to content

Commit

Permalink
Add man function for aiding in viewing manpages
Browse files Browse the repository at this point in the history
Some commands, such as shell builtins, don't have their own manpage, so
this function helps mitigate this issue.
  • Loading branch information
Pinjasaur committed Oct 8, 2017
1 parent 271eadc commit 8ede3f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ up() {
cd $ups
}

# `man` that supports shell builtins
# Source: https://unix.stackexchange.com/a/18088
man() {
case "$(type -t "$1"):$1" in
# built-in
builtin:*) help "$1" | "${PAGER:-less}";;
# pattern
*[[?*]*) help "$1" | "${PAGER:-less}";;
# something else, presumed to be an external command or options for the man
# command or a section number
*) command -p man "$@";;
esac
}

# Get the weather
wttr() {
# If no $1, use the zip code from our IP
Expand Down

0 comments on commit 8ede3f7

Please sign in to comment.