Erich Smith | 55e77de | 2012-05-11 23:27:03 -0400 | [diff] [blame] | 1 | cite about-plugin |
| 2 | about-plugin 'osx-specific functions' |
Robert R Evans | a4d0242 | 2010-10-02 15:07:29 -0700 | [diff] [blame] | 3 | |
| 4 | function tab() { |
Erich Smith | 55e77de | 2012-05-11 23:27:03 -0400 | [diff] [blame] | 5 | about 'opens a new terminal tab' |
Erich Smith | 08e439c | 2012-05-13 08:37:31 -0400 | [diff] [blame] | 6 | group 'osx' |
Erich Smith | 55e77de | 2012-05-11 23:27:03 -0400 | [diff] [blame] | 7 | |
Robert R Evans | a4d0242 | 2010-10-02 15:07:29 -0700 | [diff] [blame] | 8 | osascript 2>/dev/null <<EOF |
| 9 | tell application "System Events" |
| 10 | tell process "Terminal" to keystroke "t" using command down |
| 11 | end |
| 12 | tell application "Terminal" |
| 13 | activate |
Nils Winkler | 964850d | 2013-12-10 16:59:22 +0100 | [diff] [blame] | 14 | do script with command " cd \"$PWD\"; $*" in window 1 |
Robert R Evans | a4d0242 | 2010-10-02 15:07:29 -0700 | [diff] [blame] | 15 | end tell |
| 16 | EOF |
Rich Manalang | c94ccf1 | 2010-10-07 13:34:42 -0700 | [diff] [blame] | 17 | } |
Florian Baumann | 827578c | 2010-11-04 18:19:50 +0100 | [diff] [blame] | 18 | |
| 19 | # this one switches your os x dock between 2d and 3d |
| 20 | # thanks to savier.zwetschge.org |
| 21 | function dock-switch() { |
Erich Smith | 55e77de | 2012-05-11 23:27:03 -0400 | [diff] [blame] | 22 | about 'switch dock between 2d and 3d' |
| 23 | param '1: "2d" or "3d"' |
| 24 | example '$ dock-switch 2d' |
Erich Smith | 08e439c | 2012-05-13 08:37:31 -0400 | [diff] [blame] | 25 | group 'osx' |
Florian Baumann | 827578c | 2010-11-04 18:19:50 +0100 | [diff] [blame] | 26 | |
| 27 | if [ $(uname) = "Darwin" ]; then |
Mark Szymanski | 1a96945 | 2011-06-30 08:30:46 -0500 | [diff] [blame] | 28 | |
Florian Baumann | 827578c | 2010-11-04 18:19:50 +0100 | [diff] [blame] | 29 | if [ $1 = 3d ] ; then |
| 30 | defaults write com.apple.dock no-glass -boolean NO |
| 31 | killall Dock |
| 32 | |
| 33 | elif [ $1 = 2d ] ; then |
| 34 | defaults write com.apple.dock no-glass -boolean YES |
| 35 | killall Dock |
| 36 | |
| 37 | else |
| 38 | echo "usage:" |
Mark Szymanski | 1a96945 | 2011-06-30 08:30:46 -0500 | [diff] [blame] | 39 | echo "dock-switch 2d" |
Florian Baumann | e176116 | 2010-11-04 18:24:02 +0100 | [diff] [blame] | 40 | echo "dock-switch 3d." |
Florian Baumann | 827578c | 2010-11-04 18:19:50 +0100 | [diff] [blame] | 41 | fi |
| 42 | else |
Mark Szymanski | 1a96945 | 2011-06-30 08:30:46 -0500 | [diff] [blame] | 43 | echo "Sorry, this only works on Mac OS X" |
Florian Baumann | 827578c | 2010-11-04 18:19:50 +0100 | [diff] [blame] | 44 | fi |
| 45 | } |
Mark Szymanski | 3a2b525 | 2011-07-07 11:04:27 -0500 | [diff] [blame] | 46 | |
| 47 | # Download a file and open it in Preview |
| 48 | |
| 49 | function prevcurl() { |
Erich Smith | 55e77de | 2012-05-11 23:27:03 -0400 | [diff] [blame] | 50 | about 'download a file and open it in Preview' |
| 51 | param '1: url' |
| 52 | group 'osx' |
| 53 | |
Mark Szymanski | 3a2b525 | 2011-07-07 11:04:27 -0500 | [diff] [blame] | 54 | if [ ! $(uname) = "Darwin" ] |
| 55 | then |
| 56 | echo "This function only works with Mac OS X" |
| 57 | return 1 |
| 58 | fi |
| 59 | curl "$*" | open -fa "Preview" |
| 60 | } |