feat(osx): add `freespace` command to clean purgeable disk space (#8762)
Co-authored-by: Marc Cornellà <hello@mcornella.com>
This commit is contained in:
parent
8c1495a18e
commit
46f8765f4c
|
@ -13,7 +13,7 @@ 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 |
|
||||
|
@ -33,6 +33,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
|||
| `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
|
||||
|
||||
|
|
|
@ -233,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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue