Close current terminal and open a new terminal

By xngo on February 20, 2019

The code

#!/bin/bash
# Description: Open a new terminal and close the current terminal.
# Author: Xuan Ngo
# 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

Github

https://github.com/limelime/bash/blob/master/terminal/close-n-open-new-terminal.sh

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.