Linux - Close current terminal and open a new terminal

By xngo on June 30, 2019

#!/bin/bash
# Description: Close current terminal and open a new terminal.
# Require: nohup, xfce4-terminal
 
# * Don't suffix command with '&'. Otherwise, command doesn't have time to complete
#       before this current terminal closes.
# * 2>/dev/null: Supress "nohup: ignoring input and appending output to `nohup.out'" 
# * Adding -e COMMAND to xfce4-terminal doesn't work. Don't know why.
nohup xfce4-terminal --geometry=190x21+0+0 2>/dev/null
 
# Or
# Simpler to use --hold option.
#xfce4-terminal --geometry=190x21+0+0 --hold
 
### Close current terminal.
kill -9 $PPID

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.