How can I save my multiple tabs session in an xfce4-terminal?
Solution 1:
You can create a shortcut with pre-defined tabs like this:
Terminal --geometry=100x40 --hide-menubar --hide-toolbars -T "Host1" -e "ssh -t root@host1" --tab -T "Host2" -e "ssh -t root@host2"
But something like that in the Command line of the shortcut editor dialog.
To have each tab have a different working directory you can do it this way:
Terminal --working-directory=$HOME/tmp --tab --working-directory=$HOME/src --tab --working-directory=$HOME/opt
Not that the first one doesn't have a --tab
before it, making it associate with the new top-level window. Then two additional tabs with different working directories.
Try to avoid using ~
expansion, as that is a shell feature that may not work in other context (such as custom launchers).
Solution 2:
This solution deploys one window with multiple tabs and processes.
I created a startup script (xfce4-terminal-startup.sh
),
#!/bin/bash
xfce4-terminal --maximize --title='Neovim' -x bash -c "nvr -s; exec bash"
xfce4-terminal --tab --title='psql' -x bash -c "psql -d zzz; exec bash"
xfce4-terminal --tab --title='Cypher-shell' -x bash -c "cd /mnt/Vancouver/Programming/data/hmdb; exec bash"
xfce4-terminal --tab --title='Cycli' -x bash -c "source activate py35 && cycli -P *** -u *** -p ***; exec bash"
xfce4-terminal --tab --title='Py3' -x bash -c "source activate py35 && python; exec bash"
xfce4-terminal --tab --title='bc' -x bash -c "bc; exec bash"
xfce4-terminal --tab --title='ud' -x bash -c "pacaur -Syu; exec bash"
that when executed starts xfce4-terminal, maximizes it, and launches the various programs as indicated.
Regarding "exec bash", above see:
- https://unix.stackexchange.com/questions/47271/prevent-gnu-screen-from-terminating-session-once-executed-script-ends *https://unix.stackexchange.com/questions/75902/how-to-run-xfce-terminal-with-different-commands-per-tab-and-keep-using-the-tabs
I.e.: if you start a window in screen that runs a command, keep that window open ...
Here is an animated GIF, showing those tabs in action!
[link to larger image]
- Reference: https://askubuntu.com/questions/421421/how-can-i-make-a-terminal-with-3-tabs-appear-after-startup/422121#422121
Update
This is my current xfce4-terminal-startup.sh
script (you can download it here: https://persagen.com/files/misc/xfce4-terminal-startup.sh):
#!/bin/bash
# vim: set filetype=sh :
# vim: syntax=sh
# /mnt/Vancouver/programming/scripts/xfce4-terminal-startup.sh
# https://web.archive.org/web/20110314180918/http://www.davidpashley.com/articles/writing-robust-shell-scripts.html
# https://stackoverflow.com/questions/2870992/automatic-exit-from-bash-shell-script-on-error/2871034#2871034
set -e
# ----------------------------------------------------------------------------
# This one first:
# Python as basic calculator: 1/3; import math; 2*math.pi; ...
xfce4-terminal --maximize --title='calculations' -x bash -c "python; exec bash"
# ... then (these will open as child tabs in the parent terminal window, above):
# Open my (current) project directory:
xfce4-terminal --tab --title='bash' -x bash -c "cd /mnt/Vancouver/projects/ie/claws/; pwd; ls -l; echo ''; exec bash"
# Start Neovim:
xfce4-terminal --tab --title='neovim' -x bash -c "nvr -s; exec bash"
# Open ripgrep tab (echo sample command), for fast searches in that director:
xfce4-terminal --tab --title='ripgrep' -x bash -c "cd /mnt/Vancouver/domains/PERSAGEN.com/2.0/; echo rg . -i -e \'1903.03243\'; exec bash"
# Open an Arch Linux update tab:
xfce4-terminal --tab --title='ud' -x bash -c "yay -Syu; exec bash"