Skip to content

Instantly share code, notes, and snippets.

@notsobad
Created April 12, 2022 06:27
Show Gist options
  • Save notsobad/b22cbaaa8cbf7d3822fa1f29c6d791c3 to your computer and use it in GitHub Desktop.
Save notsobad/b22cbaaa8cbf7d3822fa1f29c6d791c3 to your computer and use it in GitHub Desktop.
Init script, so you can open several iterm2 tabs and ohter desktop apps.
#!/bin/bash
function tab () {
local cmd=""
local cdto="$PWD"
local args="$@"
if [ -d "$1" ]; then
cdto=`cd "$1"; pwd`
args="${@:2}"
fi
if [ -n "$args" ]; then
cmd="; $args"
fi
osascript &>/dev/null <<EOF
tell application "iTerm"
tell current window
set newTab to (create tab with default profile)
tell newTab
tell current session
write text "cd \"$cdto\"$cmd"
end tell
end tell
end tell
end tell
EOF
}
function alert(){
title="$1"
msg="$2"
osascript &>/dev/null <<EOF
display notification "$msg" with title "$title"
EOF
}
~/wg.sh || exit
tab "tmux new -s x"
tab "mosh app@my-box"
tab "vi notes.txt"
open -a "Google Chrome" https://google.com/
alert "have a nice day"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment