Skip to content

Instantly share code, notes, and snippets.

@h0tw1r3
Last active April 19, 2020 19:47
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 h0tw1r3/8c433cdf6987f7aef5a061bf51239801 to your computer and use it in GitHub Desktop.
Save h0tw1r3/8c433cdf6987f7aef5a061bf51239801 to your computer and use it in GitHub Desktop.
WSL bash powershell alias
__WINSYS32=/mnt/c/Windows/system32
__POWERSHELL=${__WINSYS32}/WindowsPowerShell/v1.0/powershell.exe
powershell() {
if [ -z "${__OEMCP}" ] ; then
__OEMCP=$(${__WINSYS32}/reg.exe query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage" /v OEMCP 2>&1 | sed -n 3p | tr -d '\015' | grep -o '[[:digit:]]*')
fi
$__WINSYS32/chcp.com $__OEMCP >/dev/null
$__POWERSHELL "$@" | tr -d '\015'
$__WINSYS32/chcp.com 65001 >/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment