-
-
Save linniksa/ad05020e6372c0a78534db07099d8d03 to your computer and use it in GitHub Desktop.
Revisions
-
linniksa revised this gist
Mar 10, 2024 . 1 changed file with 14 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/usr/bin/env zsh set -e function exportDefaults { local outdir="$HOME/defaults" local outdirApple="$outdir/apple" @@ -11,8 +13,8 @@ function exportDefaults { local globals=0 function cleanOutDirs { [[ ! -d "$outdir" ]] && mkdir "$outdir" if [[ -d $outdirApple ]]; then echo "removing all files in $outdirApple" rm -rf "${outdirApple/*}" @@ -41,17 +43,17 @@ function exportDefaults { for domain in "${domains[@]}"; do plist="${domain//,/}.plist" if [[ $globals == 0 ]]; then if [[ "$domain" =~ com.apple ]] || [[ $domain =~ 'Apple Global Domain' ]]; then defaults export "$domain" - > "$outdirApple/$plist" #echo "writing $plist to $outdirApple" filecount=$((filecount+1)) else defaults export "$domain" - > "$outdirUser/$plist" #echo "writing $plist to $outdirUser" filecount=$((filecount+1)) fi else sudo defaults export "$domain" - > "$outdirGlobal/$plist" #echo "writing $plist to $outdirGlobal" filecount=$((filecount+1)) fi @@ -61,12 +63,13 @@ function exportDefaults { done } cleanOutDirs # ------------------------------------------------- local domains=($(defaults domains)) domains+=('Apple Global Domain') # add "hidden" domain local filesleft=${#domains[@]} echo "USER namespace has ${#domains[@]} domains, exporting..." exportDomains echo "written $filecount files in $outdir" local filestotal=$((filestotal+filecount)) @@ -75,16 +78,16 @@ function exportDefaults { # ------------------------------------------------- local domains=($(sudo defaults domains)) local filesleft=${#domains[@]} echo "GLOBAL namespace has ${#domains[@]} domains, exporting..." exportDomains echo "written $filecount files in $outdir" local filestotal=$((filestotal+filecount)) # ------------------------------------------------- sudo chown -R "$(whoami)":staff "$outdir" local timed="$((SECONDS / 3600))hrs $(((SECONDS / 60) % 60))min $((SECONDS % 60))sec" echo "exported $filestotal files in $timed" } exportDefaults -
inoperable renamed this gist
Apr 25, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
inoperable revised this gist
Apr 25, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/env zsh function exportDefaults { local outdir="$HOME/defaults" -
inoperable renamed this gist
Mar 16, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
inoperable created this gist
Mar 16, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,90 @@ #!/bin/bash function exportDefaults { local outdir="$HOME/defaults" local outdirApple="$outdir/apple" local outdirUser="$outdir/user" local outdirGlobal="$outdir/global" local filesdone=0 local filecount=0 local filestotal=0 local globals=0 function cleanOutdirs { [[ ! -d $HOME/defaults ]] && mkdir "$HOME/defaults" if [[ -d $outdirApple ]]; then echo "removing all files in $outdirApple" rm -rf "${outdirApple/*}" else mkdir "$outdirApple" fi if [[ -d $outdirUser ]]; then echo "removing all files in $outdirUser" rm -rf "${outdirUser/*}" else mkdir "$outdirUser" fi if [[ -d $outdirGlobal ]]; then echo "removing all files in $outdirGlobal" rm -rf "${outdirGlobal/*}" else mkdir "$outdirGlobal" fi } function exportDomains { filesdone=0 filecount=0 for domain in "${domains[@]}"; do plist="${domain//,/}.plist" if [[ $globals == 0 ]]; then if [[ $domain =~ com.apple ]]; then defaults export "$domain" "$outdirApple/$plist" #echo "writing $plist to $outdirApple" filecount=$((filecount+1)) else defaults export "$domain" "$outdirUser/$plist" #echo "writing $plist to $outdirUser" filecount=$((filecount+1)) fi else sudo defaults export "$domain" "$outdirGlobal/$plist" #echo "writing $plist to $outdirGlobal" filecount=$((filecount+1)) fi filesleft=$((filesleft-1)) filesdone=$((filesdone+1)) echo -ne "[ $filesdone/$filesleft ] \r" done } cleanOutdirs # ------------------------------------------------- local domains=($(defaults domains)) local filesleft=${#domains[@]} echo "USER namespace has ${#domains[@]} domains, exportig..." exportDomains echo "written $filecount files in $outdir" local filestotal=$((filestotal+filecount)) # ------------------------------------------------- globals=1 # ------------------------------------------------- local domains=($(sudo defaults domains)) local filesleft=${#domains[@]} echo "GLOBAL namespace has ${#domains[@]} domains, exportig..." exportDomains echo "written $filecount files in $outdir" local filestotal=$((filestotal+filecount)) # ------------------------------------------------- sudo chown -R "$(whoami)":staff "$HOME/defaults" local timed="$((SECONDS / 3600))hrs $(((SECONDS / 60) % 60))min $((SECONDS % 60))sec" echo "exported $filestotal files in $timed" } exportDefaults