Coder Social home page Coder Social logo

fzf-git.sh's Introduction

I develop and maintain open-source projects that boost developer productivity.

If you like my work, you can support me on GitHub Sponsors.

Many thanks. Take care and stay safe.

fzf-git.sh's People

Contributors

cohml avatar hxlhxl avatar jobin-nelson avatar jpalus avatar junegunn avatar mathieu-lemay avatar ndegory avatar ptzz avatar raine avatar sakamossan avatar stoyandimov avatar timsu92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fzf-git.sh's Issues

Option to configure git-dir and work-tree

Thanks for the amazing work!

I want to use this with the dotfiles for which I have and alias config which runs git with preset git-dir and work-tree.

I am looking for options to somehow use this program with dotfiles.

I can think of passing GIT_COMMAND to the functions and have another key bind say ALT-G{KEY}.

Let me know your thoughts.

Incompatibility with XQuartz

Thank you for fzf and for this Git key binding, your work is amazing.

Following the instructions, after sourcing fzf-git.sh

1. Source [fzf-git.sh](https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh) file from your .bashrc or .zshrc
it stopped macOs XQuartz application from loading.

Reading through XQuartz/XQuartz#325, I did not find shift in fzf-git.sh but couldn't track what causes it to make XQuartz fail to start.

Help wanted: CTRL-G CTRL-H keybinding conflicts with tmux

Hello! Thanks for the great plugin.

I know this is more related to zsh or zsh keybinding rather than fzf-git per se, but I'm asking for help because many of the users may run into the same problem.

CTRL-G CTRL-H for commit Hashes do not work in my environment, because it conflicts with CTRL-H mappings:

❯❯❯ bindkey    # (excerpt)
"^G" fzm
"^G^H" fzf-git-hashes-widget
"^H" backward-delete-char

I pressed ^G^H within the KEYTIMEOUT limit (40 ms) but in this case the fzf-git widget does not appear. However, ^G H or other keys (e.g., ^G ^S) works fine. In a similar vein, ^G ^E seems conflicting with ^E (end-of-line) but ^G ^E works OK. Any idea why ^G ^H is not working for me?

This SuperUser thread seems relevant, but there is no working solution posted there (KEYTIMEOUT does not work).

zsh: zsh 5.9 (arm-apple-darwin21.3.0)

Space character in filename causes git files preview error

The "git files" preview command uses {-1} which creates an issue if the filename has space characters in it. e.g. if filename is "two words" then {-1} will return words"

I tried fixing this by 1. using {2..} which skips the git status flag and 2. piping the output of "git ls-files" to sed 's/"\(.*\)"$/\1/' in order to remove the double-quotes from filenames. For example if git status is
M "two words" then the sed command will give M two words and then {2..} should give two words. Then the preview command should work because it adds its own single quote.

Other options I looked at is git ls-files -z but I don't know how to send that to fzf

chars in last preview exists in the next

Version

  • fzf: 0.33.0 installed using Git
  • fzf-git.sh: commit e44dfb3
  • bat: 0.21.0 installed using bat_0.21.0_amd64.deb
  • OS: Ubuntu 22.04.1 LTS on WSL2
  • Terminal: Windows Terminal

Step to reproduce

  1. ctrl-G ctrl-F
  2. Move cursor onto a file which has words long enough in the preview window.
  3. Move cursor onto another file whose preview produced by bat overlaps in terminal with the output of last file.

expected behavior

Preview of the "another file" only

actual behavior

  • In the header and footer of bat's production, it shows the preview result of last file if the header is shorter in width. Plus, the char before "File" and "Size" is doing the same.
  • In the content of the newly previewing file, there are two spaces in each line locates between the gridline differentiating line number and content and content. And the first space shows whatever it was in the last preview.

first file

image

"another file"

image

Keybindings do not work in case one uses zsh-vi-mode plugin

Hi,
thank you for creating this amazing tool: fzf has been an absolute game-changer for me.

I had trouble in making the keybindings of fzf-git work after having installed zsh-vi-mode plugin.
I solved this issue by re-creating the keybindings according to what is advised in the zsh-vi-mode README, namely by doing:

# Set keybindings for zsh-vi-mode insert mode
function zvm_after_init() {
    zvm_bindkey viins "^P" up-line-or-beginning-search
    zvm_bindkey viins "^N" down-line-or-beginning-search
    for o in files branches tags remotes hashes stashes each_ref; do
        eval "zvm_bindkey viins '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey viins '^g${o[1]}' fzf-git-$o-widget"
    done
}
# Set keybindings for zsh-vi-mode normal and visual modes
function zvm_after_lazy_keybindings() {
    for o in files branches tags remotes hashes stashes each_ref; do
        eval "zvm_bindkey vicmd '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey vicmd '^g${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g^${o[1]}' fzf-git-$o-widget"
        eval "zvm_bindkey visual '^g${o[1]}' fzf-git-$o-widget"
    done
}

I guess there is nothing to do from your side, maybe you could consider adding a little statement on the README.

Thanks.

Keybings macOS

It appears no keybinds work in my macOS Ventura 13.3, or maybe I'm doing something wrong.

Is it supposed to work on macOS or separate PR is needed?

macOS does not like readlink -f

description

  • sourcing the script results in readlink: illegal option
  • a stackoverflow post suggests the following
brew install coreutils

greadlink -f ...

GIF

them

course of action

Maybe add a note for macOS users.

when I source fzf-git.sh in zsh, it exits with exitcode=1

If I put:

source $HOME/path/to/fzf-git.sh/fzf-git.sh

I can't even open a shell because it exist immediately:

$ source $HOME/rc.arch/bz/thirdparty/fzf-git.sh/fzf-git.sh
$ echo $?
1

but it works with bash.
my versions:

Ubuntu 22.04.1 LTS
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

→ git show --summary
commit d9c0458ba0a32560e7df6ee202555d5247705207 (HEAD -> main, origin/main, origin/HEAD)
Author: Junegunn Choi <[email protected]>
Date:   Wed Aug 24 13:11:25 2022 +0900

    Use ALT-{A,E} instead of CTRL-{A,E}
    
    Aren't we all too used to using CTRL-A and CTRL-E to move cursor around?

Key-bindings for bash do not work in vi mode

on pressing the key bind the function name is entered in the prompt and the shell goes from insert mode to normal mode.
e.g. _fzf_git_branches is put when I press Ctrl+G + Ctrl+B in insert mode.
and nothing happens when trying keybinds in normal mode (which is expected i guess)

invalid preview window option: right,50%,border-left

image

after sourcing, hitting shortcut keys gives me:

invalid preview window option: right,50%,border-left

Here is all settings related to fzf:

$ cat ~/.config/bash.d/fzf.bash
# Setup fzf
# ---------
if [[ ! "$PATH" == *$HOME/.local/fzf/bin* ]]; then
  export PATH="${PATH:+${PATH}:}$HOME/.local/fzf/bin"
  export FZF_DEFAULT_COMMAND="rg --files"
  export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {} 2>/dev/null'"
fi

# Auto-completion
# ---------------
[[ $- == *i* ]] && source "$HOME/.local/fzf/shell/completion.bash" 2> /dev/null

# Key bindings
# ------------
source "$HOME/.local/fzf/shell/key-bindings.bash"

[WSL] Open in browser does not work

I am using bash with vi mode, in wsl and $BROWSER env variable is set.
When I press Ctrl+O, nothing happens, I also treid changing BROWSER to vim and still nothing changed.

Keybindings not working for vi command mode

After sourcing the plugin, the ^G^* keybindings work for emacs and viins modes. However the widgets aren't bound to anything in vicmd mode.

Fundamentally, this is because the zsh version of __fzf_git_init doesn't explicitly specify a mode for bindkey, which for vi mode users means all keybindings default to viins.

To fix this, minimally -M vicmd must be specified in its own call to bindkey.

Possibly related to #23. Nvm, I don't think so.

Question: how is this supposed to work?

Are the bindings supposed to immediately open a tmux window or are they supposed to add, eg, _fzf_git_hashes to the command line and to be run as a part of the command?

I get the later behavior but expected the former.

Ctrl-g Ctrl-s keybinding does not work if flow control is active

This is expected, but since that is the default keybinding to open _fzf_git_stashes, it'll likely cause a bad user experience since the screen freeze if flow control is active, until the user hits Ctrl-q.

Maybe consider a different keybinding or tell people to disable flow control in the README?

Hashes from any branch?

Thanks so much for making these tools - fzf has long become an invaluable tool in my daily workflow!

Quick question: Is there a streamlined way to search for hashes from branches that aren't currently checked out? I often find myself doing something along the following lines:

git log [options] <feature_branch>  # manually find commit in <feature_branch>
git cherry-pick <hash>

I am aware that I can pipe the git log <branch> output to fzf and then use sed or awk to get the hash. But this is duplicating much of what _fzf_git_hashes is doing. So I was wondering if there's an easy way to leverage _fzf_git_hashes in its current form? Alternatively, would it be hard to add a binding to _fzf_git_hashes to select a branch and then reload git log for that branch?

Open-in-browser results in 404 when target file not in root dir

When opening a file in a browser from a repository sub-folder (CTRL-G CTRL-F and CTRL-O) the browser shows GitHub's 404 page because the file path is not included.

Expected:

  • Navigate to a sub-folder inside the repo
  • C-G C-F select a file
  • C-O to open selected file in GitHub
  • See the file in GitHub

Actual:

  • Navigate to a sub-folder inside the repo
  • C-G C-F select a file
  • C-O to open selected file in GitHub
  • See GitHub's 404 page

sh: 1: Syntax error: redirection unexpected

I keep getting sh: 1: Syntax error: redirection unexpected on the preview window this on a docker container when using _fzf_git_branches.

I tracked this down to to

$(sed s/^..// <<< {} | cut -d" " -f1)

Changing it with

$(echo {} | sed s/^..// | cut -d" " -f1) works

Any idea why?

Add colorless mode

Hi! Great stuff.

Some people are not that great with colors. Can a mode without git colors be added please?
I am specifically talking about things like:

  • git branch "$@" --sort=-committerdate --sort=-HEAD --format=$'%(HEAD) %(color:yellow)%(refname:short) %(color:green)(%(committerdate:relative))\t%(color:blue)%(subject)%(color:reset)' --color=always | column -ts$'\t'
  • git for-each-ref --sort=-creatordate --sort=-HEAD --color=always --format=$'%(refname) %(color:green)(%(creatordate:relative))\t%(color:blue)%(subject)%(color:reset)' |
  • git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always "$@"

I would propose to add a setting called FZF_GIT_NO_COLOR=true to disable these colors :)
Would you accept a PR like this?

Preview window does not see $GIT_DIR nor $GIT_WORK_TREE

When setting $GIT_DIR and $GIT_WORK_TREE as it is common for working on bare repositories, all commands work ,but the preview windows will display Warning: Not a git repository, fatal: not a git repository or similar messages.
image

_fzf_git_hashes depends on awk implementation

It appears that interval expressions ({<n>,<m>} as in /[a-f0-9]{7,}/) in AWK's regular expressions are somewhat fuzzy subject. Newer versions of gawk support it by default, older versions of gawk require additional option, mawk does not support them. Also see: https://www.gnu.org/software/gawk/manual/html_node/Interval-Expressions.html

In my system awk points to mawk hence hashes do not work. Would it be possible to either:

  1. Replace this single regex with /[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*/ so it's compatible with all awk implementations (preferably)
  2. Or use gawk command instead of awk and require gawk >= 4.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.