Last active
August 13, 2020 11:28
-
-
Save lesstif/4217cd72e828020f823befef4da41a89 to your computer and use it in GitHub Desktop.
symbolic link gnu utils to system command for convenience. for example /usr/local/bin/ggrep symlink to /usr/local/bin/grep
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 bash | |
if ! command -v "gls" &> /dev/null; then | |
echo "GNU coreutils not installed!"; | |
exit 1; | |
fi | |
if [ "$EUID" -ne 0 ];then | |
echo "Please run as root" | |
exit | |
fi | |
FILE_PATH=$(which gls) | |
DIR=$(dirname ${FILE_PATH}) | |
FILES=$(ls ${DIR}/g*) | |
for i in ${FILES};do | |
D=$(dirname ${i}); | |
F=$(basename ${i} | cut -c 2-); | |
if [ "${F}" == "vim" ];then | |
continue; | |
fi | |
ln -sf ${i} ${D}/${F}; | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment