From 8849a1f2774856c99cbc86bbabcd6b97f0593fab Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Thu, 9 Feb 2023 19:34:04 +0000 Subject: [PATCH] chore(shell): change the layout of fzf commands This is to keep things consistent with how I have ivy.nvim working in vim. All fuzzy finding is now done at the bottom of the terminal with the preview on top. This prevents the eyes to jumping up and down and keep the focus to the bottom of the terminal. --- site-modules/core/files/oh-my-zsh/custom/fzf.zsh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/site-modules/core/files/oh-my-zsh/custom/fzf.zsh b/site-modules/core/files/oh-my-zsh/custom/fzf.zsh index 4148e42..a07bd51 100644 --- a/site-modules/core/files/oh-my-zsh/custom/fzf.zsh +++ b/site-modules/core/files/oh-my-zsh/custom/fzf.zsh @@ -10,13 +10,13 @@ # Edit commands with file previews using `fd` to search files to exclude files # to improve performance # -alias fe="vim \"\$(FZF_DEFAULT_COMMAND=\"fd -t f\" fzf --layout=reverse --preview 'bat --style=numbers ---color=always {}')\"" +alias fe="vim \"\$(FZF_DEFAULT_COMMAND=\"fd -t f\" fzf --preview-window=top:70% --preview 'bat --style=numbers ---color=always {}')\"" # # cd in to a porject directory # fp() { - cd ~/Code/src/$(cd ~/Code/src && FZF_DEFAULT_COMMAND="fd -t d --exact-depth 3" fzf --layout=reverse --preview 'bat --style=numbers ---color=always {}/README.md') + cd ~/Code/src/$(cd ~/Code/src && FZF_DEFAULT_COMMAND="fd -t d --exact-depth 3" fzf --preview-window=top:70% --preview 'bat --style=numbers ---color=always {}/README.md') } # # Searching the git history with diff and show preview support. When selecting a @@ -44,11 +44,16 @@ fshow() { done } +fl() { + local format="%C(red)%h%Creset %s %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset" + FZF_DEFAULT_COMMAND="git log --color=always --format=\"$format\"" fzf --preview-window=top:70% --ansi --preview 'git show --color=always {1}' +} + # # Checkout a git branch in a fzf context # fco() { - git checkout "$(git branch -vl | fzf --layout=reverse | awk '{print $1}')" + git checkout "$(git branch -vl | fzf | awk '{print $1}')" } #