Created
November 28, 2011 20:56
-
-
Save polymorphm/1402011 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# -*- mode: bash; coding: utf-8 -*- | |
cool_hack_encoding="WINDOWS-1251" | |
if [ -z "$1" ] | |
then | |
echo "missing file path" >&2 | |
exit 2 | |
fi | |
file_path=$1 | |
shift | |
if [ ! -f "$file_path" ] | |
then | |
echo "file not exists" >&2 | |
exit 2 | |
fi | |
if iconv "$file_path" >/dev/null 2>&1 | |
then | |
# file is normal! all good :-) | |
exec gedit "$file_path" "$@" | |
else | |
# file is damaged or it is COOL HACKERS!!! :D | |
exec gedit --encoding="$cool_hack_encoding" "$file_path" "$@" | |
fi | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment