blob: 5b605ce27ceb450b678b0453b8769b4e6b7c1622 [file] [log] [blame]
Erich Smith55e77de2012-05-11 23:27:03 -04001cite about-plugin
2about-plugin 'osx-specific functions'
Robert R Evansa4d02422010-10-02 15:07:29 -07003
4function tab() {
Erich Smith55e77de2012-05-11 23:27:03 -04005 about 'opens a new terminal tab'
Erich Smith08e439c2012-05-13 08:37:31 -04006 group 'osx'
Erich Smith55e77de2012-05-11 23:27:03 -04007
Robert R Evansa4d02422010-10-02 15:07:29 -07008 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 Winkler964850d2013-12-10 16:59:22 +010014 do script with command " cd \"$PWD\"; $*" in window 1
Robert R Evansa4d02422010-10-02 15:07:29 -070015 end tell
16EOF
Rich Manalangc94ccf12010-10-07 13:34:42 -070017}
Florian Baumann827578c2010-11-04 18:19:50 +010018
19# this one switches your os x dock between 2d and 3d
20# thanks to savier.zwetschge.org
21function dock-switch() {
Erich Smith55e77de2012-05-11 23:27:03 -040022 about 'switch dock between 2d and 3d'
23 param '1: "2d" or "3d"'
24 example '$ dock-switch 2d'
Erich Smith08e439c2012-05-13 08:37:31 -040025 group 'osx'
Florian Baumann827578c2010-11-04 18:19:50 +010026
27 if [ $(uname) = "Darwin" ]; then
Mark Szymanski1a969452011-06-30 08:30:46 -050028
Florian Baumann827578c2010-11-04 18:19:50 +010029 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 Szymanski1a969452011-06-30 08:30:46 -050039 echo "dock-switch 2d"
Florian Baumanne1761162010-11-04 18:24:02 +010040 echo "dock-switch 3d."
Florian Baumann827578c2010-11-04 18:19:50 +010041 fi
42 else
Mark Szymanski1a969452011-06-30 08:30:46 -050043 echo "Sorry, this only works on Mac OS X"
Florian Baumann827578c2010-11-04 18:19:50 +010044 fi
45}
Mark Szymanski3a2b5252011-07-07 11:04:27 -050046
47# Download a file and open it in Preview
48
49function prevcurl() {
Erich Smith55e77de2012-05-11 23:27:03 -040050 about 'download a file and open it in Preview'
51 param '1: url'
52 group 'osx'
53
Mark Szymanski3a2b5252011-07-07 11:04:27 -050054 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}