Skip to content

Instantly share code, notes, and snippets.

@dimaskiddo
Last active July 10, 2020 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaskiddo/8568982e5e763fb466bcf6903fd673ea to your computer and use it in GitHub Desktop.
Save dimaskiddo/8568982e5e763fb466bcf6903fd673ea to your computer and use it in GitHub Desktop.
My WSL Profile.D Customization
# Place your addtional exported variables
# Set Timezone
export TZ=Asia/Jakarta
# Custom Mount for Windows Drive
C:\ /mnt/c/ drvfs defaults,noatime,metadata,uid=1000,gid=1000,umask=0022,fmask=0011 0 0
# Set Locale
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Custom user privilege
user ALL=(ALL:ALL) NOPASSWD: ALL
#
# Windows to WSL Executable Linker
# By Dimas Restu Hidayanto <dimas.restu@student.upi.edu>
#
# WARNING PLEASE DO WITH YOUR OWN RISK
#
# Before applying this .bash_aliases please know that this script
# will link any Windows executable file to WSL directory at /usr/bin
# at every start-up of WSL Shell
#
# Please do the following command before applying
# ...
# sudo usermod -aG root ${USER}
# sudo chmod g=u /usr/bin
# ...
#
# Create array of WSL_ADDITIONAL_PATH
# This variable need to be filled in by the user
WSL_ADDITIONAL_PATH=(
# Place your Windows Executable Path
)
# Loop for every Windows Executable Path
# That defined in WSL_ADDITIONAL_PATH array
for WSL_PATH in ${WSL_ADDITIONAL_PATH[@]}
do
# Check if WSL_PATH is exist
if [[ -d $WSL_PATH ]]
then
# If WSL_PATH exist then search any windows executable file
# Search by extension of '.exe'
for WSL_FILE_EXE in `ls $WSL_PATH/*.exe`;
do
# Check if WSL_FILE_EXE is exist
if [[ -f $WSL_FILE_EXE ]]
then
# If WSL_FILE_EXE exist then extract the executable file name
WSL_FILE_NAME=`echo $WSL_FILE_EXE | awk -F"$WSL_PATH/" '{print $2}' | awk -F".exe" '{print $1}'`
# Check if WSL_FILE_NAME is not exist in '/usr/bin'
if [[ ! -f /usr/bin/$WSL_FILE_NAME ]]
then
# Create a symbolic link from Windows Executable File Path (WSL_FILE_EXE)
# to '/usr/bin/' with extracted executable file name
#
# It will be like 'notepad.exe' linked as 'notepad' in unix style
ln -sf $WSL_FILE_EXE /usr/bin/$WSL_FILE_NAME
fi
# Free WSL_FILE_NAME variable
unset WSL_FILE_NAME
fi
# Free WSL_FILE_EXE variable
unset WSL_FILE_EXE
done
fi
# Free WSL_PATH varible
unset WSL_PATH
done
# Free WSL_ADDTIONAL_PATH variable
unset WSL_ADDITIONAL_PATH
[automount]
enabled = true
mountFsTab = true
options = "metadata"
[network]
generateHosts = true
generateResolvConf = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment