mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 08:41:43 +00:00
[#23] Rename plugins to modules
This commit is contained in:
24
modules/osx/functions/manb
Normal file
24
modules/osx/functions/manb
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Opens man pages in Bwana.app.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function manb {
|
||||
local page
|
||||
if (( $# > 0 )); then
|
||||
for page in "$@"; do
|
||||
open "man:$page" 2>/dev/null
|
||||
if (( $? != 0 )); then
|
||||
print "$0: Bwana is not installed" >&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
print 'What manual page do you want?' >&2
|
||||
fi
|
||||
}
|
||||
compdef _man manb
|
||||
manb "$@"
|
||||
|
20
modules/osx/functions/manp
Normal file
20
modules/osx/functions/manp
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Opens man pages in Preview.app.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function manp {
|
||||
local page
|
||||
if (( $# > 0 )); then
|
||||
for page in "$@"; do
|
||||
man -t "$page" | open -f -a Preview
|
||||
done
|
||||
else
|
||||
print 'What manual page do you want?' >&2
|
||||
fi
|
||||
}
|
||||
compdef _man manp
|
||||
manp "$@"
|
||||
|
13
modules/osx/functions/pfd
Normal file
13
modules/osx/functions/pfd
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Displays the current Finder.app directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (target of window 1 as alias)
|
||||
end tell
|
||||
EOF
|
||||
|
18
modules/osx/functions/pfs
Normal file
18
modules/osx/functions/pfs
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# Displays the current Finder.app selection.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
osascript 2>/dev/null <<EOF
|
||||
set output to ""
|
||||
tell application "Finder" to set the_selection to selection
|
||||
set item_count to count the_selection
|
||||
repeat with item_index from 1 to count the_selection
|
||||
if item_index is less than item_count then set the_delimiter to "\n"
|
||||
if item_index is item_count then set the_delimiter to ""
|
||||
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
|
||||
end repeat
|
||||
EOF
|
||||
|
42
modules/osx/functions/tab
Normal file
42
modules/osx/functions/tab
Normal file
@ -0,0 +1,42 @@
|
||||
#
|
||||
# Opens a new Terminal.app/iTerm.app tab in the current directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'Terminal' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm"
|
||||
set current_terminal to current terminal
|
||||
tell current_terminal
|
||||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
27
modules/osx/functions/trash
Normal file
27
modules/osx/functions/trash
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Moves directories and files to Trash.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
print -N "${@:a}" | xargs -0 osascript -e '
|
||||
on run theFilePaths
|
||||
tell application "Finder"
|
||||
set thePOSIXFiles to {}
|
||||
repeat with aFilePath in theFilePaths
|
||||
set aPOSIXFile to aFilePath as POSIX file
|
||||
if exists aPOSIXFile
|
||||
set end of thePOSIXFiles to aPOSIXFile
|
||||
end if
|
||||
end repeat
|
||||
move every item of thePOSIXFiles to trash
|
||||
end tell
|
||||
end run
|
||||
' &>/dev/null
|
||||
|
||||
if (( $? != 0)); then
|
||||
print "$0: failed to move one or more items" >&2
|
||||
return 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user