]>
git.rmz.io Git - dotfiles.git/blob - zsh/plugins/osx/osx.plugin.zsh
1 # ------------------------------------------------------------------------------
3 # DESCRIPTION: oh-my-zsh plugin file.
4 # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
6 # ------------------------------------------------------------------------------
9 local command="cd \\\"$PWD\\\""
10 (( $# > 0 )) && command="${command}; $*"
13 osascript
2>/dev
/null
<<EOF
14 tell application "System Events"
15 name of first item of (every process whose frontmost is true)
20 [[ "$the_app" == 'Terminal' ]] && {
21 osascript
2>/dev
/null
<<EOF
22 tell application "System Events"
23 tell process "Terminal" to keystroke "t" using command down
24 tell application "Terminal" to do script "${command}" in front window
29 [[ "$the_app" == 'iTerm' ]] && {
30 osascript
2>/dev
/null
<<EOF
31 tell application "iTerm"
32 set current_terminal to current terminal
34 launch session "Default Session"
35 set current_session to current session
37 write text "${command}; clear;"
45 function vsplit_tab
() {
46 local command="cd \\\"$PWD\\\""
47 (( $# > 0 )) && command="${command}; $*"
50 osascript
2>/dev
/null
<<EOF
51 tell application "System Events"
52 name of first item of (every process whose frontmost is true)
57 [[ "$the_app" == 'iTerm' ]] && {
58 osascript
2>/dev
/null
<<EOF
59 tell application "iTerm" to activate
61 tell application "System Events"
63 tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
67 keystroke "${command}; clear;"
74 function split_tab
() {
75 local command="cd \\\"$PWD\\\""
76 (( $# > 0 )) && command="${command}; $*"
79 osascript
2>/dev
/null
<<EOF
80 tell application "System Events"
81 name of first item of (every process whose frontmost is true)
86 [[ "$the_app" == 'iTerm' ]] && {
87 osascript
2>/dev
/null
<<EOF
88 tell application "iTerm" to activate
90 tell application "System Events"
92 tell menu item "Split Horizontally With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
96 keystroke "${command}; clear;"
104 osascript
2>/dev
/null
<<EOF
105 tell application "Finder"
106 return POSIX path of (target of window 1 as alias)
112 osascript
2>/dev
/null
<<EOF
114 tell application "Finder" to set the_selection to selection
115 set item_count to count the_selection
116 repeat with item_index from 1 to count the_selection
117 if item_index is less than item_count then set the_delimiter to "\n"
118 if item_index is item_count then set the_delimiter to ""
119 set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
132 function quick
-look() {
133 (( $# > 0 )) && qlmanage
-p $
* &>/dev
/null
&
136 function man
-preview() {
137 man
-t "$@" | open
-f -a Preview
141 local trash_dir
="${HOME}/.Trash"
145 if [[ -e "$item" ]]; then
146 item_name
="$(basename $item)"
147 if [[ -e "${trash_dir}/${item_name}" ]]; then
148 mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")"
150 mv -f "$item" "${trash_dir}/"