forked from alanlivio/cli-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos_win.bash
More file actions
69 lines (60 loc) · 2.29 KB
/
os_win.bash
File metadata and controls
69 lines (60 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -- essentials --
if [[ -n $WSL_DISTRO_NAME ]]; then
alias winpath='wslpath -m'
alias winget='winget.exe'
alias explorer='explorer.exe'
alias powershell='powershell.exe'
function start() {
type -p wslview >/dev/null || sudo apt install wslu
wslview $@
}
else
alias winpath='cygpath -m'
fi
# -- load funcs from os_win.ps1 as aliases --
function _ps_call() {
powershell.exe -noprofile -c "& { . $(wslpath -w $BH_DIR/os_win.ps1); $* }"
}
function _ps_def_func() {
eval 'function '$1'() { _ps_call' $1 '$*; }'
}
_regex_no_underscore_func='function\s([^_][^{]+)\('
while read -r line; do
if [[ $line =~ $_regex_no_underscore_func ]]; then
func=${BASH_REMATCH[1]}
if [[ ! $func =~ ^(log_msg)$ ]]; then # also exists in win.ps1
_ps_def_func $func
fi
fi
done <$BH_DIR/os_win.ps1
function wsl_install_cuda_cudnn() {
# https://canonical-ubuntu-wsl.readthedocs-hosted.com/en/latest/tutorials/gpu-cuda/
sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin /tmp/cuda-wsl-ubuntu.pin
sudo mv /tmp/cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub
sudo add-apt-repository -y 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /'
# https://itsfoss.com/key-is-stored-in-legacy-trusted-gpg/
sudo apt-key export 3BF863CC | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/cudatools.gpg
sudo apt-get update
sudo apt-get -y install cuda nvidia-cudnn
}
function wsl_fix_libcuda_so_slink() {
# https://github.com/microsoft/WSL/issues/5663
(
cd /usr/lib/wsl/lib
sudo rm libcuda.so
sudo rm libcuda.so.1
sudo ln -s libcuda.so.1.1 libcuda.so
sudo ln -s libcuda.so.1.1 libcuda.so.1
)
}
# -- msys2 --
if type -p pacman >/dev/null; then
alias msys2_search='pacman -s --noconfirm'
alias msys2_show='pacman -Qi'
alias msys2_list_installed='pacman -Qqe'
alias msys2_install='pacman -S --noconfirm'
alias msys2_uninstall='pacman -R --noconfirm'
alias msys2_use_same_home='echo db_home: windows >>/etc/nsswitch.conf'
fi