I'm creating an scp-tui but I can't get terminal colors to work, I need them because I have to differenciate folders from files. When I call the command ls it returns only the string with the list of the files without colors. How can I get it working?
session, err := sshClient.NewSession()
handleError(err)
defer session.Close()
// Set up terminal modes
modes := ssh.TerminalModes{
ssh.ECHO: 0, // disable echoing
ssh.ECHOCTL: 0,
ssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
ssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
}
err = session.RequestPty("xterm", 80, 40, modes)
handleError(err)
var output []byte
output, err = session.Output("ls")
fmt.Printf("output: %v\n", output)
return string(output), err
P.S. Are there better ways to get a list of files and folders of the current directory?
Update: I temporarely resolved the issue by executing two distinct commands to get first the files and then the directories.