racket-rash
racket-rash copied to clipboard
terminal title with current directory
I'm currently doing this:
(define old-prompt (current-prompt-function))
(define (my-prompt #:last-return-value [last-ret #f]
#:last-return-index [last-ret-n 0])
(printf "\033]0;~a\007" (path->string (current-directory)))
(old-prompt)
)
(current-prompt-function my-prompt)
Are you suggesting that the default prompt should change the terminal title bar to include the current directory?
If so, I'm interested. The most difficult part about this is that it's terminal-dependent. I think most terminal emulators support this feature, but there are multiple different codes for doing it. I think they all use OSC codes (IE \033]<some number>;<some text><string terminator>
), but eg. xterm uses 0 for the OSC code while KDE Konsole (the main terminal emulator I use at the moment) uses 30 instead. I'm not sure what a good way to detect this is.
Also I'll note that if you don't pass those keyword arguments on to old-prompt
you will have a degraded experience, particularly when running Racket code (top level s-expressions or pipelines that end with something other than a subprocess). It's actually the prompt handler that prints results for those.