Skip to content

Instantly share code, notes, and snippets.

@Trucido
Created February 2, 2019 11:55
Show Gist options
  • Select an option

  • Save Trucido/75bbaafdf7b6dfbe9aaca1e0a61e5b34 to your computer and use it in GitHub Desktop.

Select an option

Save Trucido/75bbaafdf7b6dfbe9aaca1e0a61e5b34 to your computer and use it in GitHub Desktop.
if [ -n "${BASH-}${ZSH_NAME-}" ]; then
lsw () {
[ -n "$1" ] && command -v which >/dev/null 2>&1 && (
for f in $(command -p which -a "$@" 2>/dev/null); do {
[ -n "$f" ] && {
command -p ls -alhFNT0 --color "$f" | gawk '{
k = 0;
for (i = 0; i <= 8; i++)
k += ((substr($1, i + 2, 1) ~ /[rwx]/) *2^ (8 - i));
if (k)
printf(" %0o ", k);
print
}'
}
}
done
) | column -t | sort -hr
}
fi
lsw "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment