fix: bootstrap.sh make it work on WSL

This commit is contained in:
Pratik Tripathy
2024-07-02 13:09:51 +05:30
parent a312e362c1
commit 6a308e0a9e
2 changed files with 49 additions and 50 deletions

View File

@@ -12,19 +12,19 @@ QUIET="n"
CREATE_LINKS="n" CREATE_LINKS="n"
usage() { usage() {
if [ "$1" != "" ]; then if [ "$1" != "" ]; then
echo "" echo ""
echo -e "${CRED}$1${CEND}\n" echo -e "${CRED}$1${CEND}\n"
fi fi
echo "Applies all settings stored in the script's directory to your home directory" echo "Applies all settings stored in the script's directory to your home directory"
echo "" echo ""
echo "Usage: $0 [-q|--quiet] [-l|--create-links]" echo "Usage: $0 [-q|--quiet] [-l|--create-links]"
echo " -q, --quiet No screen outputs" echo " -q, --quiet No screen outputs"
echo " -l, --create-links Creates soft-links to files in the current directory instead of copying them" echo " -l, --create-links Creates soft-links to files in the current directory instead of copying them"
echo "" echo ""
echo "Example: $0 -q --create-links" echo "Example: $0 -q --create-links"
} }
place_dotfile_at_target_location() { place_dotfile_at_target_location() {
@@ -48,50 +48,51 @@ place_dotfile_at_target_location() {
mkdir -p "$target_directory" && [ "$QUIET" = "n" ] && echo "Directory ${target_directory} created" mkdir -p "$target_directory" && [ "$QUIET" = "n" ] && echo "Directory ${target_directory} created"
fi fi
if [ "$CREATE_LINKS" = "y" ]; then if [ "$CREATE_LINKS" = "y" ]; then
# echo "ln -s ${source_file_location} ${target_directory}" # echo "ln -s ${source_file_location} ${target_directory}"
ln -s "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Linked ${file_target_location}" ln -s "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Linked ${file_target_location}"
else else
# echo "cp ${source_file_location} ${target_directory}" # echo "cp ${source_file_location} ${target_directory}"
cp "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Copied ${file_target_location}" cp "$source_file_location" "$target_directory" && [ "$QUIET" = "n" ] && echo "Copied ${file_target_location}"
fi fi
} }
main() { main() {
while [ "${#}" -gt 0 ]; do while [ "${#}" -gt 0 ]; do
case $1 in case $1 in
-q | --quiet) -q | --quiet)
QUIET="y" QUIET="y"
shift shift
;; ;;
-l | --create-links) -l | --create-links)
CREATE_LINKS="y" CREATE_LINKS="y"
shift shift
;; ;;
-h | --help) -h | --help)
echo echo
usage usage
echo echo
exit 0 exit 0
;; ;;
*) *)
usage "Unknown parameter passed: $1" "h" usage "Unknown parameter passed: $1" "h"
exit 1 exit 1
;; ;;
esac esac
done done
case $(uname -a) in case $(uname -a) in
Linux*) Linux*)
OS="linux" OS="kde-neon"
[ "$XDG_CURRENT_DESKTOP" = "KDE" ] && OS="kde-neon"
;; [ "$XDG_CURRENT_DESKTOP" = "KDE" ] && OS="kde-neon"
Darwin*) ;;
OS="macos" Darwin*)
;; OS="macos"
*) ;;
OS="UNSUPPORTED" *)
;; OS="UNSUPPORTED"
;;
esac esac
TS=$(date '+%d_%m_%Y-%H_%M_%S') TS=$(date '+%d_%m_%Y-%H_%M_%S')
@@ -100,18 +101,16 @@ main() {
cd -P "$(dirname "$0")" || exit cd -P "$(dirname "$0")" || exit
# Copy all files in "Common" dotfiles to $HOME directory ("~") # Copy all files in "Common" dotfiles to $HOME directory ("~")
find "./common" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; find "./common" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; do
do file_target_location="${HOME}${file#./common}"
file_target_location="${file/.\/common/$HOME}" source_file_location="${PWD}${file#.}"
source_file_location="${file/./$PWD}"
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS" place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
done done
# Copy platform specific files to $HOME directory ("~") # Copy platform specific files to $HOME directory ("~")
find "./${OS}" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; find "./${OS}" -type f -not -path '*.DS_Store' -not -path '*.directory' | while read -r file; do
do file_target_location="${HOME}${file#./${OS}}"
file_target_location="${file/.\/${OS}/$HOME}" source_file_location="${PWD}${file#.}"
source_file_location="${file/./$PWD}"
place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS" place_dotfile_at_target_location "$source_file_location" "$file_target_location" "$TS"
done done
} }

View File

@@ -49,7 +49,7 @@ if [ "$(uname -s)" = "Linux" ]; then
export CUDA_CACHE_PATH="XDG_CACHE_HOME/nv" export CUDA_CACHE_PATH="XDG_CACHE_HOME/nv"
# Map caps-lock to escape TIP: also added to /etc/profile # Map caps-lock to escape TIP: also added to /etc/profile
setxkbmap -option caps:escape command -v setxkbmap >/dev/null && setxkbmap -option caps:escape
fi fi
export QT_PLUGIN_PATH="$HOME/local/lib/qt/plugins/:" export QT_PLUGIN_PATH="$HOME/local/lib/qt/plugins/:"