Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (48 sloc) 1.97 KB
# From http://codesnippets.joyent.com/posts/show/1516
# Minimise terminal window to Dock
function twmin() { printf "\e[2t"; return 0; }
# Send Terminal window to background
function twbg() { printf "\e[6t"; return 0; }
function twhide() {
/usr/bin/osascript -e 'tell application "System Events" to set visible of some item of ( get processes whose name = "Terminal" ) to false'
return 0
}
# positive integer test (including zero)
function positive_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); }
# move the Terminal window
function twmv() {
if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
printf "\e[3;${1};${2};t"
return 0
fi
return 1
}
# resize the Terminal window
function twsize() {
if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
printf "\e[8;${1};${2};t"
/usr/bin/clear
return 0
fi
return 1
}
# default screen
function twdefault() { printf "\e[3;0;0;t\e[8;48;110t"; /usr/bin/clear; return 0; }
function twdefaultbottom() { printf "\e[3;0;475;t\e[8;48;110t"; /usr/bin/clear; return 0; }
function twdefaultlaptop() { printf "\e[3;1132;0;t\e[8;48;109t"; /usr/bin/clear; return 0; }
function twdefaultlaptopbottom() { printf "\e[3;1132;455;t\e[8;48;109t"; /usr/bin/clear; return 0; }
# max columns
function twmaxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; }
# max rows
function twmaxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; }
# show number of lines & columns
function twlc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; }
# open a new Terminal window in same location as current directory
unset -f twnew
function twnew() {
/bin/pwd | /usr/bin/pbcopy
/usr/bin/open -a Terminal
/usr/bin/osascript -e 'tell application "Terminal" to do script with command "cd \"$(/usr/bin/pbpaste)\"; echo \" \" | /usr/bin/pbcopy; /usr/bin/clear"'
return 0
}
# vi:filetype=sh
Something went wrong with that request. Please try again.