Last active
April 16, 2023 18:45
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
Just an idea: You could replace
basename "$0"
withbasename "${0%.*}"
to allow to rename to i. e. docker.sh for the docker command etc.