feat(ansi): support OSC 7 notify working directory#274
feat(ansi): support OSC 7 notify working directory#274aymanbagabas merged 8 commits intocharmbracelet:mainfrom
Conversation
aymanbagabas
left a comment
There was a problem hiding this comment.
Is there any documentation or references about this sequence?
Not super formally documented, but I've made a round-up of terminals supporting For formal documentation specifically:
There's also this blog article I've come across documenting the escape sequence. |
No worries, I would just include the iterm2 and wezterm links in the code comments. |
Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Done in 52210b9, how's that look? |
Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
aymanbagabas
left a comment
There was a problem hiding this comment.
Looks good! Could you please update the imports and format the file using gofumpt?
Done! BTW if you want to see this in action for yourself, I wrote this quick script that should let you Ctrl/Cmd+Click the ../main.go path (tested with VSCode and iTerm2) if you place it at the root of the repo and run it with package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"github.com/charmbracelet/x/ansi"
)
func main() {
_, filename, _, ok := runtime.Caller(0)
if !ok {
panic("no caller")
}
dir := filepath.Dir(filename)
fmt.Println("changing cwd OSC 7 to " + dir)
fmt.Printf(ansi.NotifyWorkingDirectory("localhost", dir, "ansi"))
fmt.Println("../main.go:13:5: error: use of undeclared identifier 'sdfsfds'")
termProgram := os.Getenv("TERM_PROGRAM")
if termProgram == "vscode" {
fmt.Println("Hello, VSCode needs an extra line for some reason (don't need this for iTerm2)")
}
} |
|
Thank you, @rzhw! This will be included in ansi/v0.5.2 |
Background: charmbracelet/sequin#24