"tput reset" is much faster than "reset" (as discussed here), and running "reset" is annoyingly slow, is there some reason why i shouldn't add alias reset=tput reset
in .bashrc ? is it likely to break something?
-
The alias won't affect anything except your interactive session.– Chris DaviesCommented Oct 15, 2019 at 17:07
1 Answer
Assuming that you are not using a real hardware terminal, as mentioned in the answer(s) to your linked question, there is probably no need to worry about it.
Note that rather than being an alias, typically the reset
command starts out as a symlink to the desired utility; then that utility's executable detects which name you ran it with and changes its behavior accordingly. (Busybox is a famous example of this technique.)
So it's theoretically possible that alias reset=tput reset
wouldn't have quite the same effect as executing tput
via a symlink named reset
. But at least with my version, the manpage says it should be equivalent:
If
tput
is invoked by a link namedreset
, this has the same effect astput reset
. Seetset
for comparison, which has similar behavior.
The alias should give you the best of both worlds: you get the faster reset which is presumably not going to be a problem with the terminals you use, but leave the system-wide /usr/bin symlink alone in case other users or background utilities are relying on the tset
behavior or option handling.
-
If tput is invoked by a link named reset, this has the same effect as tput reset. See tset for comparison, which has similar behavior.
i don't believe it =/ runtime reset
, then runtime tput reset
, do you get roughly the same number on both of them? i doubt it =/ for the record, on my system:/usr/bin/reset: symbolic link to tset; time reset: real 0m1.002s; time tput reset: real 0m0.002s
- running tput reset was 500 times faster than running the reset symlink to tput Commented Jan 17, 2020 at 8:03 -
@hanshenrik I'm not following. Since your
/usr/bin/reset
remains a symbolic link totset
then yes you would get its slower behavior, versus if it were a symbolic link totput
instead.– natevwCommented Jan 17, 2020 at 21:29 -
if using the symlink is getting the slower behavior, then the following is not true:
If tput is invoked by a link named reset, this has the same effect as tput reset.
Commented Jan 18, 2020 at 10:44 -
@hanshenrik Your symlink is not causing
tput
to be invoked. Your symlink is causingtset
to be invoked. Those are different programs with different behavior.– natevwCommented Jan 20, 2020 at 22:14 -
1They are different programs, but since 2018 the "reset" feature in each uses the same code, gives the same result. Commented Feb 1 at 21:40