Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active April 16, 2023 18:45
Show Gist options
  • Save CMCDragonkai/a897910414206010a7d2633d78504e3d to your computer and use it in GitHub Desktop.
Save CMCDragonkai/a897910414206010a7d2633d78504e3d to your computer and use it in GitHub Desktop.
Winpty Wrapper Script for Cygwin (Makes Windows Apps work in Cygwin) #cli #windows
#!/usr/bin/env sh
# rename this script to whichever windows executable you want to wrap
# make sure to place this script ahead in the PATH lookup obviously
executable="$(command which --all "$(basename "$0")" | grep --max-count=1 --invert-match "$(realpath --no-symlinks "$0")")"
if [ -t 0 -a -t 1 ]; then
exec winpty "$(realpath "$executable")" "$@"
else
exec "$(realpath "$executable")" "$@"
fi
@573
Copy link

573 commented Apr 18, 2018

Just an idea: You could replace basename "$0" with basename "${0%.*}" to allow to rename to i. e. docker.sh for the docker command etc.

@Silverbullet069
Copy link

Your code is perfect. I just add a touch: setup an alias in your terminal that point the program to the script. I use Fish Shell so i will add alias docker '~/.bin/docker.sh'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment