Automate Repetitive Tasks with Composed Commands
October 9, 2018
When working with text, it’s common to find yourself performing a certain set of actions in the same order, time and time again. By taking advantage of Atom’s hackability, you can eliminate this repetition with a custom command to perform an entire sequence of actions for you.
Thinking in commands
Many of the actions that you perform in Atom are accessible as commands. Whether you’re moving the cursor to the right, saving the current file, closing a tab, or pushing code to a Git repository, each action is a named command. And while you may currently perform those actions using the menu, using the keyboard, or clicking with your mouse, they can also be triggered programatically.
Composing a command to run other commands
Sudo apt install atom; When a new version is released, you can update Atom through the command-line or your desktop Software Update tool. Starting Atom # In the Activities search bar type “Atom” and click on the icon to launch the application. When you start the Atom editor for the first time, a window like the following should appear. Command Lineapm install - for installation of packagesapm clean - for cache removingapm disable - disable packageapm install atom-beautify atom-bootstrap4 at.
- To resolve this, we just located atom.app and copied it into the application folder, then ran the system link commands provided by nwinkler which resoled the issue. Developers can now open atom from the command line with “atom” or open the current projects from their working director with “atom.” Hope this helps!
- Atom is available with Windows installers that can be downloaded from or from the Atom releases page. Use AtomSetup.exe for 32-bit systems and AtomSetup-x64.exe for 64-bit systems. This setup program will install Atom, add the atom and apm commands to your PATH, and create shortcuts on the desktop and in the start menu.
- How to open command prompt in Atom editor? Ask Question Asked 2 years, 11 months ago. Active 2 years, 3 months ago. Viewed 20k times 3. How can I run command prompt in Atom Editor? Do I need to install any package for the same? I could not find any videos or links regarding this issue.
Imagine you often encounter files where you want to change the use of whitespace. For example, assume you want to convert tabs to spaces, trim any trailing whitespace on each line, and convert line endings from Windows-style (CRLF) to Unix-style (LF). You could accomplish this by running these three commands, one after another:
Or, you could combine them into a single “composed” command. Let’s give that a shot.
1. Open your init script
First, activate the command palette, and run the “Application: Open Your Init Script” command.
2. Add a custom command
Next, paste in the snippet below to define your new command:
For the purposes of this example, there are two important items to note in this snippet:
- On line 1, the second argument specifies the name of the new command. In this case, it’s
me:personalize-whitespace
. - Line 3 invokes, the first command (
whitespace:convert-all-tabs-to-spaces
). Once that command completes, line 4 invokes the second command (whitespace:remove-trailing-whitespace
). And once that command completes, line 5 invokes the final command (line-ending-selector:convert-to-LF
).
As you venture into defining your own composed commands, Atom’s API docs can guide you in understanding the details of each function used above as well as the many other functions available to help you customize Atom.
3. Reload Atom to pick up your new command
Each time you open a new Atom window, Atom loads your init script. You can reload Atom to pick up changes you’ve made to your init script. To do so, activate the command palette, and run the “Window: Reload” command.
4. Use your new command
Now your new command is ready for action. Open a file where you want to run the new command (example file), activate the command palette, find your new command by name (“Me: Personalize Whitespace”), and run it:
Context matters
Atom Install Shell Commands Windows
Note that some commands are designed to be executed only in specific contexts. For example, the line-ending-selector:convert-to-LF
command assumes that there is an active text editor in your Atom workspace. If you run that command when there are no active text editors open in Atom, the command obviously can’t change any line endings.
Atom Command Line Options
If you see that a command isn’t functioning as expected, it can be helpful to look at the command’s implementation to understand what assumptions the command is making.
Next steps
Atom Command Line Options
With just the few simple steps shown above, you’re ready to combine any repetitive sequence of commands into a single composed command:
- Check out the command palette to see the hundreds of commands available to you, including commands from the community packages you’ve installed.
- Want to get things done even faster? You can also define a keyboard shortcut for your new command.
- Explore public init scripts to see how other people combine commands to improve their workflows. You might just find inspiration for your own composed commands.
- Need help? Hop into the Atom Slack or ask for help on the forum.
How To Open Atom Command Line
Atom Command Line Tool
Happy automating!