Shell: Make typex work on multiple arguments

master
Pierre Neidhardt 2016-06-10 14:48:05 +02:00
parent f16db91d2a
commit 9846e7f47a
1 changed files with 16 additions and 11 deletions

View File

@ -145,20 +145,25 @@ echokeymap () {
## Extended info ## Extended info
typex () { typex () {
local xpath local xpath cmd
if [ $# -ne 1 ] || ! command -v "$1" >/dev/null 2>&1; then
echo "Provide an existing command as parameter." if [ $# -lt 1 ]; then
echo >&2 "Provide an existing command as parameter."
return return
fi fi
if [ -z "$(command -v "$1" 2>/dev/null | grep ^/)" ]; then for i; do
type "$1" cmd="$(command -v "$i" 2>/dev/null)"
return if [ $? -ne 0 ]; then
fi echo "$i does not exist."
elif [ -z "$(echo "$cmd" | grep ^/)" ]; then
xpath="$(type $1 | cut -d' ' -f3)" type "$i"
ls -l "$xpath" else
file "$xpath" | cut -d':' -f2 | cut -b 2- xpath="$(type $1 | cut -d' ' -f3)"
ls -l "$xpath"
file "$xpath" | cut -d':' -f2 | cut -b 2-
fi
done
} }
# Automatically change the directory in shell after closing ranger. # Automatically change the directory in shell after closing ranger.