Avoiding gedit’s cannot detect character coding

I found I was often running into the error where gedit would tell me I was trying to open a binary file or somesuch.  It became sufficiently annoying that I spent a bit of time trying to find a way around it.  What I eventually settled on was this bash function added to my .bashrc, the amount of overhead it adds is surprisingly small, even for large files.

function gedit()
	for f in "$@"
		if [ -f "$f" ]
			cat -v "$f" > "$f.bak"
			chmod --reference="$f" "$f.bak"
			mv "$f.bak" "$f"
	/usr/bin/gedit $@
Posted in Tech. Tags: , . Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: