Open In App

Viewing typescript .ts files in Midnight Commander

Last Updated : 26 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

TypeScript is an important and popular framework developed in 2012 that is used in our daily life for the development of various applications. We can simply install any text editor Such as Visual Studio Code or sublime text editor to edit and manage our code files but whenever we are working on Linux or Ubuntu it becomes challenging to open the specific code file using the text editor or code editor that we want a popular file manager used in the Linux system called midnight commander Is used to quickly and efficiently access file in the Linux systems so in this article, we will learn how to open the typescript file using the midnight commander file manager step by step.

Why Typescript Is Better Than Javascript?

As we all know the javascript language is dynamically typed only, meaning that the type checking happens at the execution time. while the typescript language can be strongly typed as well. apart from that the typescript language is considered to be more readable and requires less maintenance as compared to javascript. As you might be aware javascript can be used for both frontend as well as backend, similarly, the TypeScript language also supports the frontend and backend development, this is because the typescript is ultimately compiled into javascript.

Applications of Typescript:

  • Typescript provides static typing and modern ECMAScript features which can reduce bugs in the code.
  • Typescript enhances the code’s maintainability.
  • The typescript language is ideal for large-scale applications.
  • We can develop cross-platform applications using typescript.
  • Typescript can easily work with popular frontend frameworks such as Angular, and React.

How to Install Midnight Commander File Manager in Linux?

We can install Midnight Commander File Manager using two different methods which are stated below:

  • Method 1: Using apt Package Manager
  • Method 2: Using yum Package Manager

Follow the below steps to install Midnight Commander File Manager in Linux by executing the given commands:

Method 1: Using apt Package Manager

Step 1: Running Installation Command

Before understanding how we can open the typescript format using Midnight Commander let us install the Midnight Commander file manager in the Linux system for this all you have to do is run the following command using the terminal in Linux:

apt-get install mc
Running Command to Install

Running Command to Install

Step 2: Confirming the Installation

Once you run the above command in the terminal the midnight commander file manager will be installed and you will be able to access it using the ‘mc‘ command in Linux.

Confirming the Installation

Confirming the Installation

Once you have successfully installed the Midnight Commander file manager you can continue with the following steps to configure the midnight manager to open the typescript format files using a specific text editor in Midnight Commander.

Method 2: Using yum Package Manager

Step 1: Run the yum Command:

Run the following command in your terminal:

yum install mc
Installing using Yum

Installing using Yum

Step 2: Allow the Installation:

After the above step, simply type “Y” when it prompts and asks if you want to proceed with the installation:

Allowing the Installation

Allowing the Installation

Step 3: Open the Midnight Commander:

Once the above steps are completed, you can simply go ahead and type “mc” to let your terminal open the MC file editor for you.

mc
Opening Midnight Commander

Opening Midnight Commander

How To Open Typescript File Using Midnight Commander?

In this section, we will see how we can open or view Typescript files using Midnight Commander. So follow the below steps to view the Typescript File Using Midnight Commander.

Step 1: Find the mc.ext file

To configure the default file opening type for the midnight manager we have to first configure the “mc.ext” File which holds the data about which application will be used by default if the user wants to open certain files once we open the file, we can add a certain line of code to specify that we want to open the typescript or .ts file format using a specific program.

sudo nano /etc/mc/mc.ext
Finding the mc.ext file

Finding the mc.ext file

Step 2: Edit the mc.ext file

Following is the basic format and structure of the ‘mc.ext‘ file:

  • File Type Definition:

File type definition starts with the keyword ‘include’ and then it follows the pattern that defines the file type, the pattern can include wildcards, for example:

include \.txt$include \.jpg$
  • Comments:

You can use “#” to add comments in the mc.ext file:

# This is a comment...
  • Actions for File Types:

Actions are defined using the regex keyword, which is followed by a regular expression pattern which is something that matches the filename. for example:

regex/\.txt$    Open=(vim %f &)    View=(less %f)

Once we run the above command from Step 1 it will open the mc.ext file, as we can see in the image below the file contains various codes and we do not have to touch or change any code we only have to make changes by adding two lines of our code which will allow us to open typescript using our specified text editor.

regex/\.ts$/Open=vim %f
Editing the mc.ext File

Editing the mc.ext File

If you cannot find the file or If it shows no such file or directory then you have to run the ‘whereis mc’ command which will allow you to know the the location where the file exists once you know the file location you can use the upper command with minor improvements on the path location and make sure to redirect the location to the path you got from the ‘where’ command.

Step 3: Restart The Manager And Open the Terminal Again

Once all of these above steps are completed all we have to do is restart the manager using the command ‘quit mc’ open the terminal and run the ‘mc’ command once again which will open the midnight commander manager and then we can open the typescript files using our specified text editor please ensure that you rename ‘vim’ to some other text editor if you want to open typescript using other text editors.

Step 4: Open The Typescript File Using Our Specified Text Editor

Now if you try to open the typescript file using the Midnight Commander Manager, you’ll see that it is not being opened in other default browsers or editors it is being opened in our specified text editor only.

2023-12-19_16-00

Midnight Commander Opened

Once you have selected the folder or directory where you have your typescript files you can just double-click on the file and it will automatically open in the software that you wanted. As you can see in the middle image we have a file named “tssample.ts”.

Opening Typescript File

Opening Typescript File

Now once we double-click on the file it will automatically open in the text editing software of my choice that we have inserted in the code steps above. As you can see in the image below once we double-click on the tssample.ts file it automatically opens in the VIM software:

File Opened

File Opened

Conclusion

In conclusion, we have learned how to set up the midnight commander manager and also how to configure the manager to open the typescript file format using a specified text editor in the Linux systems. refer to this article If you want to open the typescript file using any specified text editor of your choice using Midnight Commander Manager, feel free to ask any queries that you have on the discuss section of this article.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads