commit 100162f4b0b181045e6cfa6443873eb92511a4ff
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2022-09-10T13:26:51Z |
| subject | Fixed mkuserdirs not working properly |
commit 100162f4b0b181045e6cfa6443873eb92511a4ff
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2022-09-10T13:26:51Z
Fixed mkuserdirs not working properly
---
bash/sources/22_win-setups | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/bash/sources/22_win-setups b/bash/sources/22_win-setups
index 3b55611..ff82f55 100755
--- a/bash/sources/22_win-setups
+++ b/bash/sources/22_win-setups
@@ -2,15 +2,28 @@
function mkuserdirs {
- local PROFILE PKG_DIR i
- PROFILE=$( cygpath $USERPROFILE )
- for i in $( ls $PROFILE | grep -o "^[A-Z][a-z]\+$" ); do
- ln -vs "$PROFILE/$i" $HOME/
+ local PKG_DIR i IFS=$'\n'
+ for i in $( reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" \
+ | grep "^ [A-Za-z ]\+" \
+ | tr -d '\r' \
+ | sed -e "s/.\+REG_EXPAND_SZ[ ]\+//g"
+ ); do
+
+ if [[ "$i" =~ .*"\\AppData\\".* ]]; then
+ continue
+ fi
+
+ if [[ "$i" =~ "%USERPROFILE".* ]]; then
+ i=$USERPROFILE${i/\%USERPROFILE\%/}
+ fi
+
+ ln -vs "$( cygpath "$i" )" $HOME/
done
# Package Directory
- PKG_DIR="$APPDATA/../Local/Packages"
+ PKG_DIR=$( cygpath "$APPDATA/../Local/Packages" )
if [ -d "$PKG_DIR" ]; then
ln -vs "$PKG_DIR" $HOME/
fi
+
}