From 8979af0155824ca88aceac50ba07f631c4d4901d Mon Sep 17 00:00:00 2001 From: CNG Date: Tue, 18 Apr 2017 23:57:20 -0700 Subject: [PATCH 1/6] Laptop install issues --- lib/common.bash | 3 ++- .../developer/{env.getopt-path.zsh => env.path-getopt.zsh} | 0 ...{env.gnu-coreutils-path.zsh => env.path-gnu-coreutils.zsh} | 0 mods-available/developer/env.path-mysql.zsh | 2 +- mods-available/developer/env.path.zsh | 2 -- mods-available/git/env.path.zsh | 2 ++ mods-available/git/install.bash | 4 ++-- mods-available/macos/upgrade_defaults.sh | 4 ++++ mods-available/zsh/env.path-local.zsh | 2 ++ mods-available/zsh/install.sh | 4 ++++ 10 files changed, 17 insertions(+), 6 deletions(-) rename mods-available/developer/{env.getopt-path.zsh => env.path-getopt.zsh} (100%) rename mods-available/developer/{env.gnu-coreutils-path.zsh => env.path-gnu-coreutils.zsh} (100%) delete mode 100644 mods-available/developer/env.path.zsh create mode 100644 mods-available/git/env.path.zsh create mode 100644 mods-available/zsh/env.path-local.zsh diff --git a/lib/common.bash b/lib/common.bash index 2f9315a..6173767 100644 --- a/lib/common.bash +++ b/lib/common.bash @@ -221,6 +221,7 @@ module_install () { } _module_install_inner () { local pth=$MODS_ON/$module + [[ -d $MODS_ON ]] || mkdir $MODS_ON link_file "../${MODS_ALL##*/}/$module" "$MODS_ON" $lvl2 if [[ $module = base ]]; then scripts_execute "$pth" 'install' $lvl2 @@ -688,7 +689,7 @@ scripts_execute () { local count=0 if ! [[ -h $pth || -d $pth ]]; then - fail $lvl "Invalid $allow_any_dir path $(fmt bold $pth)." + fail $lvl "Invalid $name script path $(fmt bold $pth)." return 1 fi diff --git a/mods-available/developer/env.getopt-path.zsh b/mods-available/developer/env.path-getopt.zsh similarity index 100% rename from mods-available/developer/env.getopt-path.zsh rename to mods-available/developer/env.path-getopt.zsh diff --git a/mods-available/developer/env.gnu-coreutils-path.zsh b/mods-available/developer/env.path-gnu-coreutils.zsh similarity index 100% rename from mods-available/developer/env.gnu-coreutils-path.zsh rename to mods-available/developer/env.path-gnu-coreutils.zsh diff --git a/mods-available/developer/env.path-mysql.zsh b/mods-available/developer/env.path-mysql.zsh index bce0f74..5e4e074 100644 --- a/mods-available/developer/env.path-mysql.zsh +++ b/mods-available/developer/env.path-mysql.zsh @@ -1,2 +1,2 @@ export PATH=/usr/local/mysql/bin:$PATH - +export MANPATH="/usr/local/mysql/man:$MANPATH" diff --git a/mods-available/developer/env.path.zsh b/mods-available/developer/env.path.zsh deleted file mode 100644 index 15e2313..0000000 --- a/mods-available/developer/env.path.zsh +++ /dev/null @@ -1,2 +0,0 @@ -export PATH="./bin:/usr/local/bin:/usr/local/sbin:$PATH" -export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH" diff --git a/mods-available/git/env.path.zsh b/mods-available/git/env.path.zsh new file mode 100644 index 0000000..07cf58a --- /dev/null +++ b/mods-available/git/env.path.zsh @@ -0,0 +1,2 @@ +# not sure when this was needed +# export MANPATH="/usr/local/git/man:$MANPATH" diff --git a/mods-available/git/install.bash b/mods-available/git/install.bash index 7130b83..bfc0a6e 100644 --- a/mods-available/git/install.bash +++ b/mods-available/git/install.bash @@ -21,9 +21,9 @@ create_local_config() { fi #local git_authorname git_authoremail - user $lvl "$(fmt bold What is your Github author name?)" + user $lvl "$(fmt bold 'What is your Github author name?')" read -e git_authorname - user $lvl "$(fmt bold What is your Github author email?)" + user $lvl "$(fmt bold 'What is your Github author email?')" read -e git_authoremail sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" "$target_file.example" > "$target_file" diff --git a/mods-available/macos/upgrade_defaults.sh b/mods-available/macos/upgrade_defaults.sh index d9bef8a..a010330 100755 --- a/mods-available/macos/upgrade_defaults.sh +++ b/mods-available/macos/upgrade_defaults.sh @@ -3,6 +3,10 @@ # echo "› sudo softwareupdate -i -a" # sudo softwareupdate -i -a +# This does not survive reboot. Need 'UseKeychain yes' in ~/.ssh/config +# load identities from keychain +# ssh-add -A + # turn on keychain keychain diff --git a/mods-available/zsh/env.path-local.zsh b/mods-available/zsh/env.path-local.zsh new file mode 100644 index 0000000..8793be7 --- /dev/null +++ b/mods-available/zsh/env.path-local.zsh @@ -0,0 +1,2 @@ +export PATH="./bin:/usr/local/bin:/usr/local/sbin:$PATH" +export MANPATH="/usr/local/man:$MANPATH" diff --git a/mods-available/zsh/install.sh b/mods-available/zsh/install.sh index 97a9c1e..4cd43fb 100644 --- a/mods-available/zsh/install.sh +++ b/mods-available/zsh/install.sh @@ -13,3 +13,7 @@ rm -rf /tmp/powerlinefonts # Disable path_helper since we manage $PATH separately [[ ! -x /usr/libexec/path_helper ]] || sudo chmod -x /usr/libexec/path_helper + +# Ignore insecure directories and continue [y] or abort compinit [n]? +sudo chmod -R 755 /usr/local/share/zsh +sudo chown -R root:staff /usr/local/share/zsh From 88981b17ddf11c55c1c5d722c0f556b5900200c3 Mon Sep 17 00:00:00 2001 From: Charlie Gorichanaz Date: Thu, 20 Apr 2017 01:36:15 -0700 Subject: [PATCH 2/6] git-delete-history v1 --- .../git/functions/git-delete-history | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 mods-available/git/functions/git-delete-history diff --git a/mods-available/git/functions/git-delete-history b/mods-available/git/functions/git-delete-history new file mode 100644 index 0000000..a996063 --- /dev/null +++ b/mods-available/git/functions/git-delete-history @@ -0,0 +1,36 @@ +#!/bin/bash + +# Delete all revision history of remote Git repo or Github gist with given hash +# +# Usage: git-delete-history HASH +# Usage: git-delete-history git@github.com:CNG/dotfiles.git +# +# Example for https://gist.github.com/CNG/1019db1a536ad325590f: +# git-delete-history 1019db1a536ad325590f +# +# Inspiration: http://stackoverflow.com/a/26000395/172602 + +set -o errexit + +# Make unique temporary directory +# https://unix.stackexchange.com/a/84980/39419 +temp=`mktemp -d 2>/dev/null || mktemp -d -t 'temp'` + +( + cd "$temp" + if [[ $1 = *.git ]]; then + git clone $1 . + else + git clone git@gist.github.com:$1.git . + fi + git checkout --orphan latest_branch + git add -A + git commit -a --allow-empty-message -m '' + git branch -D master + git branch -m master + git gc --aggressive --prune=all + git push -f origin master +) + +# Delete temporary directory +rm -rf "$temp" From 4dc38c39d0b3e68d9758334abeb2c4830db261c4 Mon Sep 17 00:00:00 2001 From: Charlie Gorichanaz Date: Thu, 20 Apr 2017 01:37:45 -0700 Subject: [PATCH 3/6] git-import: better temp --- mods-available/git/functions/git-import | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mods-available/git/functions/git-import b/mods-available/git/functions/git-import index 95efc38..b1014cb 100644 --- a/mods-available/git/functions/git-import +++ b/mods-available/git/functions/git-import @@ -8,15 +8,11 @@ # - http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/ # - https://gist.github.com/voltagex/3888364 - set -o errexit # Make unique temporary directory -temp=$PWD/_tmp_patches -while [[ -d $temp ]]; do - temp=${temp}_ -done -mkdir "$temp" +# https://unix.stackexchange.com/a/84980/39419 +temp=$(mktemp -d 2>/dev/null || mktemp -d -t 'temp') # Make patches ( From 539fb2206b778aa403108a8030d0933316b57fc4 Mon Sep 17 00:00:00 2001 From: Charlie Gorichanaz Date: Sun, 23 Apr 2017 18:57:37 -0700 Subject: [PATCH 4/6] Use Dvorak, not Dvorak CMD --- mods-available/macos/upgrade_defaults.sh | 4 ++-- mods-available/productivity/upgrade.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mods-available/macos/upgrade_defaults.sh b/mods-available/macos/upgrade_defaults.sh index 1dfa84f..b471727 100755 --- a/mods-available/macos/upgrade_defaults.sh +++ b/mods-available/macos/upgrade_defaults.sh @@ -73,10 +73,10 @@ defaults write com.apple.inputmethod.Kotoeri.plist JIMPrefTypingMethodKey 0 defaults write com.apple.inputmethod.Kotoeri.plist JIMPrefVersionKey 1 # Keyboards -defaults write com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.US" +defaults write com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.Dvorak" defaults write com.apple.HIToolbox.plist AppleEnabledInputSources -array \ '{InputSourceKind = "Keyboard Layout";"KeyboardLayout ID" = 0;"KeyboardLayout Name" = "U.S.";}' \ - '{InputSourceKind = "Keyboard Layout";"KeyboardLayout ID" = 16301;"KeyboardLayout Name" = "DVORAK - QWERTY CMD";}' \ + '{InputSourceKind = "Keyboard Layout";"KeyboardLayout ID" = 16300;"KeyboardLayout Name" = "Dvorak";}' \ '{"Bundle ID" = "com.apple.inputmethod.Kotoeri";"Input Mode" = "com.apple.inputmethod.Japanese";InputSourceKind = "Input Mode";}' \ '{"Bundle ID" = "com.apple.inputmethod.Kotoeri";"Input Mode" = "com.apple.inputmethod.Roman";InputSourceKind = "Input Mode";}' \ '{"Bundle ID" = "com.apple.inputmethod.Kotoeri";"Input Mode" = "com.apple.inputmethod.Japanese.Katakana";InputSourceKind = "Input Mode";}' \ diff --git a/mods-available/productivity/upgrade.sh b/mods-available/productivity/upgrade.sh index bd916a6..953bd85 100644 --- a/mods-available/productivity/upgrade.sh +++ b/mods-available/productivity/upgrade.sh @@ -18,7 +18,7 @@ defaults write com.mizage.Divvy defaultColumnCount 7 defaults write com.mizage.Divvy defaultRowCount 6 defaults write com.mizage.Divvy lastColumnCount 6 defaults write com.mizage.Divvy lastRowCount 6 -defaults write com.mizage.Divvy shortcuts -data 62706c6973743030d401020304050847485424746f7058246f626a65637473582476657273696f6e59246172636869766572d1060754726f6f748001a8090a122b2c333b4355246e756c6cd20b0c0d0e5624636c6173735a4e532e6f626a656374738007a30f1011800280058006dd131415161718191a1b1c1d1e0b1f20212223202425262228292a5f101273656c656374696f6e456e64436f6c756d6e5f101173656c656374696f6e5374617274526f775c6b6579436f6d626f436f646557656e61626c65645d6b6579436f6d626f466c6167735f101473656c656374696f6e5374617274436f6c756d6e5b73697a65436f6c756d6e735a73756264697669646564576e616d654b657956676c6f62616c5f100f73656c656374696f6e456e64526f775873697a65526f777310011000102909120010000010070880030910051006800450d22d2e2f325824636c61737365735a24636c6173736e616d65a230315853686f7274637574584e534f626a6563745853686f7274637574dd131415161718191a1b1c1d1e0b2920342236282425262228292a1027091200100000088003098004dd131415161718191a1b1c1d1e0b29203c223e202425262228292a1025091200100000088003098004d22d2e4445a34546315e4e534d757461626c654172726179574e53417272617912000186a05f100f4e534b657965644172636869766572000800110016001f002800320035003a003c0045004b00500057006200640068006a006c006e0089009e00b200bf00c700d500ec00f80103010b01120124012d012f0131013301340139013b013c013e013f0141014301450146014b0154015f0162016b0174017d0198019a019b01a001a101a301a401a601c101c301c401c901ca01cc01cd01cf01d401d801e701ef01f40000000000000201000000000000004900000000000000000000000000000206 +defaults write com.mizage.Divvy shortcuts -data 62706c6973743030d40102030405064546582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a8070810292a31394155246e756c6cd2090a0b0f5a4e532e6f626a656374735624636c617373a30c0d0e8002800580068007dd11121314150a161718191a1b1c1d1e1f20212223212526271f285873697a65526f77735f100f73656c656374696f6e456e64526f775f101173656c656374696f6e5374617274526f775a7375626469766964656456676c6f62616c5f101273656c656374696f6e456e64436f6c756d6e57656e61626c65645b73697a65436f6c756d6e73576e616d654b65795c6b6579436f6d626f436f64655f101473656c656374696f6e5374617274436f6c756d6e5d6b6579436f6d626f466c61677310061005100008098004100109100780031021120010000050d22b2c2d2e5a24636c6173736e616d655824636c61737365735853686f7274637574a22f305853686f7274637574584e534f626a656374dd11121314150a161718191a1b1c1d1e1f2021221d212526371e3808098004098003101e1200100000dd11121314150a161718191a1b1c1d1e1f2021221d2125263f1f400809800409800310231200100000d22b2c42435e4e534d757461626c654172726179a3424430574e5341727261795f100f4e534b657965644172636869766572d1474854726f6f74800100080011001a0023002d0032003700400046004b0056005d006100630065006700690084008d009f00b300be00c500da00e200ee00f60103011a0128012a012c012e012f013001320134013501370139013b0140014101460151015a01630166016f017801930194019501970198019a019c01a101bc01bd01be01c001c101c301c501ca01cf01de01e201ea01fc01ff02040000000000000201000000000000004900000000000000000000000000000206 defaults write com.mizage.Divvy showMenuIcon 0 defaults write com.mizage.Divvy useDefaultGrid 1 From ceacb192d3ff0af35d1158851f753af568bc6a29 Mon Sep 17 00:00:00 2001 From: Charlie Gorichanaz Date: Wed, 26 Apr 2017 17:32:42 -0700 Subject: [PATCH 5/6] git-import: usage info --- mods-available/git/functions/git-import | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mods-available/git/functions/git-import b/mods-available/git/functions/git-import index b1014cb..a40a028 100644 --- a/mods-available/git/functions/git-import +++ b/mods-available/git/functions/git-import @@ -1,15 +1,24 @@ #!/bin/bash -# Import a file or directory, with history, from a Git repository +# Import a file or directory, with history, from given Git repository into the +# repository within which this function is executed # # Usage: git-import path/to/repo/file/or/folder/to/import # # Inspiration: # - http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/ # - https://gist.github.com/voltagex/3888364 +# +# Also consider: +# - http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/ set -o errexit +if [[ $(git rev-parse --is-inside-work-tree > /dev/null 2>&1) != true ]]; then + echo "Must be inside Git repository work tree where ${1##*/} is to be imported." + return +fi + # Make unique temporary directory # https://unix.stackexchange.com/a/84980/39419 temp=$(mktemp -d 2>/dev/null || mktemp -d -t 'temp') From 321e498f447d2a8ad2e5662440c34cd5d50ab8a6 Mon Sep 17 00:00:00 2001 From: jhelfman Date: Fri, 28 Apr 2017 11:40:49 -0700 Subject: [PATCH 6/6] use /var/tmp in favor of /tmp Writing to /tmp on many systems these days is a ram filesystem and using this location could cause system issues if it is a large repository. --- mods-available/git/functions/git-import | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods-available/git/functions/git-import b/mods-available/git/functions/git-import index a40a028..1c82319 100644 --- a/mods-available/git/functions/git-import +++ b/mods-available/git/functions/git-import @@ -21,7 +21,7 @@ fi # Make unique temporary directory # https://unix.stackexchange.com/a/84980/39419 -temp=$(mktemp -d 2>/dev/null || mktemp -d -t 'temp') +temp=$(mktemp -p /var/tmp -d 2>/dev/null || mktemp -d -t 'temp') # Make patches (