╭ changed ──────────╮ │src/ui/CloneUrl.zig│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────╮ │1 const std = @import("std"); │ │2 +const builtin = @import("builtin");│ │3 const ui = @import("../ui.zig"); │ │4 const xit = @import("xit"); │ │5 const xitui = xit.xitui; │ ╰──────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │20 const Protocol = struct { │ │21 name: []const u8, │ │22 url: []const u8, │ │23 + copyable_text: []const u8, │ │24 }; │ │25 │ │26 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, identity: []const u8) !View {│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │28 var protocols: [2]Protocol = undefined; │ │29 var protocol_count: usize = 0; │ │30 if (session.data.clone_http_port) |port| { │ │31 + const url = try std.fmt.allocPrint(aa, "http://localhost:{d}/repo/{s}", .{ port, identity });│ │32 protocols[protocol_count] = .{ │ │33 .name = "http", │ │31 - .url = try std.fmt.allocPrint(aa, "http://localhost:{d}/repo/{s}", .{ port, identity }), │ │34 + .url = url, │ │35 + .copyable_text = try std.fmt.allocPrint(aa, "git clone {s}", .{url}), │ │36 }; │ │37 protocol_count += 1; │ │38 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │39 if (session.data.clone_ssh_port) |port| { │ │40 + const debug_prefix = "GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR' \\\r\n";│ │41 + const url = try std.fmt.allocPrint(aa, "ssh://localhost:{d}/repo/{s}", .{ port, identity }); │ │42 protocols[protocol_count] = .{ │ │43 .name = "ssh", │ │38 - .url = try std.fmt.allocPrint(aa, "ssh://localhost:{d}/repo/{s}", .{ port, identity }), │ │44 + .url = url, │ │45 + .copyable_text = try std.fmt.allocPrint(aa, "{s}git clone {s}", .{ if (builtin.mode == .Debug) debug_prefix else "", url }), │ │46 }; │ │47 protocol_count += 1; │ │48 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │133 .arrow_left => if (self.selected > 0) self.selected - 1 else return, │ │134 .arrow_right => if (self.selected + 1 < self.protocol_count) self.selected + 1 else return, │ │135 .enter => { │ │129 - if (self.session.is_terminal) self.session.host_request = .{ .show_url = self.protocols[self.selected].url }; │ │136 + if (self.session.is_terminal) self.session.host_request = .{ .show_copyable_text = self.protocols[self.selected].copyable_text };│ │137 return; │ │138 }, │ │139 .mouse => |mouse| blk: { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │141 if (inp.leftClickOn(root_focus, self.protocolLabel(i).getFocus().id, mouse)) break :blk i; │ │142 } │ │143 if (self.session.is_terminal and !mouse.ctrl and inp.leftClickOn(root_focus, self.urlInput().getFocus().id, mouse))│ │137 - self.session.host_request = .{ .show_url = self.protocols[self.selected].url }; │ │144 + self.session.host_request = .{ .show_copyable_text = self.protocols[self.selected].copyable_text }; │ │145 return; │ │146 }, │ │147 else => return, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯