SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Features and/or Improvements => Topic started by: rowbearto on September 20, 2017, 06:27:34 pm

Title: Determine language from hashbang !# at top of extension-less files
Post by: rowbearto on September 20, 2017, 06:27:34 pm
I have many scripts that don't have extensions, such as python scripts or bash scripts. They start with a line as follows:

#!/usr/bin/env bash
#!/bin/bash
#!/usr/bin/env python
#!/bin/python
#!/bin/ksh

As these files don't have an extension, SE doesn't know they are a bash, python or ksh script.

It would be good if SE could look for the #! line at the top of extension-less scripts to help figure out what type of file it is, so that it can get the color coding right.
Title: Re: Determine language from hashbang !# at top of extension-less files
Post by: Clark on September 22, 2017, 02:05:28 am
SlickEdit supports recognizing all of the examples you gave.

What I did noticed is that if you create the file in SlickEdit, save it, close it, and the reopen the file. You get plain text mode because SlickEdit save/restores (perfile.xml and vrestore.slk) the mode it was the last time you edited it. Just select the mode, if you create the file in SlickEdit.
Title: Re: Determine language from hashbang !# at top of extension-less files
Post by: rowbearto on September 22, 2017, 11:43:18 am
OK - that must be the reason, as I create most of my scripts in SE.

How about creating a command to re-determine the type from the hashbang so that I don't have to go through all the clicks to re-classify the file? I can just run this new command instead (and bind it to a key).
Title: Re: Determine language from hashbang !# at top of extension-less files
Post by: Clark on September 25, 2017, 12:32:58 am
Try this macro.
Title: Re: Determine language from hashbang !# at top of extension-less files
Post by: rowbearto on September 25, 2017, 01:09:56 pm
Works great! Thanks!