Quicklook Text-Based Files With No File Extension

This following AppleScript will generate a Quicklook preview for any text-based file(with no file extension) for the currently selected file in Finder.

set quickLookTempFileLocation to "/private/tmp/"

tell application "Finder"
	set selectedFile to (item 1 of (get selection)) as alias
	set {selectedName, nameExtension} to ({name, name extension} of selectedFile)
end tell

set quickLookTempFile to quoted form of (quickLookTempFileLocation & selectedName & ".txt")

do shell script "cat " & quoted form of POSIX path of selectedFile & " > " & ¬
	quickLookTempFile & " ; /usr/bin/qlmanage -p " & ¬
	quickLookTempFile & " && rm -f " & quickLookTempFile

I have also found that occasionally some of my .scpt or .scptd files don’t generate Quicklook previews of those selected files in Finder, correctly. This extended version of the first script addresses those files also.

set quickLookTempFileLocation to "/private/tmp/"

tell application "Finder"
	set selectedFile to (item 1 of (get selection)) as alias
	set {selectedName, nameExtension} to ({name, name extension} of selectedFile)
end tell

set quickLookTempFile to quoted form of (quickLookTempFileLocation & selectedName & ".txt")

if nameExtension is in {"scpt", "scptd"} then
	do shell script "osadecompile " & quoted form of POSIX path of selectedFile & " > " & ¬
		quickLookTempFile & " ; /usr/bin/qlmanage -p " & ¬
		quickLookTempFile & " && rm -f " & quickLookTempFile
else
	do shell script "cat " & quoted form of POSIX path of selectedFile & " > " & ¬
		quickLookTempFile & " ; /usr/bin/qlmanage -p " & ¬
		quickLookTempFile & " && rm -f " & quickLookTempFile
end if

[center]
[/center]
These solutions create a temporary file but that temporary file gets deleted when the script stops running.