summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratyush Yadav <me@yadavpratyush.com>2020-01-04 21:08:03 (GMT)
committerPratyush Yadav <me@yadavpratyush.com>2020-01-04 21:08:03 (GMT)
commit0d2116c6441079a5a1091e4cf152fd9d5fa9811b (patch)
treec6d55a57b692d88df3a51a4b95940fdce829337b
parent23cbe427c44645a3ab0449919e55bade5eb264bc (diff)
parent786f4d24057b13184aaff8a5fa2d82a9c0180783 (diff)
downloadgit-0d2116c6441079a5a1091e4cf152fd9d5fa9811b.zip
git-0d2116c6441079a5a1091e4cf152fd9d5fa9811b.tar.gz
git-0d2116c6441079a5a1091e4cf152fd9d5fa9811b.tar.bz2
Merge branch 'zs/open-current-file'
Allow opening the currently selected file in its default app by clicking on its name. * zs/open-current-file: git-gui: allow opening currently selected file in default app
-rwxr-xr-xgit-gui.sh29
1 files changed, 24 insertions, 5 deletions
diff --git a/git-gui.sh b/git-gui.sh
index c1be733..f41ed2e 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2248,9 +2248,8 @@ proc do_git_gui {} {
}
}
-proc do_explore {} {
- global _gitworktree
- set explorer {}
+# Get the system-specific explorer app/command.
+proc get_explorer {} {
if {[is_Cygwin] || [is_Windows]} {
set explorer "explorer.exe"
} elseif {[is_MacOSX]} {
@@ -2259,9 +2258,23 @@ proc do_explore {} {
# freedesktop.org-conforming system is our best shot
set explorer "xdg-open"
}
+ return $explorer
+}
+
+proc do_explore {} {
+ global _gitworktree
+ set explorer [get_explorer]
eval exec $explorer [list [file nativename $_gitworktree]] &
}
+# Open file relative to the working tree by the default associated app.
+proc do_file_open {file} {
+ global _gitworktree
+ set explorer [get_explorer]
+ set full_file_path [file join $_gitworktree $file]
+ exec $explorer [file nativename $full_file_path] &
+}
+
set is_quitting 0
set ret_code 1
@@ -3513,9 +3526,11 @@ tlabel .vpane.lower.diff.header.file \
-justify left
tlabel .vpane.lower.diff.header.path \
-background gold \
- -foreground black \
+ -foreground blue \
-anchor w \
- -justify left
+ -justify left \
+ -font [eval font create [font configure font_ui] -underline 1] \
+ -cursor hand2
pack .vpane.lower.diff.header.status -side left
pack .vpane.lower.diff.header.file -side left
pack .vpane.lower.diff.header.path -fill x
@@ -3530,8 +3545,12 @@ $ctxm add command \
-type STRING \
-- $current_diff_path
}
+$ctxm add command \
+ -label [mc Open] \
+ -command {do_file_open $current_diff_path}
lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
+bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}
# -- Diff Body
#