Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fzf Enhancements #5

Open
5 tasks
ninmonkey opened this issue Jan 3, 2022 · 0 comments
Open
5 tasks

Fzf Enhancements #5

ninmonkey opened this issue Jan 3, 2022 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ninmonkey
Copy link
Owner

ninmonkey commented Jan 3, 2022

reload action/event

built in hotkeys

Preview

# {} is replaced with the single-quoted string of the focused line
fzf --preview 'cat {}'
fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'
fzf --height 40% --layout reverse --info inline --border \
    --preview 'file {}' --preview-window up,1,border-horizontal \
    --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,preview-bg:#223344,border:#778899'

Using Ignore

# Feed the output of fd into fzf
fd --type f | fzf

# Setting fd as the default source for fzf
export FZF_DEFAULT_COMMAND='fd --type f'

# Now fzf (w/o pipe) will use fd instead of find
fzf

# To apply the command to CTRL-T as well
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

Examples

# todo: also set default FD env vars, making this query simpler
fd | 
fzf.exe --bind 'ctrl-d:reload(fd -t d),ctrl-f:reload(fd -t f)'

https://github.com/junegunn/fzf#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f

[0] execute external background process

# Press F1 to open the file with less without leaving fzf
# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)
fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'```

### [1] reload list of processes (or newest logs)

```ps1
FZF_DEFAULT_COMMAND='ps -ef' \
  fzf --bind 'ctrl-r:reload($FZF_DEFAULT_COMMAND)' \
      --header 'Press CTRL-R to reload' --header-lines=1 \
      --height=50% --layout=reverse

[2] toggle modes, inline, using hotkeys

FZF_DEFAULT_COMMAND='find . -type f' \
  fzf --bind 'ctrl-d:reload(find . -type d),ctrl-f:reload($FZF_DEFAULT_COMMAND)' \
      --height=50% --layout=reverse

[3] interactive ripgrep

INITIAL_QUERY=""
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
  fzf --bind "change:reload:$RG_PREFIX {q} || true" \
      --ansi --disabled --query "$INITIAL_QUERY" \
      --height=50% --layout=reverse

Links

@ninmonkey ninmonkey added the enhancement New feature or request label Jan 3, 2022
@ninmonkey ninmonkey self-assigned this Jan 3, 2022
@ninmonkey ninmonkey added the documentation Improvements or additions to documentation label Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant