- Create symlinks in
~/bin
# Create ~/bin if it doesn't exist
[ ! -d "$HOME/bin" ] && mkdir "$HOME/bin"
# link windows exe files
ln -snf "$(which pscp.exe)" "$HOME/bin/scp"
ln -snf "$(which ssh.exe)" "$HOME/bin/ssh"
ln -snf "$(which scp.exe)" "$HOME/bin/scp"
ln -snf "$(which gpg.exe)" "$HOME/bin/gpg"- Then add these lines to
~/.zshenv. This is needed because runningwsl commandwill create a non-login, non-interactive shell andzshwill source this file in that scenario.
# Prepend $HOME/bin to PATH
if [[ ! ":$PATH:" == *":$HOME/bin:"* ]]; then
export PATH="$HOME/bin:$PATH"
fi- The above solution will works only on
zsh, other shells likefishorcshmight source different files. - For bash however, there no way to automatically source a file in a non-login non-interactive shell. So one can directly symlink the executable in
/usr/bin. However it is not recommended as it modifies global executables.
# Back up the WSL gpg executable
sudo mv /etc/bin/gpg /etc/bin/gpg.old
# link the Windows gpg executable
sudo ln -snf "$(which gpg.exe)" "/etc/bin/gpg"ref: