Created
December 22, 2021 20:05
-
-
Save dominikb1888/87f396d8c8434fa284c91d17cdc2bd66 to your computer and use it in GitHub Desktop.
Create a horizontal split in vim for the same file in different branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function brdiff | |
| set -l paths | |
| for branch in (git branch -l | fzf -m | tr -d '[*+ ]') | |
| if [ $branch = "master" ] | |
| set -a paths $argv[1] | |
| else | |
| git worktree add "../$branch" | |
| set -a paths "../$branch/$argv[1]" | |
| end | |
| end | |
| echo $paths | |
| vim -O $paths | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only works if master is checked out in the current git folder. New worktrees will be generated in parent folder.
TODO:
An improved version would probably check out a new bare repo first and then do add the worktrees.