From 2ab2c2255bc7ae65856890e36f17164ff5a4d2a1 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 25 Feb 2023 17:27:38 +0530 Subject: [PATCH] fish: functions: Make it easier to review code with difftool aliases If no arguments are provided to the git difftool aliases, just invoke it with the default `git difftool main...current-branch`. This is what we will use most of the time anyway as this is exactly the command needed when we want to review our own changes before pushing upstream or reviewing some other merge request. --- fish/.config/fish/functions/gdd.fish | 8 +++++++- fish/.config/fish/functions/gdk.fish | 8 +++++++- fish/.config/fish/functions/gdt.fish | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fish/.config/fish/functions/gdd.fish b/fish/.config/fish/functions/gdd.fish index d822aa9..6eaec01 100644 --- a/fish/.config/fish/functions/gdd.fish +++ b/fish/.config/fish/functions/gdd.fish @@ -1,3 +1,9 @@ function gdd --description "Use difftastic as a difftool" - git difftool --tool=difftastic $argv + if count $argv >/dev/null + git difftool --tool=difftastic $argv + else + set default (git symbolic-ref refs/remotes/origin/HEAD | awk -F'/' '{print $4}') + set current (git branch --show-current) + git difftool --tool=difftastic $default...$current + end end diff --git a/fish/.config/fish/functions/gdk.fish b/fish/.config/fish/functions/gdk.fish index da7df27..ba78ca8 100644 --- a/fish/.config/fish/functions/gdk.fish +++ b/fish/.config/fish/functions/gdk.fish @@ -1,3 +1,9 @@ function gdk - git difftool --tool=kitty $argv + if count $argv >/dev/null + git difftool --tool=kitty $argv + else + set default (git symbolic-ref refs/remotes/origin/HEAD | awk -F'/' '{print $4}') + set current (git branch --show-current) + git difftool --tool=kitty $default...$current + end end diff --git a/fish/.config/fish/functions/gdt.fish b/fish/.config/fish/functions/gdt.fish index 476c1de..d4c7781 100644 --- a/fish/.config/fish/functions/gdt.fish +++ b/fish/.config/fish/functions/gdt.fish @@ -1,3 +1,9 @@ function gdt - git --no-pager difftool $argv + if count $argv >/dev/null + git --no-pager difftool $argv + else + set default (git symbolic-ref refs/remotes/origin/HEAD | awk -F'/' '{print $4}') + set current (git branch --show-current) + git --no-pager difftool $default...$current + end end