Skip to content

Instantly share code, notes, and snippets.

@lesstif
Last active August 13, 2020 11:28
Show Gist options
  • Save lesstif/4217cd72e828020f823befef4da41a89 to your computer and use it in GitHub Desktop.
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
#!/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