Is there an elegant solution to do this shell script in Python without importing os ?
tput cup 14 15; echo -ne "\033[1;32mtest\033[0m" ; tput cup 50 0
This just has been gnawing in my mind for some time now :)
Thanks
The tput command allows shell scripts to do things like clear the screen, underline text, and center text no matter how wide the screen is. To do these things, it translates the terminal-independent name of a terminal capability into its actual value for the terminal type being used.
Description. The tput command uses the terminfo database to make terminal-dependent information available to the shell. The tput command outputs a string if the attribute CapabilityName is of type string. The output string is an integer if the attribute is of type integer.
Thanks Ignacio Vazquez-Abrams for your input, it was a great push in the right direction. In the end i came up with this little code that will help me conquer the world :)
from curses import *
setupterm()
#cols = tigetnum("cols")
#lines = tigetnum("lines")
#print str(cols) + "x" + str(lines)
place_begin = tparm(tigetstr("cup"), 15, 14)
place_end = tparm(tigetstr("cup"), 50, 0)
print place_begin + "-- some text --" + place_end
@TZ.TZIOY, thanks, i think using stdout rather than using print indeed is a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With