github.com/wtfutil/wtf@v0.43.0/wtf/terminal.go (about)

     1  package wtf
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/logrusorgru/aurora/v4"
     8  	"github.com/olebedev/config"
     9  )
    10  
    11  // SetTerminal sets the TERM environment variable, defaulting to whatever the OS
    12  // has as the current value if none is specified.
    13  // See https://www.gnu.org/software/gettext/manual/html_node/The-TERM-variable.html for
    14  // more details.
    15  func SetTerminal(config *config.Config) {
    16  	term := config.UString("wtf.term", os.Getenv("TERM"))
    17  	err := os.Setenv("TERM", term)
    18  	if err != nil {
    19  		fmt.Printf("\n%s Failed to set $TERM to %s.\n", aurora.Red("ERROR"), aurora.Yellow(term))
    20  		os.Exit(1)
    21  	}
    22  }