Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rather than turn off all attributes with "tput sgr0", instead I Save Cursor with "tput sc" at the beginning to save attributes, and Restore Cursor with "tput rc" at the end to restore attributes.

Save and Restore cursor doesn't always work because I don't necessarily need the vertical position restored, for example:

  ls_color () { 
    tput sc;
    /bin/ls --color=auto "$@";
    push_cursor_position;
    tput rc;
    pop_cursor_position
  }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: