Skip to content

Instantly share code, notes, and snippets.

@jameswebb68
Created January 3, 2014 19:26
Show Gist options
  • Save jameswebb68/8244719 to your computer and use it in GitHub Desktop.
Save jameswebb68/8244719 to your computer and use it in GitHub Desktop.
Returns the Windows file details for any file using Cygwin bash (actual r-click-properties-info) to the term. ex: finfo notepad.exe finfo "C:\windows\system32\notepad.exe" finfo /cygdrive/c/Windows/System32/notepad.exe finfo "/cygdrive/c/Program Files/notepad.exe" finfo ../notepad.exe
#get file details from windows via wmic wmi formatted call
finfo() {
[[ -e "$(cygpath -wa "$@")" ]] || { echo "bad-file"; return 1; }
echo "$(wmic datafile where name=\""$(echo "$(cygpath -wa "$@")" | sed 's/\\/\\\\/g')"\" get /value)" |\
sed 's/\r//g;s/^M$//;/^$/d' | awk -F"=" '{print $1"=""\033[1m"$2"\033[0m" }'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment