summaryrefslogtreecommitdiff
path: root/plugins/osx/osx.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2021-10-23 18:01:40 -0600
committerTuowen Zhao <ztuowen@gmail.com>2021-10-23 18:01:40 -0600
commitfad92c603be0ff36825cc53bf8c485d4b95c7869 (patch)
tree407fe826be62a3543b6feab4f3552f58575234de /plugins/osx/osx.plugin.zsh
parentc674485e6b4abe313469900997d893d2940ee843 (diff)
parentf1dd97bb2a9df55fae9b1ca26c829b9f8b290667 (diff)
downloadzsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.gz
zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.bz2
zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/osx/osx.plugin.zsh')
-rw-r--r--plugins/osx/osx.plugin.zsh26
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 7842e9f73..16f16ddb6 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -219,7 +219,8 @@ function quick-look() {
}
function man-preview() {
- man -t "$@" | open -f -a Preview
+ # Don't let Preview.app steal focus if the man page doesn't exist
+ man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@"
}
compdef _man man-preview
@@ -232,6 +233,29 @@ function rmdsstore() {
find "${@:-.}" -type f -name .DS_Store -delete
}
+# Erases purgeable disk space with 0s on the selected disk
+function freespace(){
+ if [[ -z "$1" ]]; then
+ echo "Usage: $0 <disk>"
+ echo "Example: $0 /dev/disk1s1"
+ echo
+ echo "Possible disks:"
+ df -h | awk 'NR == 1 || /^\/dev\/disk/'
+ return 1
+ fi
+
+ echo "Cleaning purgeable files from disk: $1 ...."
+ diskutil secureErase freespace 0 $1
+}
+
+_freespace() {
+ local -a disks
+ disks=("${(@f)"$(df | awk '/^\/dev\/disk/{ printf $1 ":"; for (i=9; i<=NF; i++) printf $i FS; print "" }')"}")
+ _describe disks disks
+}
+
+compdef _freespace freespace
+
# Music / iTunes control function
source "${0:h:A}/music"