-
Notifications
You must be signed in to change notification settings - Fork 44
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
Bash window title #171
Comments
I think this is terminal+shell dependent and it is not actionable on the binenv side. |
Ok I get it. func SetProcessName(name string) error {
argv0str := (*reflect.StringHeader)(unsafe.Pointer(&os.Args[0]))
argv0 := (*[1 << 30]byte)(unsafe.Pointer(argv0str.Data))[:argv0str.Len]
n := copy(argv0, name)
if n < len(argv0) {
argv0[n] = 0
}
return nil
} Will check this. |
After taking a third look at this, the above solution won't work, since it has to be made in the binary itself, something we of course do not control. The only way I see is to change binaries layout, and instead of having binaries in the distribution name like this:
we could use another directory level using version, and a properly name binary inside like so:
|
There is an ANSI escape code for changing the terminal emulators window title: package ansititle
import (
"bytes"
"errors"
"os"
"golang.org/x/crypto/ssh/terminal"
)
func Write(title []byte) error {
fd := os.Stdout.Fd()
if !terminal.IsTerminal(int(fd)) {
return errors.New("not a TTY")
}
_, err := os.Stdout.Write(formatTitle(title))
return err
}
func formatTitle(title []byte) []byte {
if len(title) == 0 {
return nil
}
title = sanatise(title)
ansi := make([]byte, len(title)+5)
copy(ansi[0:4], []byte{27, ']', '0', ';'})
copy(ansi[4:len(title)+4], title)
ansi[len(ansi)-1] = 7
return ansi
}
func sanatise(b []byte) []byte {
b = bytes.ReplaceAll(b, []byte{'\r'}, nil)
// replace all control characters with space
for i := range b {
if b[i] < 32 || b[i] == 127 {
b[i] = 32
}
}
return b
} (adapted from: https://github.com/lmorg/murex/tree/master/utils/ansititle) The issue is while some terminal emulators seems to honour this, Konsole by default does not. That's up to the user to change in their tab settings (I've not found a way to force change that myself). However you can query what the tab title format is with this command:
|
@jgournet thanks fo the report but, as you can see, I have very little time for the project right now. Since this is not critical, I'd rather set it aside for now if that's ok. If someone wants to handle this, I'd be glad to review PRs. |
Hi there,
It's really low priority, as it's cosmetic and highly dependent on configuration, but just wanted to mention:
I'm using "Konsole", and by default, the bash window title is "folder : software_running"
When launching any application installed via binenv, I get: "folder : software_version"
=> is there a way to change binenv so it would reflect the software running ?
The text was updated successfully, but these errors were encountered: