Skip to content

Instantly share code, notes, and snippets.

@vikpe
Last active May 28, 2018 10:15
Show Gist options
  • Save vikpe/1ae593e408533ada9b500cf3cc82deff to your computer and use it in GitHub Desktop.
Save vikpe/1ae593e408533ada9b500cf3cc82deff to your computer and use it in GitHub Desktop.
Script to open multiple terminals in CentOS
#!/bin/bash
# sample config (4x2 grid on a 3840x2160 screen)
screen_cols=424
screen_rows=116
screen_width=3840
screen_height=2160
grid_col_count=4
grid_row_count=2
declare -a dirs=(
"~"
"~"
"~"
"~"
"~"
)
# script
scrollbar_cols=1
menubar_rows=2
terminal_width=$(($screen_width/$grid_col_count))
terminal_height=$(($screen_height/$grid_row_count))
terminal_cols=$((($screen_cols/$grid_col_count)-$scrollbar_cols))
terminal_rows=$((($screen_rows/$grid_row_count)-$menubar_rows))
for index in ${!dirs[@]}; do
col_index=$(($index%$grid_col_count))
row_index=$(($index/$grid_col_count))
offset_x=$(($terminal_width*$col_index))
offset_y=$(($terminal_height*$row_index))
geometry="${terminal_cols}x${terminal_rows}+${offset_x}+${offset_y}"
gnome-terminal --tab --geometry=$geometry --working-directory=${dirs[index]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment