File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ M.diff_commit_line = function()
74
74
attach_mappings = function (_ , map )
75
75
ags_mappings .open_diff_view_current_file_selected_commit (map )
76
76
ags_mappings .open_selected_commit_in_browser (map )
77
+ ags_mappings .copy_commit_hash_to_clipboard (map )
77
78
return true
78
79
end ,
79
80
})
@@ -98,6 +99,7 @@ M.search_log_content = function()
98
99
attach_mappings = function (_ , map )
99
100
ags_mappings .open_diff_view_current_file_selected_commit (map )
100
101
ags_mappings .open_selected_commit_in_browser (map )
102
+ ags_mappings .copy_commit_hash_to_clipboard (map )
101
103
return true
102
104
end ,
103
105
})
@@ -126,6 +128,7 @@ M.search_log_content_file = function()
126
128
attach_mappings = function (_ , map )
127
129
ags_mappings .open_diff_view_current_file_selected_commit (map )
128
130
ags_mappings .open_selected_commit_in_browser (map )
131
+ ags_mappings .copy_commit_hash_to_clipboard (map )
129
132
130
133
return true
131
134
end ,
@@ -151,6 +154,7 @@ M.diff_commit_file = function()
151
154
ags_mappings .open_diff_view_current_file_selected_commit (map )
152
155
ags_mappings .show_entire_commit (map )
153
156
ags_mappings .open_selected_commit_in_browser (map )
157
+ ags_mappings .copy_commit_hash_to_clipboard (map )
154
158
155
159
return true
156
160
end ,
Original file line number Diff line number Diff line change @@ -87,6 +87,25 @@ M.show_entire_commit = function(map)
87
87
omnimap (map , " <C-e>" , open_entire_commit )
88
88
end
89
89
90
+ ---- ---------------------------------------------------------------------------
91
+ local copy_commit_hash = function (_ )
92
+ local selection = action_state .get_selected_entry ()
93
+ local commit_hash = selection .opts .commit_hash
94
+ vim .notify (
95
+ " Copied commit hash " .. commit_hash .. " to clipboard" ,
96
+ vim .log .levels .INFO ,
97
+ { title = " Advanced Git Search" }
98
+ )
99
+
100
+ vim .fn .setreg (" +" , commit_hash )
101
+ vim .fn .setreg (" *" , commit_hash )
102
+ end
103
+
104
+ --- copy commit hash to clipboard with <C-y>
105
+ M .copy_commit_hash_to_clipboard = function (map )
106
+ omnimap (map , " <C-y>" , copy_commit_hash )
107
+ end
108
+
90
109
---- ---------------------------------------------------------------------------
91
110
local checkout = function (prompt_bufnr )
92
111
actions .close (prompt_bufnr )
You can’t perform that action at this time.
0 commit comments