Created
January 22, 2015 11:32
-
-
Save mcilloni/1bc04a5791ca6fb8c531 to your computer and use it in GitHub Desktop.
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 fish | |
function usage | |
echo "Usage: gcc-alias [on|off]" | |
end | |
if test (count $argv) -ne 1 | |
usage | |
exit 1 | |
end | |
switch $argv | |
case on | |
if test -e /usr/bin/gcc-real | |
echo 'Already on' | |
else | |
echo 'Aliasing gcc' | |
mv -v /usr/bin/gcc /usr/bin/gcc-real | |
and mv -v /usr/bin/g++ /usr/bin/g++-real | |
and mv -v /usr/bin/cc /usr/bin/cc-real | |
and mv -v /usr/bin/c++ /usr/bin/c++-real | |
and ln -sv (which clang) /usr/bin/gcc | |
and ln -sv (which clang++) /usr/bin/g++ | |
and ln -sv (which clang) /usr/bin/cc | |
and ln -sv (which clang++) /usr/bin/c++ | |
end | |
case off | |
if test -e /usr/bin/gcc-real | |
echo 'Restoring gcc' | |
rm -v /usr/bin/gcc | |
and rm -v /usr/bin/g++ | |
and rm -v /usr/bin/cc | |
and rm -v /usr/bin/c++ | |
and mv -v /usr/bin/gcc-real /usr/bin/gcc | |
and mv -v /usr/bin/g++-real /usr/bin/g++ | |
and mv -v /usr/bin/cc-real /usr/bin/cc | |
and mv -v /usr/bin/c++-real /usr/bin/c++ | |
else | |
echo 'Already off' | |
end | |
case '*' | |
usage | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment