-
-
Save pachun/23d50a19e14a16266e13aa2fea6b3fd5 to your computer and use it in GitHub Desktop.
macOS Dock scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
path=/Applications/Automator.app | |
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>$path</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"; killall Dock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock | |
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="small-spacer-tile";}'; killall Dock | |
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="flex-spacer-tile";}'; killall Dock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
path=~/Downloads | |
label="${path##*}" | |
arrangement=1 # 1 - name (default), 2 - added, 3 - modification, 4 - creation, 5 - kind | |
displayas=2 # 1 - folder, 2 - stack (default) | |
showas=4 # 1 - beep, 2 - grid, 3 - list, 4 - auto (default) | |
tmp="$(mktemp)" || exit | |
cat <<EOF > "$tmp" | |
<dict> | |
<key>tile-data</key> | |
<dict> | |
<key>file-data</key> | |
<dict> | |
<key>_CFURLString</key> | |
<string>$path</string> | |
<key>_CFURLStringType</key> | |
<integer>0</integer> | |
</dict> | |
<key>file-label</key> | |
<string>$label</string> | |
<key>arrangement</key> | |
<integer>$arrangement</integer> | |
<key>displayas</key> | |
<integer>$displayas</integer> | |
<key>showas</key> | |
<integer>$showas</integer> | |
</dict> | |
<key>tile-type</key> | |
<string>directory-tile</string> | |
</dict> | |
EOF | |
value="$(cat "$tmp")" || exit | |
defaults write com.apple.dock persistent-others -array-add "$value"; killall Dock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
defaults read com.apple.dock persistent-apps | grep '"_CFURLString"' | awk -F'"' '{print $4}' | php -R 'echo urldecode($argn)."\n";' | sed -e 's/file:\/\///g' | sed -e 's/\/$//g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
defaults read com.apple.dock persistent-others | grep '"_CFURLString"' | awk -F'"' '{print $4}' | php -R 'echo urldecode($argn)."\n";' | sed -e 's/file:\/\///g' | sed -e 's/\/$//g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
path=/Applications/Automator.app | |
dloc="$(defaults read com.apple.dock persistent-apps | grep '"_CFURLString"' | grep -n "$path" | cut -f1 -d:)" | |
[[ -n "$dloc" ]] && { | |
dloc=$[$dloc-1] | |
/usr/libexec/PlistBuddy -c "Delete persistent-apps:$dloc" ~/Library/Preferences/com.apple.dock.plist | |
killall Dock | |
};: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment