frankjonen

Run script in new Terminal Window + Grid - maxOS High Sierra

May 3rd, 2018
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.64 KB | None | 0 0
  1. # - - - - - - - - - - - - - - - - - - - - - - - - - #
  2. # > .bash_profile                                   #
  3. # - - - - - - - - - - - - - - - - - - - - - - - - - #
  4.  
  5. HISTCONTROL=ignoreboth
  6. # This excludes anything with a space before it from
  7. # your .bash_history
  8.  
  9.  
  10. alias example =" ssh [email protected]"
  11. alias some_other =" ssh [email protected]"
  12.  
  13. # aliases for your ssh connections for example
  14.  
  15.  
  16. function scriptSpawn(){
  17. # The Apple Script that creates the grid items
  18.  
  19. osascript <<EOD
  20.     tell application "Finder"
  21.         set desktopBounds to bounds of window of desktop
  22.         set desktopWidth to item 3 of desktopBounds
  23.         set desktopHeight to item 4 of desktopBounds
  24.  
  25.         set windowWidth to desktopWidth / 3
  26.         set windowHeight to desktopHeight / 2
  27.  
  28.         -- - - - - - - -  Column 1
  29.  
  30.         set window_c1_vpos1 to 22
  31.         set window_c1_vpos2 to desktopHeight - 1
  32.         set window_c1_hpos1 to 0
  33.         set window_c1_hpos2 to windowWidth
  34.  
  35.         -- - - - - - - -  Column 2
  36.         -- - - - - - - - - - - - - - - - - - - - - ROW 1
  37.  
  38.         -- grid item 1
  39.         set window_1_vpos1 to 22
  40.         set window_1_vpos2 to windowHeight
  41.         set window_1_hpos1 to 0
  42.         set window_1_hpos2 to windowWidth
  43.  
  44.         -- grid item 2
  45.         set window_2_vpos1 to 22
  46.         set window_2_vpos2 to windowHeight
  47.         set window_2_hpos1 to windowWidth
  48.         set window_2_hpos2 to 2 * windowWidth
  49.  
  50.         -- grid item 3
  51.         set window_3_vpos1 to 22
  52.         set window_3_vpos2 to windowHeight
  53.         set window_3_hpos1 to 2 * windowWidth
  54.         set window_3_hpos2 to 3 * windowWidth
  55.  
  56.         -- - - - - - - - - - - - - - - - - - - - - ROW 2
  57.  
  58.         -- grid item 4
  59.         set window_4_vpos1 to windowHeight
  60.         set window_4_vpos2 to 2 * windowHeight
  61.         set window_4_hpos1 to 0
  62.         set window_4_hpos2 to windowWidth
  63.  
  64.         -- grid item 5
  65.         set window_5_vpos1 to windowHeight
  66.         set window_5_vpos2 to 2 * windowHeight
  67.         set window_5_hpos1 to windowWidth
  68.         set window_5_hpos2 to 2 * windowWidth
  69.  
  70.         -- grid item 6
  71.         set window_6_vpos1 to windowHeight
  72.         set window_6_vpos2 to 2 * windowHeight
  73.         set window_6_hpos1 to 2 * windowWidth
  74.         set window_6_hpos2 to 3 * windowWidth
  75.     end tell
  76.  
  77.     tell application "Terminal"
  78.         set newTab to do script "$1"
  79.         set bounds of front window to {window_$2_hpos1, window_$2_vpos1, window_$2_hpos2, window_$2_vpos2}
  80.     end tell
  81. EOD
  82. }
  83.  
  84. ## Make sure EOD does not have a trailling space!
  85.  
  86. # Call AppleScript to open a new Terminal window/tab
  87. # and run the alias piped into it via the variable.
  88. #
  89. # - - Window Sizes and Positions - -
  90. # These are derived from your screensize.
  91. # The 'c1' parameter gets you a full-height panel
  92. # pinned to the left.  
  93. #
  94. # "scriptSpawn example 1" would run the "example" alias
  95. # in a new Terminal window anchored top left and a
  96. # size of 1/3rd your screen width and half its height.
  97.  
  98.  
  99.  
  100. ✁ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  101.  
  102.  
  103.  
  104. # - - - - - - - - - - - - - - - - - - - - - - - - - #
  105. # > .inputrc                                        #
  106. # - - - - - - - - - - - - - - - - - - - - - - - - - #
  107.  
  108. # F9 to run the scriptSpwan function with the alias
  109. # "example" and the position flag "1" appended as flags
  110. # Or use your own scripts and tools instead of an alias.
  111. # For example I have 'htop' mapped to a key for 'c1'.
  112.  
  113.  
  114.  
  115. # - - - - - - - - - - - - - - - -
  116. # Script Spawn Grid
  117. # - - - - - - - - - - - - - - - -
  118. #     1 | 2 | 3
  119. #     4 | 5 | 6
  120.  
  121. #    c1 | 2 | 3
  122. #       | 5 | 6
  123.  
  124. "\e[20~": " scriptSpawn example 1 && clear \C-m"
Advertisement
Add Comment
Please, Sign In to add comment