From bccfca8c1014e755eac0a8955e96c43e2d46807d Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 2 Feb 2014 20:08:21 -0500 Subject: [PATCH] Make osx functions autoloadable --- modules/osx/README.md | 5 +++-- modules/osx/functions/ql | 10 ++++++++++ modules/osx/functions/rm-osx-cruft | 11 +++++++++++ modules/osx/init.zsh | 18 ------------------ 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 modules/osx/functions/ql create mode 100644 modules/osx/functions/rm-osx-cruft diff --git a/modules/osx/README.md b/modules/osx/README.md index aace73c..31fde4e 100644 --- a/modules/osx/README.md +++ b/modules/osx/README.md @@ -9,8 +9,7 @@ Aliases - `cdf` changes the current working director to the current _Finder_ directory. - `pushdf` pushes the current working directory onto the directory queue and - - `ql` quick looks at files. - - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. + changes the current working director to the current _Finder_ directory. Functions --------- @@ -20,6 +19,8 @@ Functions - `pfd` prints the current _Finder_ directory. - `pfs` prints the current _Finder_ selection. - `tab` creates a new tab (works in both _Terminal_ and [_iTerm_][3]). + - `ql` previews files in Quick Look. + - `rm-osx-cruft` deletes .DS\_Store, \_\_MACOSX cruft. Authors ------- diff --git a/modules/osx/functions/ql b/modules/osx/functions/ql new file mode 100644 index 0000000..c8efa3f --- /dev/null +++ b/modules/osx/functions/ql @@ -0,0 +1,10 @@ +# +# Previews files in Quick Look. +# +# Authors: +# Sorin Ionescu +# + +if (( $# > 0 )); then + qlmanage -p "$@" &> /dev/null +fi diff --git a/modules/osx/functions/rm-osx-cruft b/modules/osx/functions/rm-osx-cruft new file mode 100644 index 0000000..0a91ced --- /dev/null +++ b/modules/osx/functions/rm-osx-cruft @@ -0,0 +1,11 @@ +# +# Deletes .DS_Store and __MACOSX directories. +# +# Authors: +# Sorin Ionescu +# + +find "${@:-$PWD}" \( \ + -type f -name '.DS_Store' -o \ + -type d -name '__MACOSX' \ +\) -print0 | xargs -0 rm -rf diff --git a/modules/osx/init.zsh b/modules/osx/init.zsh index 6acbfbc..a78f298 100644 --- a/modules/osx/init.zsh +++ b/modules/osx/init.zsh @@ -19,21 +19,3 @@ alias cdf='cd "$(pfd)"' # Push directory to the current Finder directory. alias pushdf='pushd "$(pfd)"' - -# -# Functions -# - -# 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 -} -