forked from TrueCloudLab/rclone
cmd: add --progress-terminal-title to print ETA to terminal title
Adds a flag, --progress-terminal-title, that when used with --progress, will print the string `ETA: %s` to the terminal title. This also adds WriteTerminalTitle to lib/terminal
This commit is contained in:
parent
6dc28ef50a
commit
aac2406e19
8 changed files with 33 additions and 0 deletions
|
@ -60,6 +60,9 @@ const (
|
|||
HiMagentaBg = "\x1b[105m"
|
||||
HiCyanBg = "\x1b[106m"
|
||||
HiWhiteBg = "\x1b[107m"
|
||||
|
||||
ChangeTitle = "\033]0;"
|
||||
BEL = "\007"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
@ -29,3 +30,8 @@ func IsTerminal(fd int) bool {
|
|||
func ReadPassword(fd int) ([]byte, error) {
|
||||
return terminal.ReadPassword(fd)
|
||||
}
|
||||
|
||||
// WriteTerminalTitle writes a string to the terminal title
|
||||
func WriteTerminalTitle(title string) {
|
||||
fmt.Printf(ChangeTitle + title + BEL)
|
||||
}
|
||||
|
|
|
@ -21,3 +21,8 @@ func IsTerminal(fd int) bool {
|
|||
func ReadPassword(fd int) ([]byte, error) {
|
||||
return nil, errors.New("can't read password")
|
||||
}
|
||||
|
||||
// WriteTerminalTitle writes a string to the terminal title
|
||||
func WriteTerminalTitle(title string) {
|
||||
// Since there's nothing to return, this is a NOOP
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue