diff options
Diffstat (limited to 'plugins/osx')
| -rw-r--r-- | plugins/osx/README.md | 43 | ||||
| -rw-r--r-- | plugins/osx/osx.plugin.zsh | 26 | 
2 files changed, 47 insertions, 22 deletions
diff --git a/plugins/osx/README.md b/plugins/osx/README.md index ecc9327d0..50458f60e 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -12,27 +12,28 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)  ## Commands -| Command         | Description                                           | -| :-------------- | :---------------------------------------------------- | -| `tab`           | Open the current directory in a new tab               | -| `split_tab`     | Split the current terminal tab horizontally           | -| `vsplit_tab`    | Split the current terminal tab vertically             | -| `ofd`           | Open the current directory in a Finder window         | -| `pfd`           | Return the path of the frontmost Finder window        | -| `pfs`           | Return the current Finder selection                   | -| `cdf`           | `cd` to the current Finder directory                  | -| `pushdf`        | `pushd` to the current Finder directory               | -| `pxd`           | Return the current Xcode project directory            | -| `cdx`           | `cd` to the current Xcode project directory           | -| `quick-look`    | Quick-Look a specified file                           | -| `man-preview`   | Open a specified man page in Preview app              | -| `showfiles`     | Show hidden files in Finder                           | -| `hidefiles`     | Hide the hidden files in Finder                       | -| `itunes`        | _DEPRECATED_. Use `music` from macOS Catalina on      | -| `music`         | Control Apple Music. Use `music -h` for usage details | -| `spotify`       | Control Spotify and search by artist, album, track…   | -| `rmdsstore`     | Remove .DS\_Store files recursively in a directory    | -| `btrestart`     | Restart the Bluetooth daemon                          | +| Command       | Description                                              | +| :------------ | :------------------------------------------------------- | +| `tab`         | Open the current directory in a new tab                  | +| `split_tab`   | Split the current terminal tab horizontally              | +| `vsplit_tab`  | Split the current terminal tab vertically                | +| `ofd`         | Open the current directory in a Finder window            | +| `pfd`         | Return the path of the frontmost Finder window           | +| `pfs`         | Return the current Finder selection                      | +| `cdf`         | `cd` to the current Finder directory                     | +| `pushdf`      | `pushd` to the current Finder directory                  | +| `pxd`         | Return the current Xcode project directory               | +| `cdx`         | `cd` to the current Xcode project directory              | +| `quick-look`  | Quick-Look a specified file                              | +| `man-preview` | Open a specified man page in Preview app                 | +| `showfiles`   | Show hidden files in Finder                              | +| `hidefiles`   | Hide the hidden files in Finder                          | +| `itunes`      | _DEPRECATED_. Use `music` from macOS Catalina on         | +| `music`       | Control Apple Music. Use `music -h` for usage details    | +| `spotify`     | Control Spotify and search by artist, album, track…      | +| `rmdsstore`   | Remove .DS\_Store files recursively in a directory       | +| `btrestart`   | Restart the Bluetooth daemon                             | +| `freespace`   | Erases purgeable disk space with 0s on the selected disk |  ## Acknowledgements 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"  | 
