mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-15 08:01:43 +00:00
[#23] Rename plugins to modules
This commit is contained in:
32
modules/osx/README.md
Normal file
32
modules/osx/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
OSX
|
||||
===
|
||||
Defines [Mac OS X][1] aliases and functions.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
change to the current _Finder_ directory.
|
||||
- `cdf` change the current working director to the current _Finder_ directory.
|
||||
- `pushdf` push the current working directory onto the directory queue and
|
||||
- `ql` quick look at files.
|
||||
- `rm-osx-cruft` delete .DS\_Store, \_\_MACOSX cruft.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `manb` open _man_ pages in [_Bwana.app_][2].
|
||||
- `manp` open _man_ pages in _Preview.app_.
|
||||
- `pfd` print current _Finder_ directory.
|
||||
- `pfs` print current _Finder_ selection.
|
||||
- `tab` create a new tab (works in both _Terminal_ and [_iTerm_][3]).
|
||||
- `trash` move files and folders to _Trash_.
|
||||
|
||||
Authors
|
||||
-------
|
||||
*The authors of this module should be contacted via the GitHub issue tracker.*
|
||||
|
||||
- [Sorin Ionescu](/sorin-ionescu)
|
||||
|
||||
[1]: http://www.apple.com/macosx/
|
||||
[2]: http://bruji.com/bwana/
|
||||
[3]: http://www.iterm2.com/
|
||||
|
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
|
||||
|
26
modules/osx/init.zsh
Normal file
26
modules/osx/init.zsh
Normal file
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Defines Mac OS X aliases and functions.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Change directory to the current Finder directory.
|
||||
alias cdf='cd "$(pfd)"'
|
||||
|
||||
# Push directory to the current Finder directory.
|
||||
alias pushdf='pushd "$(pfd)"'
|
||||
|
||||
# Open files in Quick Look.
|
||||
function ql {
|
||||
(( $# > 0 )) && qlmanage -p "$@" &> /dev/null
|
||||
}
|
||||
|
||||
# Delete .DS_Store and __MACOSX directories.
|
||||
function rm-osx-cruft {
|
||||
find "${@:-$PWD}" \( \
|
||||
-type f -name '.DS_Store' -o \
|
||||
-type d -name '__MACOSX' \
|
||||
\) -print0 | xargs -0 rm -rf
|
||||
}
|
||||
|
Reference in New Issue
Block a user