Use pgrep instead of ps/grep/cut
Use pgrep instead of ps/grep/cut

$ time ps -u $(whoami) |grep mate-terminal |cut -d' ' -f1

real	0m0.043s
user	0m0.012s
sys	0m0.036s

$ time pgrep -u $(whoami) mate-terminal

real	0m0.019s
user	0m0.009s
sys	0m0.011s
optimiz/scripts