Viewing typescript .ts files in Midnight Commander
Last Updated :
26 Dec, 2023
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
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
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
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
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
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
Step 2: Edit the mc.ext file
Following is the basic format and structure of the 'mc.ext' file:
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$
You can use "#" to add comments in the mc.ext file:
# This is a comment...
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
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.
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
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
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.
Similar Reads
How to execute TypeScript file using command line?
TypeScript is a statically-typed superset of JavaScript that adds optional type annotations and compiles to plain JavaScript. It helps catch errors during development. To execute a TypeScript file from the command line, compile it using tsc filename.ts, then run the output JavaScript file with node.
2 min read
How to Enable Decorators in TypeScript via Command Line ?
Decorators are a feature of TypeScript that allows you to annotate and modify classes, methods, properties, and parameters at design time. They are used to add metadata or behavior to these entities. To enable decorators, you need to configure TypeScript to use the experimentalDecorators flag. In th
5 min read
How to Use Midnight Commander, a Visual File Manager
For Unix-like systems, Midnight Commander (MC) is a potent visual file manager with an easy-to-use interface for organizing and managing files and directories. It is perfect for distant servers and systems without graphical user interfaces because it functions in a text-based environment. The fundam
6 min read
script command in Linux with Examples
The 'script' command in Linux is a versatile tool that allows you to record all terminal activities, including inputs and outputs, making it a valuable resource for developers, system administrators, educators, and anyone who needs to document terminal sessions. This command captures everything disp
5 min read
How to Import Another TypeScript Files?
To use code from one TypeScript file in another, we use the module system introduced in ECMAScript 2015. This allows us to export functions, classes, or variables from one file and import them into another. By doing this, we can reuse code from previous projects without having to rewrite it. This ma
4 min read
How to compile a Typescript file ?
TypeScript is a robust, open-source programming language developed and maintained by Microsoft. As a syntactic superset of JavaScript, TypeScript enhances its foundational language by introducing additional features, including strong typing and object-oriented programming capabilities. Unlike JavaSc
3 min read
scriptreplay command in Linux with Examples
scriptreplay command is used to replay a typescript/terminal_activity stored in the log file that was recorded by the script command. With the help of timing information, the log files are played and the outputs are generated in the terminal with the same speed the original script was recorded. The
3 min read
What are the Modules in Typescript ?
Modules in TypeScript allow you to organize code into reusable, manageable, and logical units by encapsulating functionalities into separate files.They help avoid global namespace pollution by providing scoped declarations.Modules can be imported and exported, enabling code reuse and better maintain
4 min read
How to compile multiple Typescript files into a single file ?
In this article, we will learn how to compile multiple Typescript files into a single file. There are two approaches that can be followed here: Approach 1: Compiling multiple Typescript files into a single JavaScript file. We simply use the following syntax: Syntax: tsc --out outputFile.js typeScrip
4 min read
How to use express in typescript ?
In this article, we will see how to use Express in TypeScript. The TypeScript is a superset of JavaScript that provides type notation with the JavaScript, so we can handle our server, and very scalable for the future. Express is web framework helps to create server-side handling with the help of Nod
2 min read