-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copying committed file name crashes if running lazygit through ssh #1055
Comments
I'm not able to replicate this on mac. Do you have the stack trace handy? |
I am now using this version: stackTrace:
|
I wonder if the machine you've ssh'd onto lacks the required utilities to copy to clipboard. I also wonder how clipboard stuff generally works when dealing with ssh. |
It requires |
It would be great if there had a custom config property to say to lazygit how to copy to the clipboard. os:
copyShaCommitToClipboard: ssh user@my-machine 'echo "${commit}" | pbcopy' |
^ +1. OSC52 is my preferred way of copying. Would be great to have a config option to use this. |
This should be easy to implement, just a matter of going to diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index 78dad7a8e..f51539a78 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -267,6 +267,14 @@ func (c *OSCommand) CopyToClipboard(str string) error {
escaped := strings.Replace(str, "\n", "\\n", -1)
truncated := utils.TruncateWithEllipsis(escaped, 40)
c.LogCommand(fmt.Sprintf("Copying '%s' to clipboard", truncated), false)
+
+ if c.UserConfig.OS.CopyToClipboard != "" {
+ cmdStr := utils.ResolvePlaceholderString(c.UserConfig.OS.CopyToClipboard, map[string]string{
+ "text": c.Cmd.Quote(str),
+ })
+ return c.Cmd.NewShell(cmdStr).Run()
+ }
+
return clipboard.WriteAll(str)
} The CopyToClipboard key can be defined in Then it's a matter of updating the docs in I'll chuck a good-first-issue label on this. Do either of you want to take this on @mestihudson @redstreet ? |
You pretty much included the whole code there (thank you!), and I wish I could do this, but I've never worked with Go, or with docker, so I'm unlikely to be able to find the time to set myself up adequately :(. I'll offer this proposal instead, if someone else is interested in considering it:
Update: the simpler solution is to include the command to do an OSC52 copy in the doc. |
Just noticed the Github Codespaces in CONTRIBUTING. Cool. Let me take a shot at this. |
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
Issue jesseduffield#1055 test: CopyPatchToClipboard (temporary commit for review)
I am using a terminal emulator that supports OSC52, am SSHing into a computer and am inside of a tmux session. The given example of using OSC52 doesn't seem to work, does anyone know why? I assume its something not related to lazygit, but just wondering if anyone else has ran into this. My workaround is to use ssh, but that doesn't work when I'm actually on the computer os:
copyToClipboardCmd: "echo {{text}} | ssh \"mitchell@$(echo $SSH_CONNECTION | awk '{ print $1}')\" pbcopy" |
Describe the bug
Copying committed file name crashes if running lazygit through ssh.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The name of the committed name should be copied.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: