Skip to content

Instantly share code, notes, and snippets.

@kidpixo
Last active July 15, 2022 04:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidpixo/e52277bec4717c93ea627394bce3c8e2 to your computer and use it in GitHub Desktop.
Save kidpixo/e52277bec4717c93ea627394bce3c8e2 to your computer and use it in GitHub Desktop.
Interactively search command options from man with fzf

MANOPT-FZF

Interactively search command options from man with fzf.

INSTALL

Copy manoptfzf.sh in $PATH and source it

manoptfzf() {
local dir
man $1 | sed -n "/^\s*-. /p" | fzf --preview "manopt $1 {1}"
}

This function accept a command name and calls manopt. I must use an extra function because fzf pass argument as single-quoted in --preview.

Copy in $PATH and make executable with chmod +x

fzf doesn't see my custom bash function in --preview, but an executable is fine.

whatis $1
man $1 | sed -n "/^\s*$2/,/^$/p"

EXAMPLE

manopt example gif

# copy in $PATH and make executable with chmod +x
# fzf don't grab my custom define function in --preview
whatis $1
man $1 | sed -n "/^\s*$2/,/^$/p"
View raw

(Sorry about that, but we can’t show files that are this big right now.)

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