Pop Mood Daily
updates /

How to run any mac terminal command with a keyboard shortcut

Justin Pot has been writing about technology for over a decade, with work appearing in Digital Trends, The Next Web, Lifehacker, MakeUseOf, and the Zapier Blog. He also runs the Hillsboro Signal, a volunteer-driven local news outlet he founded. Read more.

How to run any mac terminal command with a keyboard shortcut

Are there particular Terminal commands you find yourself running several time a day? Do you wish you could trigger them quickly, with just a keystroke?

As it turns out, you can! We’ve shown you all the Mac keyboard shortcuts you should be using, but this gives you an opportunity to invent your own keyboard shortcut to do just about anything you can imagine with the Terminal. There are two main ways to accomplish this, so let’s get started.

The Easy Way: iCanHazShortcut

The easiest way to add custom keyboard shortcuts for specific commands is to download iCanHazShortcut, a free Mac application with a terrible name. Installing couldn’t be simpler: just drag the icon to your Applications folder.

How to run any mac terminal command with a keyboard shortcut

Then fire up the application. You’ll find it in the menu bar.

How to run any mac terminal command with a keyboard shortcut

Click “Shortcuts” to bring up a list of current shortcuts.

How to run any mac terminal command with a keyboard shortcut

Looks like we don’t have any shortcuts defined right now. To change this, click the green arrow at bottom-right. This will bring up a two fields: one for the keyboard shortcut, another for the command you’d like to trigger.

How to run any mac terminal command with a keyboard shortcut

Click the first field, then hit whatever keyboard shortcut you’d like to use. Next, click the second field and enter whatever command you’d like to trigger. For our example, we’re going to use date “+The time is %H:%M” | say which makes our Mac say the current time out loud.

Click the green checkmark at bottom-right, and your done! Your keyboard shortcut will now run your command at will.

How to run any mac terminal command with a keyboard shortcut

Note that you can configure a few more things, if you like. The icon menu bar icon can be disabled, allowing you to run this application in the background. You can also set the application to run when you start up your computer.

The (Slightly) Harder, But Built-In Way: Automator

If you’d rather not use a third party application to trigger Terminal commands, there’s another method, which works because macOS lets you set custom keyboard shortcuts for everything. To get started we’re going to launch Automator, which you’ll find in your Applications folder. We’re going to create a new Service for your Mac.

How to run any mac terminal command with a keyboard shortcut

In the Actions section, click the “Utilities” sub-section, then drag “Run Shell Script” over to your workflow.

How to run any mac terminal command with a keyboard shortcut

Next, paste your command.

How to run any mac terminal command with a keyboard shortcut

Again I’ve used date “+The time is %H:%M” | say , which will read the current time out loud, but you can use whatever command you like. Save your workflow with a name you’ll recognize, and we’re done with Automator.

Next, head to System Preferences > Keyboard > Shortcuts. In the left panel click “Services,” and scroll down until you see the service you just created—it should be under the “General” section.

How to run any mac terminal command with a keyboard shortcut

After setting this, you can trigger your service using whatever shortcut you defined. And because this is all native to the operating system itself, there’s no program you need to leave running in the background.

How to run any mac terminal command with a keyboard shortcut

How to run any mac terminal command with a keyboard shortcut

Mac’s command line interface, Terminal, ships with a bewildering array of commands. Google searches and man pages will help you get a better sense of what your machine is capable of, but they won’t tell you the name of every command on your Mac. If you want to see all available commands at once, or if you’re trying to find a particular command, you can follow the instructions below to find out all the Terminal commands on your Mac.

Viewing All Available Terminal Commands

1. Open Terminal (Applications/Utilities/Terminal.app).

How to run any mac terminal command with a keyboard shortcut

2. Hold down the “Escape” key (or button on a MacBook Pro Touchbar) for a second or two.

3. When you see the prompt that says “Display all 1456 possibilities?” press the “Y” key. Note that the exact number of available commands will vary based on your installation, but it should be approximately 1400.

How to run any mac terminal command with a keyboard shortcut

4. Terminal will now list all of the available commands in alphabetical order. You can navigate down the list line by line by pressing the “Enter” key. There’s no way to navigate backwards, so read slowly.

How to run any mac terminal command with a keyboard shortcut

5. To return to the command prompt, press “Control + C” or the “Delete” key to exit the list of available commands. You can also continue pressing the “Enter” key until you’ve scrolled through all the commands, at which point you’ll be automatically returned to the command prompt.

How to run any mac terminal command with a keyboard shortcut

Generating a List of Commands with Compgen

What if you don’t want to see a list of commands in the terminal window, but you want to produce a text file containing all of the available Terminal commands? You can use compgen to generate a list of all available commands and then send the result of the command to a new text file. You can also use grep to search compgen’s output quickly.

1. Open Terminal (Applications/Utilities/Terminal.app).

2. To list all available Terminal commands (and command aliases) instantaneously, type in compgen -ac and press “Enter.”

3. If you’d rather create a text file containing a list of all those commands, type the following command and press Enter:

This will send the compgen command’s output to a new text file named “commandlist.txt.” That file will then appear in your current working directory (your home directory, by default).

More Compgen Options

1. Use compgen -b to display only built-in commands. These are the commands that are “built-in” to Bash, macOS’s default command line interpreter, like cd and kill .

2. Search compgen’s output using grep , which is another terminal command search for text strings. For example, to find every command with “net” in the name, type the following command and press Enter:

This will display a short list of all the commands with “net” in the title.

How to run any mac terminal command with a keyboard shortcut

3. Use compgen -k to list all available “keywords.” These keywords are commands that you can use when writing command line scripts for bash to execute.

How to run any mac terminal command with a keyboard shortcut

Conclusion

To manually search through a list of all available Terminal commands, use the Escape key trick. This isn’t the best way to find a particular command, however. For a searchable and exportable directory of available commands, use compgen along with one of its several command options.

Our latest tutorials delivered straight to your inbox

Justin Pot has been writing about technology for over a decade, with work appearing in Digital Trends, The Next Web, Lifehacker, MakeUseOf, and the Zapier Blog. He also runs the Hillsboro Signal, a volunteer-driven local news outlet he founded. Read more.

How to run any mac terminal command with a keyboard shortcut

Are there particular Terminal commands you find yourself running several time a day? Do you wish you could trigger them quickly, with just a keystroke?

As it turns out, you can! We’ve shown you all the Mac keyboard shortcuts you should be using, but this gives you an opportunity to invent your own keyboard shortcut to do just about anything you can imagine with the Terminal. There are two main ways to accomplish this, so let’s get started.

The Easy Way: iCanHazShortcut

The easiest way to add custom keyboard shortcuts for specific commands is to download iCanHazShortcut, a free Mac application with a terrible name. Installing couldn’t be simpler: just drag the icon to your Applications folder.

How to run any mac terminal command with a keyboard shortcut

Then fire up the application. You’ll find it in the menu bar.

How to run any mac terminal command with a keyboard shortcut

Click “Shortcuts” to bring up a list of current shortcuts.

How to run any mac terminal command with a keyboard shortcut

Looks like we don’t have any shortcuts defined right now. To change this, click the green arrow at bottom-right. This will bring up a two fields: one for the keyboard shortcut, another for the command you’d like to trigger.

How to run any mac terminal command with a keyboard shortcut

Click the first field, then hit whatever keyboard shortcut you’d like to use. Next, click the second field and enter whatever command you’d like to trigger. For our example, we’re going to use date “+The time is %H:%M” | say which makes our Mac say the current time out loud.

Click the green checkmark at bottom-right, and your done! Your keyboard shortcut will now run your command at will.

How to run any mac terminal command with a keyboard shortcut

Note that you can configure a few more things, if you like. The icon menu bar icon can be disabled, allowing you to run this application in the background. You can also set the application to run when you start up your computer.

The (Slightly) Harder, But Built-In Way: Automator

If you’d rather not use a third party application to trigger Terminal commands, there’s another method, which works because macOS lets you set custom keyboard shortcuts for everything. To get started we’re going to launch Automator, which you’ll find in your Applications folder. We’re going to create a new Service for your Mac.

How to run any mac terminal command with a keyboard shortcut

In the Actions section, click the “Utilities” sub-section, then drag “Run Shell Script” over to your workflow.

How to run any mac terminal command with a keyboard shortcut

Next, paste your command.

How to run any mac terminal command with a keyboard shortcut

Again I’ve used date “+The time is %H:%M” | say , which will read the current time out loud, but you can use whatever command you like. Save your workflow with a name you’ll recognize, and we’re done with Automator.

Next, head to System Preferences > Keyboard > Shortcuts. In the left panel click “Services,” and scroll down until you see the service you just created—it should be under the “General” section.

How to run any mac terminal command with a keyboard shortcut

After setting this, you can trigger your service using whatever shortcut you defined. And because this is all native to the operating system itself, there’s no program you need to leave running in the background.

Чтобы запускать быстрые команды из командной строке на Mac, можно использовать приложение «Терминал». Запуск быстрых команд из командной строки не отличается от запуска команд из приложения «Быстрые команды»: Вы точно так же можете передавать во входных данных документы, изображения, текст и другое содержимое. Затем быстрая команда может передать выходные данные другому процессу или записать их в файл.

Почти все команды можно запускать из командной строки, однако наиболее эффективны те команды, которые не отображают оповещения и не запрашивают входные данные. Когда быстрая команда запрашивает входные данные, процесс командной строки приостанавливается и ожидает входных данных от пользователя. Вместо того чтобы использовать действие «Выбрать», можно настроить быструю команду так, чтобы она могла получать только определенное содержимое во входных данных и запрашивала содержимое в случаях, когда входные данные не получены. См. раздел Ограничение типов входных данных для быстрой команды на Mac при запуске из другого приложения. Если разрешить быстрой команде получать изображения во входных данных и спрашивать, если их нет, это позволит запускать такую быструю команду из любого места в системе и показывать оповещение пользователю, только когда это необходимо.

Запуск быстрых команд из командной строки

Для запуска быстрых команд используется команда shortcuts . Чтобы запустить быструю команду с названием «Объединить изображения», необходимо учитывать пробел в этом названии. Для этого оформите текст команды одним из следующих способов:

shortcuts run “Объединить изображения” или shortcuts run Объединить\ изображения

Изображения можно передавать быстрой команде с помощью флага -i или –input-path . Пути изображений можно передавать в абсолютном или относительном формате с пробелами в качестве разделителей. Также можно использовать символы подстановки. Чтобы запустить быструю команду «Объединить изображения» и передать ей во входных данных все файлы JPEG на рабочем столе, можно использовать следующую команду:

shortcuts run “Объединить изображения” -i

Примечание. Когда Вы передаете путь файла с разделением прямой чертой ( | ), путь обрабатывается как текст. Используйте флаг -i : он сигнализирует о том, что входные данные нужно обработать как путь файла.

Если быстрая команда заканчивается действием, которое передает текст, изображения или другой файл в выходных данных, или если Вы используете действие «Остановить и получить выходные данные», можно добавить флаг -o или –output-path , чтобы записать выходные данные в файл. К примеру, можно передать текст из выходных данных в файл PDF или TXT, указав путь с подходящим расширением файла. Чтобы запустить быструю команду «Объединить изображения», объединяющую все изображения на рабочем столе в файл PNG, можно использовать следующую команду:

shortcuts run “Объединить изображения” -i

Если в быстрой команде есть действие, в результате выполнения которого передаются выходные данные или в котором есть действие «Остановить и получить выходные данные», эти данные можно направить в другую команду. Для этого используйте символ | . Можно обозначить тип выходных данных (например, сделать так, чтобы выходные данные получались в формате JPEG вместо текста). Для этого используйте флаг –output-type с унифицированным индикатором типа. Чтобы запустить быструю команду «Объединить изображения», объединяющую все изображения на рабочем столе и передающую результат другой команде в формате RTFD, можно использовать следующую команду:

shortcuts run “Объединить изображения” -i

/Desktop/*.jpg –output-type com.apple.rtfd | …

Список унифицированных индикаторов типа можно найти на странице System-Declared Uniform Type Identifiers.

Команда shortcuts на выходе вернет 0 в случае успешного запуска или 1 в случае ошибки.

Просмотр списка быстрых команд, доступных из командной строки

Прежде чем запускать сложные автоматизации, рекомендуется уточнить, существует ли быстрая команда, которую Вы хотите использовать. Когда графический пользовательский интерфейс отсутствует, может быть полезно просмотреть список доступных быстрых команд. Список доступных быстрых команд можно просмотреть с помощью команды shortcuts list . Вы также можете просматривать списки быстрых команд, которые хранятся в настроенных пользователем папках. Используйте флаг -f и укажите название настроенной папки. Например, если Вы хотите увидеть список со всеми быстрыми командами, которые есть в настроенной Вами папке «Музыка», используйте следующее:

shortcuts list -f Музыка

Примечание. Флаг -f можно использовать только с настроенными папками: с его помощью не удастся просмотреть список команд в автоматически созданных папках, например «Быстрые действия», «Строка меню» и другие.

Чтобы вместо быстрых команд отобразить все папки быстрых команд, которые у Вас есть, можно использовать следующее:

shortcuts list –folders

Просмотр быстрых команд из командной строки

Можно открыть быструю команду в редакторе с помощью команды shortcuts view . Это может быть полезно для поиска и устранения ошибок в быстрой команде, которая работает не так, как задумано. Чтобы просмотреть быструю команду с названием «Плохая команда», используйте следующее:

shortcuts view “Плохая команда”

Подпись быстрых команд из командной строки

Можно подписать экспортированную быструю команду с помощью команды shortcuts sign . Когда Вы подписываете быструю команду, Apple получает ее копию для проверки (чтобы защитить ее от изменений после отправки). Для подписи быстрых команд можно использовать следующие режимы.

Все. Вашу быструю команду сможет импортировать любой человек.

Для знакомых со мной. Вашу быструю команду смогут импортировать только те, у кого Вы есть в контактах. Ваши контактные данные будут добавлены в файл быстрой команды.

Чтобы подписать быструю команду с названием «Поделиться», используйте следующее:

shortcuts sign –mode people-who-know-me –input “Поделиться.shortcut” –output “Поделиться signed.shortcut”

Информацию об отправке быстрых команд см. в разделе Отправка быстрых команд на Mac.

Несмотря на то что можно использовать x-callback-url для запуска и просмотра быстрых команд из командной строки, следует использовать команду shortcuts , когда требуется обеспечить высокую точность входных или выходных данных. См. Схемы URL в приложении «Быстрые команды» на Mac.

Justin Pot has been writing about technology for over a decade, with work appearing in Digital Trends, The Next Web, Lifehacker, MakeUseOf, and the Zapier Blog. He also runs the Hillsboro Signal, a volunteer-driven local news outlet he founded. Read more.

How to run any mac terminal command with a keyboard shortcut

Many Mac users spend their entire lives in the Terminal, but most of us only open it occasionally. Using a mouse to open a text-based interface feels weird, however. What if there was a way to always have the Terminal at the ready, triggered by a single keyboard shortcut?

You can set this up yourself easily thanks to iTerm, an alternative to the default Terminal that’s customizable in all sorts of ways. It’s really the best way to power up your macOS Terminal.

One of my favorite features is the hotkey window, which I’ll use here to create the quickly-triggered full screen Terminal of my dreams. Here’s what that looks like:

Excited? Let’s get started.

Step One: Download and Install iTerm

The first step is simple: head to the iTerm website and download the program. You can install the program by unzipping it and draging the icon to Applications.

How to run any mac terminal command with a keyboard shortcut

When you run iTerm, you’ll notice it’s not that different from your default Terminal.

How to run any mac terminal command with a keyboard shortcut

There’s a lot of hidden functionality in the settings, however, which we’ll get to now.

Step Two: Enable The Hotkey Window

Click “iTerm2” in the menu bar, choose the “Preferences” option, and then head to the “Keys” section. At the bottom-left you’ll see a button called “Create a Dedicated Hotkey Window.” Tap this and a menu appears.

How to run any mac terminal command with a keyboard shortcut

Configure this to your liking. I prefer the keyboard shortcut Option+Space, because it’s similar to Spotlight without overlapping, but you can use anything you want. You can also set this window to open when you click the iTerm dock icon, but that’s up to you. Click “OK” when you’re done.

How to run any mac terminal command with a keyboard shortcut

Use the keyboard shortcut you just signed and you’ll see the default hotkey window, which takes up half the screen.

How to run any mac terminal command with a keyboard shortcut

If you like the way this looks and works, congrats: you can stop here. If you want the full screen large Terminal seen in my screenshots above, however, you’ve got a bit more work to do.

Step Three: Change The Look and Feel

Head to the Profiles section in the Preferences window and make sure the “Hotkey Window” profile is selected.

How to run any mac terminal command with a keyboard shortcut

Next head to the “Text” section in the right panel. If you want the full screen Terminal experience I recommend changing the font to something bigger, because otherwise everything is buried in a sea of black space. I went with 18pt Monaco, but use whatever font combination you like.

How to run any mac terminal command with a keyboard shortcut

Next head to Window and set the “Style” dropdown to Fullscreen.

How to run any mac terminal command with a keyboard shortcut

Also feel free to adjust the Transparency and Blur settings until everything looks just right. You could just as easily forgo the transparency and have a black background. Here’s how mine turned out:

How to run any mac terminal command with a keyboard shortcut

If a single Terminal isn’t enough, you can split the screen vertically with Command+D (or horizontally with Command+Shift+D).

How to run any mac terminal command with a keyboard shortcut

You can switch between panes using Command+Option and the arrow keys. This way, you can have several different things running, all of them easy to pull up with keyboard shortcuts. You’ll wonder how you ever lived without it.

If you’re not sure how to use this, don’t worry: there are all sorts of cool commands you can use, allowing you to do things like listen to music or even update apps without opening the Mac App Store. Get to it!

I am using Alfred and hence I don’t have any use for the Cmd + Space keyboard shortcut. I want to invoke terminal using that shortcut. Just like in Ubuntu, when you press Ctrl + Alt + T

I don’t want to use Alfred to start the terminal. I just want to press Cmd + Space and I want the terminal to appear just like it would in Ubuntu.

Is there a way to start terminal like that in OS X Mavericks?

How to run any mac terminal command with a keyboard shortcut

10 Answers 10

Keyboard Maestro

You can do this with Keyboard Maestro, using a macro such as this:

How to run any mac terminal command with a keyboard shortcut

Alfred

You can set up a custom hotkey to launch an app using a workflow:

How to run any mac terminal command with a keyboard shortcut

Go to the workflows tab, create a new workflow and add a hotkey and a ‘launch apps’ with Terminal selected as the app to launch.

KeyRemap4MacBook

You can use KeyRemap4MacBook with a private.xml such as this:

Automator Service

You can create a service in Automator:

How to run any mac terminal command with a keyboard shortcut

…then in System Preferences → Keyboard → Shortcuts → Services you can assign a keyboard command to run it.

5 months late, but I think this bit is useful.

As far as an automator solution goes this is probably a little better. Instead of running finder just use an applescript. ie add action “Utilities Run AppleScript”. Run this script:

This will not only open terminal, when run multiple times it will open multiple windows. Then just add a hotkey for it in services (under keyboard), as explained in George Garside’s answer.

I was able to achieve the same behavior as Ubuntu Ctrl + Alt + T by combining following two steps:

Set up an Automator service to open iTerm2 : Open Automator app, select “Quick Action” from the menuHow to run any mac terminal command with a keyboard shortcut and assign it a keyboard shortcut Ctrl + command + T . How to run any mac terminal command with a keyboard shortcutThis will open the app but won’t open any more windows (so if the app is open the keyboard shortcut doesn’t have an effect).

Add an iTerm2 key mapping to open subsequent windows. In iTerm2 preferences: How to run any mac terminal command with a keyboard shortcut

There you have it, no external app needed but far from straight forward

You can do this very easily with BetterTouchTool:

How to run any mac terminal command with a keyboard shortcut

As the “Specific Application” to open the selected/active folder with, I chose Terminal.

Thus when I use the keyboard shortcut specified (I use option-‘), the current Folder is opened in the Terminal.

How to run any mac terminal command with a keyboard shortcut

In iTerm2, you can go to iterm preferences, keys -> hotkeys -> set in your key command.

How to run any mac terminal command with a keyboard shortcut

If you want to use iTerm (iTerm2), do the same as @tlane’s answer, except use this for the AppleScript:

How to run any mac terminal command with a keyboard shortcut

The closest I’ve come with macOS as-is and no mods or 3rd party software:

  1. Cmd + Shift + u
    Opens the Utilities sub-folder in /Applications/ (where Terminal.app lives)
  2. t
    Selects the Terminal.app
  3. Cmd + Option + o
    Opens the Terminal.app and closes the finder window.

This has worked since day one with every OSX release.

With a slight modification to System Preferences >> Keyboard >> Shortcuts::Services , this is a close runner up, but it requires that you select a folder first: How to run any mac terminal command with a keyboard shortcut

. for example from the Finder at login you could

    Cmd + Up Arrow and your home directory

/ would open in the Finder, then
Cmd + Up Arrow again to the /Users/ directory. Now your user home directory

/ should be selected (if in list or icon view, not column).
If you then hit your custom “Services” key combination (e.g. Ctrl + Opt + Cmd + t ) to launch a “New Terminal at Folder” the Terminal.app will launch at your home directory

Lastly, in an effort to get something as close as possible to launching a Terminal.app window from the Finder with Ctrl + Alt + t . Since the Option key is kinda equivalent to the Alt key. using the “Services” custom key combo to launch a “New Terminal at Folder” you could also create an alias of your home directory on the desktop. If you rename the alias Space , then from the Finder it’s:

Space to select your

Ctrl + Opt + t to Open a Terminal there.

. and you end up with a little home living on your desktop which has an arrow pointing to it:

Want to open your coding projects faster? Want to mitigate moving through various folders with just one simple command? Here’s how to create quick shortcut commands!

How to run any mac terminal command with a keyboard shortcut

The file .bash_profile might really be where all the magic happens for creating shortcut commands in the Terminal! If you’re sort of familiar with the general Unix command line commands that allow you to navigate through your machine via the Terminal, then creating aliases will help optimize your navigation process! It’s pretty easy, too. Here’s how to do it:

Navigate to your Terminal. You can simply command + SPACE to bring up the search bar. Type in Terminal and launch it.

Once your in the Terminal, type ls -a to be given a list of files and folders that are both hidden and not hidden. We are looking for the hidden file .bash_profile , for instance, to open and write into in order to create customized shortcut commands for your daily usage.

/.bash_profile if you prefer using the nano GNU in order to make critical changes to the file. You could also just open that file with the command open

Once you’re in the file, you may find some aliases that have already been established. There’s also a possibility that there may not be any. Regardless, let’s get to making our own!

At the bottom, copy this into the file:

Below the commenting is where you find the standard syntax for creating an alias (shortcut command) for your machine to recognize.

The alias edit means that when you type the command in that word and press Enter in the Terminal, it will follow the command that it equates to, which would be open

/.bash_profile . This command opens the file, regardless of where you may be in any of your directory levels. The

(tilde , pronounced ‘TIL-dah’) sign is handy because it’ll take you directly to the location of the file without you having to return to the root directory level with separate commands. It’s done all in one!

For example, I’m going to make an alias that will allow me to quickly open a note taking file I use for learning more Python (By the way, they’re just an example of lines of Python code in those notes.).

To access my Python notes, I’d like to call it pynotes .

I’ll set this new alias, pynotes , to the command that automatically opens my Python notes. Here’s what I type into my

You must know the exact filename and file path of the file you want to open!

In this instance, the name of the file I want to open is “py-notes.txt” and the absolute file path is /Documents/pythonpractice/py-notes.txt

Be Careful

Syntax here is super important. There can’t be any spaces in between the quotation marks and the commands in the string expression, and no spaces in between the equal sign and the alias name.

Important!! Make sure that not only your syntax is correct, but that your directory path is correct! If not, the alias will not be able to successfully jump to your desired location and perform that task.

open is a great starter for opening up applications and/or documents you use regularly. This is the primary command in the alias command that makes opening up desired applications via the Terminal super convenient.

Once you’ve created the alias and set it equal to a command, save the changes you’ve made to the file and close it. If your terminal is open or still running, quit it in order to refresh it.

Start up your Terminal again and type in the new alias you just created. For me, I type in pynotes .

Immediately, your command should get executed successfully!

Here’s what happened on my machine:

How to run any mac terminal command with a keyboard shortcut

Upon typing in the alias pynotes , the text file opened!

How to run any mac terminal command with a keyboard shortcut

And now I can resume my list comprehension notes for Python!

How to run any mac terminal command with a keyboard shortcut

Play around with aliases and decide what makes the most sense to make a shortcut command for! The customization is really up to you! Here are some examples of what I’ve developed custom aliases for:

1. Getting to my programming notes

2. Typing in my journal notes

3. Navigating to my work-related projects so I can run the server, databases, front-end watchers, and open up the repositories in VS Code

4. Getting to my ./bash_profile file to create new commands!

Terminal is a handy tool for giving your Mac commands, although many may be intimidated by it. After all, it’s not as easy as just typing in a sentence and your Mac responding. We have some articles listed below that can help you with common commands if you’re interested in learning to use Terminal or if you just want to enter a command or two. Either way, before you can use it, you have to open it, right? There are various methods for launching it. Here are six simple ways to open Terminal on Mac.

How to run any mac terminal command with a keyboard shortcut

Open Terminal using Spotlight Search

One of the quickest and easiest ways to open Terminal on Mac is with Spotlight Search. 1) If you have the Spotlight Search button in your menu bar, click it. Otherwise, you can use the keyboard shortcut Command + Space. 2) Type in “Terminal.” 3) You should see the Terminal application under Top Hit at the top of your results. Double-click it and Terminal will open.

How to run any mac terminal command with a keyboard shortcut

Open Terminal using Finder

Open Finder or make sure that your menu bar is using Finder and not another application. 1) Click Go > Utilities from the menu bar. 2) In the Utilities folder that opens, double-click Terminal.

How to run any mac terminal command with a keyboard shortcut

Open Terminal using the Applications folder

If you have a Finder window open, you can access Terminal from the Applications folder. 1) Select Applications from the left side. 2) Click the arrow to expand the Utilities folder. 3) Double-click Terminal.

How to run any mac terminal command with a keyboard shortcut

If you have the Applications folder in your Dock as I do, you can open Terminal from there too. 1) Click Applications in your dock. 2) Select Utilities. 3) Choose Terminal.

How to run any mac terminal command with a keyboard shortcut

Open Terminal using Launchpad

You can open Terminal using Launchpad in two ways, depending on if you have organized Launchpad a different way or not. By default, Launchpad contains a folder labeled Other that contains Terminal. 1) Open Launchpad from your Dock, with the keyboard shortcut F4, or tap the six-square-icon button on the Touch Bar. 2) Locate the Other folder and click it. 3) Choose Terminal.

How to run any mac terminal command with a keyboard shortcut

If you have arranged your Launchpad items differently and removed the Other folder, you can still find Terminal easily. 1) Open Launchpad. 2) Type “Terminal” into the search box at the top. 3) When the Terminal icon displays, click it.

How to run any mac terminal command with a keyboard shortcut

Open Terminal using Siri

Thanks to a helpful comment from one of our readers, there is one more super simple way to open Terminal on Mac; using Siri. 1) Click the Siri button from your menu bar or open Siri from your Applications folder. 2) Using your microphone, simply say “Open Terminal.”

How to run any mac terminal command with a keyboard shortcut

Create a Terminal shortcut

If you decide to start using Terminal more often, creating a shortcut for it in your Dock is convenient. With the Terminal icon in your Dock already, from recently opening it, do the following. 1) Hold Control and click the Terminal icon in the Dock or right-click it. 2) Mouse over Options in the pop-up menu. 3) Click Keep in Dock.

How to run any mac terminal command with a keyboard shortcut

Terminal commands and tips

As mentioned above, here are some of our articles with commands you can use for Terminal that may come in handy.

You can also head to the Terminal section of our website for additional tips and tutorials for Terminal.

Wrapping it up

Terminal is a terrific tool for doing things quickly on your Mac. And once you get the hang of it and bookmark some useful commands, it’s not as intimidating anymore. Have you tried to use Terminal yet, or are you interested in learning more about it so that you can use it? Let us know your thoughts below, and if you have any tips you’d like to share with our readers for using Terminal, feel free to comment!

Run in Terminal, an Extension for vscode

Use a keyboard shortcut to run any command in the Integrated Terminal of Visual Studio Code.

I built this because I wanted something for vscode like benmills’ amazing vimux for vim .

The send-to-terminal extension was close to what I wanted, but I wanted to be able to run more than 2 commands per filetype match. run-in-terminal is based on send-to-terminal , but allows an arbitrary number of commands per filetype.

The native Tasks functionality in vscode is also close, but configuration is only possible at the project level, not the global level.

Here is what Run in Terminal looks like:

How to run any mac terminal command with a keyboard shortcut

The simplest way to configure a keybindings.json using the cmd argument for the runInTerminal.run command:

Note above that when using keybindings.json you might use the ‘when’ context (rather than the match expression) to specify different commands with the same keybinding for different filetypes. If you do so, use ‘.*’ as your match expression.

If you are using VSCodeVim, things look a little bit different, because there is no support for a ‘when’ context to perform different commands for different filetypes.

Here is what you might put in your settings.json when configuring with VSCodeVim:

Note above, you specify each keybinding in your vim settings only once with a target name , and then in your runInTerminal.commands , you can specify multiple commands with the same name but different file match expressions. In this case, r b maps to the name ‘b’, which has a command for ruby and for javascript .

You can use the following substitution tokens in cmd strings:

  • $
  • $
  • $ (replace environment variables)
  • $
  • $
  • $
  • $
  • $
  • $
  • $
  • $

You should provide an object as the value of the arguments key when calling this command. This object must have either (i) a name pointing to a command in runInTerminal.commands or (ii) a file match expression and cmd to execute.

Runs the last cmd run by runInTerminal.run again.

Example of a Javascript / Typescript Line Runner

Here is an example of a VS Code extension, written in typescript, with a line runner bound to ,rl :

How to run any mac terminal command with a keyboard shortcut

After I move my workspace environment from Linux to Mac OS, I’m not used to have no any shortcut key to open terminal(Terminal.app).

Fortunately, after searching on the Internet, I found the configuration method and I recorded it here.

Configure shortcut keys

To set the shortcut key to “open terminal“, you need to do the two steps:

  • Write the command “open terminal” as AppleScript (Apple-specific script)
  • Set AppleScript as shortcut

Step 1. Build a AppleScript

Open Finder > Applications > search automator > open Automator.

How to run any mac terminal command with a keyboard shortcut

Select Quick Action.

How to run any mac terminal command with a keyboard shortcut

Searching as left side, find Run AppleScript, drap it to the right side, and we can start to write our command.

How to run any mac terminal command with a keyboard shortcut

Select execute key(arrow shape), and execute it can open terminal or not.

How to run any mac terminal command with a keyboard shortcut

After confirming that it can be executed, use command + s to save. I named it Open Terminal. You can open the Finder to search for the existence of this file.

Found it and double-click to execute and install. You can confirm whether there is a .workflow file with this file under Library/Services.

Step 2. Set a shortcut key

Open System Preferences > Keyboard.

How to run any mac terminal command with a keyboard shortcut system preferences

Select Shortcuts > Services > set Open Terminal shortcut key.

How to run any mac terminal command with a keyboard shortcut

I select a shortcut keys that is similar to the Linux shortcut keys: control + command + t.

If you need to be able to use it anywhere, add App Shortcuts.

How to run any mac terminal command with a keyboard shortcut

After that, you should be able to call the terminal according to the shortcut keys we set.

How to run any mac terminal command with a keyboard shortcut

In macOS, there are many ways to launch an application. You can click an icon in the Dock or the Launchpad, or type the name of the app in the Spotlight search box. However, in macOS, there is no built-in way to launch an application by pressing a keyboard shortcut.

Using the macOS Automator, you can create a custom service to launch the application of your choice, and bind a keyboard shortcut to it. When you press the keyboard shortcut, the chosen application launches automatically.

Follow the steps below to configure a keyboard shortcut to launch an application in macOS 10.15 Catalina.

Create an Automator service

First, create an Automator service to launch your app.

  1. In the macOS Finder, open the Applications folder. Double-click Automator.
  1. If this is the first time you are running Automator, your Automator documents open in a Finder window. Click the New Document button, or double-click the New Document icon.

How to run any mac terminal command with a keyboard shortcut

  1. Click the Quick Action document type, then click Choose.

How to run any mac terminal command with a keyboard shortcut

  1. In the Workflow receives currentdrop-down menu, select no input.

How to run any mac terminal command with a keyboard shortcut

  1. On the left is a list of Actions from your Actions Library. Scroll down to Launch Application. Drag this action from the list and drop it in the gray area of the window, as indicated.

How to run any mac terminal command with a keyboard shortcut

  1. The new action appears on the right, outlined in blue.

How to run any mac terminal command with a keyboard shortcut

  1. In the Launch Application drop-down menu, select the application you want to launch. If your app is not listed, choose “Other” to locate it manually. In this example, we have chosen the terminal application iTerm.
  1. Configuration is complete. Open the File menu and choose Save.

How to run any mac terminal command with a keyboard shortcut

  1. Type a name for your quick action and click Save.

Close the Automator window.

Create a shortcut for the service

Follow these steps to create a keyboard shortcut for your new service.

  1. Open the Apple menu and choose System Preferences.
  1. Click Keyboard.

How to run any mac terminal command with a keyboard shortcut

  1. Click Shortcuts. On the left, click Services. Scroll down to the service you created, and click to select it. Click Add Shortcut.

How to run any mac terminal command with a keyboard shortcut

  1. A text box opens. Press the desired key combination for your shortcut. In this example, we’ve held down Command and pressed the backslash key \.

You can choose any combination of Command, Shift, Option/Alt, and the alphanumeric keys. If your chosen shortcut conflicts with an existing shortcut, you will be alerted.

Choose a keyboard shortcut that you do not use in any other application. If you’re running another application that uses the same shortcut, your custom shortcut will not work.

How to run any mac terminal command with a keyboard shortcut

There are times when the applications on your Mac do not respond to your commands and you are not able to cancel those applications. Now, you do not need to panic, if you come across such a situation, as here are six ways in which you can quit a task or a site or a program with just a keyboard shortcut. You must be having some doubts about whether it is safe to quit the applications forcibly or not? So there is an explanation of your doubts as follows:

Force quitting an unresponsive application is the same as killing the viruses when we get sick. You need to see a broad view of this and understand what is the actual problem and how can you take care of it such that it never happens again.

So, the reason is that you do not have enough memory in your mac (RAM is not enough). This happens when your mac lacks enough memory to operate with new applications. So whenever you run the task on your mac, the system becomes unresponsive and freezes. Imagine RAM as a physical object which has limited space to sit or keep something then, you cannot force the object to adjust some more things over it. Just like that RAM of your mac cannot operate applications more than its capacity.

How to Force Quit Mac Applications With the Keyboard Shortcut

To prevent unresponsive applications, you should always keep deleting the stuff which you do not need any more from your mac or you can also save the files in your pen drive as to have enough space to operate multiple applications. By not doing so, it can also sometimes result in losing the saved data. So, following are the six ways in which you can force quit the applications on your Mac when they are unresponsive:

Method 1: You can Force Quit an App from the Apple Menu

Following are the steps to apply this method:

  • Press the Shift Key.
  • Select the Apple menu.
  • After selecting the Apple Menu to select “Force Quit [Application Name]”. As in the screenshot shown below the name of the application is “Quick Time Player”.

How to run any mac terminal command with a keyboard shortcut

This is one of the easiest ways to remember but it is not the most powerful method because it might happen that the application does not respond and the menu is not able to gain access.

Method 2: Command + Option + Escape

This method is a lot easier than using the Activity Monitor. Also, this is a very simple keypress to remember. This keypress allows you to cancel multiple applications at once.

This keypress is the best shortcut to quit a task or a process or a site or a daemon forcibly.
This is one of the easiest ways to cancel out the applications. Following are the steps to apply this method:

  • Press Command + Option + Escape.
  • Select the “Force Quit Applications” window.
  • Select the application name and then click on the “Force Quit” option.

How to run any mac terminal command with a keyboard shortcut

This will surely help in ending the application immediately.

Method 3: You can close the Presently Active Mac App with the help of your Keyboard

Keep in mind that you have to press this keystroke when the application you want to close is the only application on your Mac at that time, as this keystroke will force quit all the applications which are active at that time.

Keystroke: Command + Option + Shift + Escape until the app forcibly closes.

This is one of the fastest yet easiest ways to close the applications on your Mac. Also, it is a very simple keypress to remember.

Method 4: You can Force Quit the Applications from the Dock

Follow the following steps to apply this method:

  • Click Option + Right Click on the application icon in the dock
  • Then select the “Force Quit” option as shown in the screenshot below

How to run any mac terminal command with a keyboard shortcut

By using this method, the application will be forcibly quit without any confirmation so, you have to be sure before applying this method.

Method 5: You can use the Activity Monitor to Force Quit Apps

Activity Monitor is one of the most powerful ways to quit any app, task, or process forcibly which is running on your Mac. You can find and click it in the Applications or Utilities OR you can simply open it by pressing Command + Space and then type ‘Activity Monitor’ and then press the return key. This method is very effective. If the above methods fail to force quit the application then, this method will surely work. Also, it is very simple to use Activity Monitor. Following are the steps to apply this method:

  • Select the process name or ID you want to kill (unresponsive apps will appear as red).
  • Then you have to hit the red “Force quit” option as shown below in the screenshot.

How to run any mac terminal command with a keyboard shortcut

Method 6: You can use the Terminal & kill Command

In this killall command, the auto-save option does not work so, you should be very careful that you do not lose your unsaved significant data. It usually operates at the system level. Following are the steps to apply this method:

  • First, launch the terminal
  • Second, type the following command:
    killall [application name]
  • Then, click enter.

How to run any mac terminal command with a keyboard shortcut

So these were the six ways in which you can force quit the applications on your mac when they are unresponsive. Mainly, your frozen applications can be forcibly quit with the help of the above method but if you are still not able to force quit the application then, you should visit Apple Support.

Now, if your mac is still not able to force quit the application even after applying all these methods, then you need to contact your mac operator. You should try calling their customer service line and if they can’t help you, you should contact Apple Support. One can conclude that there is some hardware related issue with your Mac if all the methods stated above fail to work.

It is better to try each method before going to a hardware store and shelling out money unnecessarily. Therefore, these methods will help in solving your problem in the most cost-effective manner.

Pete Mitchell

Pete is a Senior staff writer at TechCult. Pete loves all things technology and is also an avid DIYer at heart. He has a decade of experience writing how-tos, features, and technology guides on the internet.

  • Forums
  • Macs
  • macOS
  • macOS

ilnyckyj

macrumors member
  • Jan 7, 2006
  • #1
  • GimmeSlack12

    macrumors 603
    • Jan 8, 2006
  • #2
  • Mitthrawnuruodo

    Moderator emeritus
    • Jan 8, 2006
  • #3
  • revenuee

    macrumors 68020
    • Jan 8, 2006
  • #4
  • GimmeSlack12

    macrumors 603
    • Jan 8, 2006
  • #5
  • Mitthrawnuruodo

    Moderator emeritus
    • Jan 8, 2006
  • #6
  • ilnyckyj

    macrumors member
    • Jan 8, 2006
  • #7
  • i mean, i don’t mind a third party program which edits osx to recognize a new shortcut which opens terminal, but i’d rather not have another program running in the background, that’s all.

    (i disabled dashboard too, never used it.)

    Bronish

    macrumors newbie
    • Apr 15, 2011
  • #8
  • Using Automator to Automate

    This is coming to the thread a few years late BUT here goes.

    I use Automator to launch any application by keyboard shortcut. Must be using Snow Leopard

    1. Launch Automator from the Applications folder
    2. Choose Service
    3. The line that states “Service receives selected” change it to “no input”
    4. From the Action side drag to the workflow side “Launch Application”
    5. For the pull down in the Launch Application action select the application you would like to launch. For Terminal you will have to go to the bottom and select “Other” and find it in the Utilities folder.
    6. Save the Service giving it a unique name like Launch Terminal
    7. Goto Keyboard Shortcuts tab within the Keyboard System Preferences
    8. Select Services from the left pane and scroll down to General in the right pane. You should see your Service.
    9. It’s not so obvious, but double click to right side of your Services row. This allows you to enter a key combination for the shortcut.
    10. Enter a key combination and close System Preferences.

    10 steps but really it takes less than a minute to do. Enjoy!

    You know what sets apart a pro user from a regular user? Mastery over the keyboard shortcuts.

    Alright! That’s not the only thing but it is undoubtedly a factor.

    Shortcuts help you to be more productive and efficient with whatever tool you use. Just think about it. If someone holds the mouse all the way down to copy entire text instead of Ctrl+A, how would you feel about it?

    Linux terminal is not an exception. There are certain Linux terminal shortcuts that every user must know and practice.

    Trust me; once you master these shortcuts, you’ll notice how good you are with using the Linux command line.

    Must Know Linux Shortcuts

    I would like to mention that some of these shortcuts may depend upon the Shell you are using. Bash is the most popular shell, so the list is focused on Bash. If you want, you may call it Bash shortcut list as well.

    1. Tab

    This is the Linux shortcut you cannot live without. It will save you so much time in the Linux command line.

    Just start typing a command, filename, directory name or even command options and hit the tab key. It will either automatically complete what you were typing or it will show all the possible results for you.

    If you could only remember one shortcut, this would be the chosen one.

    2. Ctrl + C

    These are the keys you should press in order to break out of a command or process on a terminal. This will stop a running program immediately.

    If you want to stop using a program running in the foreground, just press this key combination.

    3. Ctrl + Z

    This shortcut will send a running program in the background. Normally, you can achieve this before running the program using the & option but if you forgot to do that, use this key combination.

    4. Ctrl + D

    This keyboard shortcut will log you out of the current terminal. If you are using an SSH connection, it will be closed. If you are using a terminal directly, the application will be closed immediately.

    Consider it equivalent to the ‘exit’ command.

    5. Ctrl + L

    How do you clear your terminal screen? I guess using the clear command.

    Instead of writing C-L-E-A-R, you can simply use Ctrl+L to clear the terminal. Handy, isn’t it?

    6. Ctrl + A

    This shortcut will move the cursor to the beginning of the line.

    Suppose you typed a long command or path in the terminal and you want to go to the beginning of it, using the arrow key to move the cursor will take plenty of time. Do note that you cannot use the mouse to move the cursor to the beginning of the line.

    This is where Ctrl+A saves the day.

    7. Ctrl + E

    This shortcut is sort of opposite to Ctrl+A. Ctrl+A sends the cursor to the beginning of the line whereas Ctrl+E moves the cursor to the end of the line.

    Note: If you have the Home and End keys on your keyboard, you can also use them. Home is equivalent to Ctrl +A and End is equivalent to Ctrl + E.

    8. Ctrl + U

    Typed a wrong command? Instead of using the backspace to discard the current command, use Ctrl+U shortcut in the Linux terminal. This shortcut erases everything from the current cursor position to the beginning of the line.

    9. Ctrl + K

    This one is similar to the Ctrl+U shortcut. The only difference is that instead of the beginning of the line, it erases everything from the current cursor position to the end of the line.

    10. Ctrl + W

    You just learned about erasing text till the beginning and the end of the line. But what if you just need to delete a single word? Use the Ctrl+W shortcut.

    Using Ctrl+W shortcut, you can erase the word preceding to the cursor position. If the cursor is on a word itself, it will erase all letters from the cursor position to the beginning of the word.

    The best way to use it to move the cursor to the next space after the targetted word and then use the Ctrl+W keyboard shortcut.

    11. Ctrl + Y

    This will paste the erased text that you saw with Ctrl + W, Ctrl + U and Ctrl + K shortcuts. Comes handy in case you erased wrong text or if you need to use the erased text someplace else.

    12. Ctrl + P

    You can use this shortcut to view the previous command. You can press it repeatedly to keep on going back in the command history. In a lot of terminals, the same can be achieved with PgUp key.

    13. Ctrl + N

    You can use this shortcut in conjugation with Ctrl+P. Ctrl+N displays the next command. If you are viewing previous commands with Ctrl+P, you can use Ctrl+N to navigate back and forth. Many terminals have this shortcut mapped to the PgDn key.

    Bonus shortcut: Ctrl + R to search in command history

    You typed some command but cannot remember what it was exactly? Meet Ctrl + R.

    This keyboard shortcut allows you to perform a search in your command history. Just press Ctrl+R and start typing. It will show the last command that matches the string you typed. Note that the typed string could be anywhere in the command. How cool is that?

    How to run any mac terminal command with a keyboard shortcut

    If you want to see more commands for the same string, just keep pressing Ctrl + R.

    You can press enter to run the command selected or press Esc to come out of the search with the last search result.

    Try it and be amazed.

    Download FREE terminal shortcut cheatsheet

    The best way to learn new keyboard shortcuts is by keeping a cheat sheet pinned to your disk. You cannot possibly remember the new shortcuts so having the shortcuts in front of you gives the ability to look at it at a quick glance. This way you’ll use them more often and eventually, it gets added to your muscle memory.

    To help you with that, I have added a one-page PDF. You can print it and keep it at your desk.

    How to run any mac terminal command with a keyboard shortcut

    When you find yourself running a terminal command that you don’t know how to exit from. Don’t just close the whole terminal, you can close the that command!

    If you want to force quit “kill” a running command, you can use “Ctrl + C”. most of the applications running from the terminal will be forced to quit.

    There’s commands/apps that are designed to keep running until the user asks it to end. and there’s other commands/apps that are designed to show the output and exit automatically.

    Here’s how to stop 3 of the most common commands.

    Nano is a simple text editor, you could have faced it when dealing with “git commit”.

    If you’re inside nano editor. Press “ Ctrl + X” to exit. it will prompt you whether you want to save before quitting or not.

    Vim is another text editor, unlike nano, this one is sophisticated and powerful one.

    If you were running Vim editor and you want to quit, you can press “ Esc” then type a colon “ :” followed by “ q!” to force quit without saving.

    If you want to save do the same process but replace “ q!” with “ wq” (which means write then quit).

    Less is a command that let you view the content of an input (either the output of another command or a content of a file).

    Less is different from the editors above, if you’re inside commands that don’t need input, like “less” or top, you can press “ q”.

    Sometimes nothing from the above will work to quit the command gracefully. In these situations, you can use the “kill” command which is “ Ctrl + C”.

    In general, try to quit the application gracefully so it can do what it’s designed to do when quitting. If it didn’t work just force quit (kill) it.

    Account Information

    Share with Your Friends

    20 Terminal shortcuts developers need to know

    20 Terminal shortcuts developers need to know

    These days, more and more developers are moving to OS X. Here are 20 shortcuts to help you get work done in Terminal on your Mac.

    Boasting some of the best web development software, the ability to develop for almost any platform, and a great design and user experience, it’s no wonder why Macs are used by many developers as their primary machine.

    As a developer, being able to properly navigate your keyboard is one of the most useful skills you can have. Also, Macs are known for having their own proprietary set of keys that differ from more traditional keyboards.

    Whether you’re a recent convert from Windows or Linux, or you’re about to start your first job out of school, here are 20 keyboard shortcuts on OS X that will make life easier if you’re working in Terminal.

    Option/Alt + Left or Right

    This shortcut allows you to move the cursor between separate words in a command line. Use Option and the left arrow to move back and use Option with the right arrow to move forward down the line.

    Control + W

    Using this keyboard combination will delete the word immediately before, or to the left of, the cursor.

    Escape + T

    This will swap the two words that appear immediately before the cursor. So, if “this is” sits before the cursor, using Escape and T will change that to “is this.”

    Control + R

    If you need to locate a previously used command in Terminal, use Control and R. It will open up [(reverse-i-search)`’:] and allow you to find a previously used commands that you may need to access again.

    Command + A

    Using Command and A will take you to the end, or the far right, of the line where your cursor is.

    Command +E

    This shortcut is the opposite of Command and A. Command and E will take you back to the beginning, or the far left, of the line you are currently working on.

    Control + C

    If you need to kill what’s currently running, us Control and C in Terminal to abort the current application.

    Control + U

    This shortcut clears the entirety of the line before the cursor. So, if you get to the end of a line and realize the whole thing is wrong, use Control and U to delete it all.

    Control + K

    Using Control and K will have the opposite effect as using Control and U. This will clear the line that appears after the cursor. It is helpful if you need to change or delete the latter half of a line.

    Command + K

    This will clear the entire Terminal screen you’re working on, deleting everything. The same thing can be accomplished using Control and L or by typing “clear” into Terminal.

    Control + D

    This will cause you to exit the current shell in Terminal.

    Control + Z

    Suspends what you are currently running in the background.

    This executes the last command entered. If you run into permission issues, try entering sudo before .

    Control + H

    Essentially the same thing as backspace, but it is useful if you want to stay anchored on the home row keys.

    Typing “top” into Terminal will display all of your active processes. Similar to what you’d get from Activity Monitor, but within Terminal. Press “Q” to quit.

    History + a number

    If you’ve lost track of a command you typed earlier, you can type “history” into Terminal to retrieve a history of your commands. However, if you want to view a specific number of past commands simply type a space then a number after history. So, “history 5” would show you the last five commands you typed.

    Control + F

    This shortcut moves the cursor forward to the next character on the line. It is essentially the same thing as using the right arrow key, but keeps you on the home row keys.

    Control + B

    This shortcut moves the cursor back to the previous character on the line. It gives you the same result as using the left arrow key, but keeps you on the home row keys.

    Escape + F

    Using this combination will move your cursor to the next word on the line, similar to Option and right arrow that was mentioned earlier.

    Escape + B

    This is an alternate way of moving the cursor back by one word, like you would do using the Option and left arrow shortcut. However, this keeps your fingers better positioned on the keyboard.

    Applies to: Visual Studio for Mac Visual Studio

    The Integrated Terminal is currently not available in Simplified Chinese or Traditional Chinese locales. We’re fixing bugs related to Chinese character input and this feature will be available soon.

    You can open an integrated terminal window in Visual Studio for Mac, starting at the root of your solution. The terminal can be useful for different kinds of situations – running front-end tasks (for example: npm, ng, or vue), managing containers, running advanced git commands, executing Entity Framework commands, viewing dotnet CLI output, adding NuGet packages, and more.

    To open the Terminal:

    • Use the Ctrl + ` keyboard shortcut with the backtick character to show or hide the Terminal window.
    • Use the View >Terminal menu command.
    • Use the terminal command from the search bar.

    How to run any mac terminal command with a keyboard shortcut

    How to run any mac terminal command with a keyboard shortcut

    By default, when the Terminal is launched it will:

    • Set the working directory to the path of the current solution.
    • Load the default system shell.

    Search

    You can search the content of the Terminal window by using the Search > Find. menu.

    How to run any mac terminal command with a keyboard shortcut

    Terminal keyboard shortcuts

    CommandsKeyboard shortcuts
    Show/Hide the Terminal windowCtrl+ `
    Create new Terminal instanceCtrl+’
    Scroll page upPageUp
    Scroll page downPageDown
    Cycle through previously used commands↑, ↓
    Increase font size⌘+
    Decrease font size⌘-

    Multiple instances

    Multiple instances of the Terminal may be running at any time. You can create a new instance by using the Ctrl+’ keyboard shortcut. You can switch between instances by clicking on the tab for each instance, or using the Ctrl+tab shortcut to use the window picker dialog.

    How to run any mac terminal command with a keyboard shortcutВ

    Customizing the terminal window

    Configuring the terminal font

    You can change the font Family, Typeface and Size used for the Terminal Window Contents from Preferences. > Environment > Fonts. By default, the font will be the same as that for the Output Window Contents, using Menlo Regular 11. You can set it to any font, independent of your Text Editor font.

    How to run any mac terminal command with a keyboard shortcut

    How to run any mac terminal command with a keyboard shortcut

    Reusing system terminal customizations

    The integrated terminal uses the same defaults and configuration as your macOS system terminal. That means that your terminal customizations (zsh, oh-my-zsh, etc.) also work in the integrated terminal.

    How to run any mac terminal command with a keyboard shortcut

    Python is a very Mac-style language. It ditches many of the syntax conventions of traditional programming languages in favor of human-readable code, tab-based hierarchy, and abstracted memory management. It’s a great first programming language, although there are some tasks not covered in many tutorials – for example, running a Python script on macOS.

    In this post, we show you two different ways to run a Python script on macOS, though the first is less common than the second.

    Also read: Python While Loop: Intro and Explanation

    Python Launcher

    For the unaware, Python scripts use the .py file extension regardless of the version of the language you use.

    By default, macOS comes with Python 2.7.3 installed. We don’t recommend using this version, though, as it’s now deprecated.

    A common way to install Python 3 is through the dedicated installer. This gives you access to tools such as the Python Launcher – a Graphical User Interface (GUI) program to run Python scripts from the Finder.

    To do this, locate the Python script file in the Finder, right-click, and use “Get Info” to find the path name.

    How to run any mac terminal command with a keyboard shortcut

    Next, right-click the file and select “Open With -> Python Launcher” from the context menu.

    Python scripts can also be dragged onto the Python Launcher icon, whether it’s in the Dock or the Applications folder.

    Configuring the Python Launcher

    If you like using the Python Launcher, you can customize it with a few additional options. For example, you can select your version of Python, enable debugging tools, and adjust how the script runs.

    How to run any mac terminal command with a keyboard shortcut

    The Python Launcher’s Preferences window opens in the background automatically when Python Launcher is executed. You can also open it manually by selecting “Python Launcher -> Preferences” from the Python Launcher menu bar.

    You can even invoke the Preferences window before running a script. To do this, drag the script to the Python Launcher icon while holding the Option key, and the Preferences menu will display before the script is run.

    This will let you adjust settings that will only apply to this run of the script. It’s almost like a temporary run configuration, though changes to the Python Launcher Preferences under normal circumstances are global, affecting all future scripts.

    Using the Terminal

    Most users will run scripts from the Terminal, which is a stellar way to run a Python script on macOS.

    First, you’ll want to find the path of the Python script in the Finder. If you’re not sure, you can Option + Right-Click on the file, then select “Copy … as Pathname” to copy the path to your clipboard.

    How to run any mac terminal command with a keyboard shortcut

    You can also drag a file onto the Terminal window to see its absolute path.

    How to run any mac terminal command with a keyboard shortcut

    The Terminal-centric way uses the cd command to navigate to the folder containing the Python file. Note that you can paste your copied path name in here too.

    How to run any mac terminal command with a keyboard shortcut

    Once you’re at the right folder, use python3 to execute the script.

    How to run any mac terminal command with a keyboard shortcut

    Of course, here represents the name of your script. It’s a straightforward approach and one that you’ll become familiar with if you’re using Python on a regular basis.

    Conclusion

    Working with Python files on the Mac is a breeze, especially given some of the built-in functionality. As such, there are two ways to run a Python script on macOS: through the Python Launcher app and the more common Terminal execution. Using the Terminal is the preferred way, as you’ll often use Homebrew to install the latest Python 3 version (rather than use the built-in and obsolete Python 2).

    If you’re on a Windows machine, Python 3 is also a snap to install and use. Do you have a method for running a Python script on macOS we haven’t covered? Let us know in the comments section below!

    Our latest tutorials delivered straight to your inbox

    I switch back and forth between two computers constantly:

    • OSX Snow Leopard
    • Ubuntu 10.10

    I’d like to be able to make Ubuntu use the same keyboard shortcuts as OSX System Wide, for the following keyboard sequences only (ie I don’t want to make Ctrl act like Super)

    Super+T -> Open a new tab in whatever browser I’m in.

    Super+W -> Close a tab in whatever browser I’m in.

    So in short, is there anyway for me to map just these keyboard sequences to the following, system wide ?

    • Super+C -> Ctrl+C
    • Super+V -> Ctrl+V
    • Super+T -> Ctrl+T
    • Super+W -> Ctrl+W

    I know there are ways for me to do this for vim, and Firefox, and I’m sure specifically for most applications. but I would prefer to have to do this just once and have it work that way system wide!

    I’m using a standard PC keyboard, that is “Generic 105 key (intl) PC” on Ubuntu. I’m also using the same keyboard on my Mac mini.

    16 Answers 16

    If you install the xautomation package, you can add a command in System → PreferencesKeyboard ShortcutsCustom like:

    and map that to Meta + C .

    You may need to use “keyup Super_L” “keyup Super_R” depending on your keyboard.

    Install AutoKey ( apt-get install autokey-gtk ) and set a phrase to:

    How to run any mac terminal command with a keyboard shortcut

    Since Ubuntu 14 you can use GNOME Tweaks:

    Then, look for Tweak Tool > Keyboard & Mouse > Additional Layout Options > Alt/Win key behavior.

    And check: Ctrl is mapped to Win keys and usual Ctrl keys.

    How to run any mac terminal command with a keyboard shortcut

    There is a way to map Ctrl to Win / Super key:

    go to system->preferences->keyboard,

    open tab Layouts,

    click Options. ,

    open Alt / Win key behavior,

    and select Control is mapped to Win keys

    And for console there is a forum post how to do that here.

    For more digging check general Linux keyboard HOWTO here.

    How to run any mac terminal command with a keyboard shortcut

    Some of the above solutions are old and not working with Ubuntu 18.04. Here is an updated answer

    Install gnome-tweaks if not installed in the system

    sudo apt-get install gnome-tweaks

    Open the list of applications by pressing Show Applications on at the left bottom.

    Note that this will only change the behavior of WINDOWS key to CMD key and keeps CTRL key as same as before (you will have 2 CTRL keys). If you don’t like this, skip step 4 and go to step 5

    Look for Tweaks application –> Keyboard and Mouse –> Additional Layout options –> Alt/Win behavior –> Select Control is mapped to Win keys and the usual Ctrl Keys .

    Skip this step if you completed step 4. This step will swap Windows key Behaviour to Ctrl and vice versa. Look for Tweaks application –> Keyboard and Mouse –> Additional Layout options –> Ctrl Position –> Select Swap Left Win with Left Ctrl

    One more thing I miss from macOS is the ability to switch windows with CMD+Tab (In this case Windows+Tab). To achieve this go to Settings –> Keyboard –> Look for Switch Windows under navigation section –> Double Click it and press Windows+Tab when pop up appears

    How to run any mac terminal command with a keyboard shortcut

    Bumping this! Your pinkies will thank me

    All of my muscle memory is Mac based, and I use a Mac at work and in my personal life, but I happened across a Dell Latitude E7470 and figured I might as well give Linux a go on it (since my Macbook Pro is from 2012 and is pretty heavy, and I just didn’t want to have to bother with \r\n line endings). So it’s been a slow-moving work in progress to figure out how to modify the system to match my muscle memory instead of relearning keyboard shortcuts.

    At first, I was just using the Keyboard > Layouts > Options. settings for “Ctrl is mapped to Alt; Alt is mapped to Win” but, and this is a very minor thing, I didn’t like that my settings didn’t apply until after I got past the greeter. I was also having trouble getting

    /.Xmodmap to run on start (either by itself, as part of .xinitrc and as a custom startup command in startup applications and in /etc/default/

    I’m currently running Ubuntu MATE 19.10 (Eoan), and the keyboard is recognized as a pc105

    You’ll have to modify the script below (or the individual files, if you’ve already made other modifications to them that you want to keep) to match whatever keyboard your computer has.

    Modify X11 Keyboard symbol file for your keyboard (the important part here is the include “altwin(ctrl_alt_win)” before // End of modifier mappings. This is an otherwise unmodified /usr/share/X11/xkb/symbols/pc file):

    And just in case, here’s the relevant part of /usr/share/X11/xkb/symbols/altwin if you need to add it manually:

    And finally, here’s my GNOME and Marco keybinding dconf dumps:

    How to run any mac terminal command with a keyboard shortcut

    Want to save energy? Long for quietude? Find out here how to put a Mac to sleep with a keyboard shortcut immediately—or use another method: the lid, the menu, and even your own key combination.

    Table of Contents

    First, 2½ Minutes at the Beach, 1 Hour on the Turntable

    Intrigued by the ocean’s ability to mask background noise, Irv Teibel had recorded some two and a half minutes of surf (and a few environmental sounds more) at Brighton Beach on Coney Island, NY.

    He went to Bell Labs with the recording and one of the people behind 2001‘s HAL computer, Lou Gerstman, they looped and processed the recording like true electronic musicians, and out came 30 or even 60 minutes (depending on the playback speed) of The Psychologically Ultimate Seashore.

    Now, while that recording (especially, I find, played at 16 rpm) will masterfully put one to rest and sleep, it does not have the same effect on Macs; other options do work reliably, though:

    Article post on: us.dinhthienbao.com

    • How to Install & Use ES File Explorer on FireStick
    • ​How to Delete Photos from Google Photos but Not from Phone
    • How to Change the Background Color in GIMP
    • How To Remove Cigarette Lighter Socket
    • How to Change the Default Font in Google Docs‍

    The Mac Sleep Shortcut (and How to Put a Mac to Sleep by Other Means)

    Using the Standard macOS Sleep Keyboard Shortcut

    Using the Mouse and Menu

    To sleep a Mac using the menu bar:

    Using the Command Line

    To enter sleep mode immediately using the macOS command line (or an app with option to run command line programs):

    Article post on: us.dinhthienbao.com

    1. Open a Terminal prompt.
    2. Type pmset sleepnow .
    3. Press Enter .

    How to Create a Custom Mac Keyboard Shortcut for Sleep

    Using Shortcuts

    To set up a custom Mac keyboard shortcut for sleeping with Shortcuts:

    1. Open Shortcuts.
    2. Select File | New Shortcut from the menu.
      Shortcuts keyboard shortcut: You can also press Command N , of course.
    3. Drag and drop the Run Shell Script action to the shortcut area.
      Find Run Shell Script: You can find Run Shell Script under Terminal app or search for shell script .
    4. If scripting is disabled:
      – Select Shortcuts | Preferences… from the menu.
      – Go to the Advanced tab.
      – Enable Allow Running Scripts.
    5. Type pmset sleepnow under Run Shell Script.
    6. Now type a name for the new action over Run Shell Script in the title bar.
      Example: Use something like Put Mac to Sleep .
    7. Go to Shortcut Details.
    8. Click Add Keyboard Shortcut.
    9. Press the keyboard combination you want to use to put your Mac to sleep.

    Using Automator

    To make your own keyboard shortcut to sleep a Mac using Automator:

    Article post on: us.dinhthienbao.com

    • How To Disable Google New Tab Homepage Thumbnails
    • How to Find Slope in Google Sheets
    • How to Make Sticks in Minecraft
    • How to Move a Track in Audacity
    • How To Tell What Amp Your Alternator Is?
    1. Launch Automator.
    2. Click New Document.
      NoNew Document”: If you do not see New Document, select File | New from the menu.
    3. Highlight Quick Action.
    4. Click Choose.
    5. Select no input for Workflow receives.
    6. Select Library under Actions on the left.
    7. Drag and drop the Run Shell Script action to the workflow.
      Find it: You search actions for shell to spot it quickly.
    8. Type pmset sleepnow under Run Shell Script.
      Which shell: The shell is not important; the default /bin/zsh works fine.
    9. Now select File | Save from the menu.
    10. Type the name for sleeping (say, “sleep”) under Save quick action as:.
    11. Click Save.
    12. Now select System Preferences… from the Apple logo menu ().
    13. Open the Keyboard category.
    14. Go to the Shortcuts tab.
    15. Choose Services.
    16. Select the quick action you just saved (“sleep”) under General.
    17. Click Add Shortcut.
    18. Now type the key combination you want to use for your own sleep Mac keyboard shortcut.

    (How to put a Mac to sleep tested with macOS Monterey 12.3 and Big Sur 11.2; updated March 2022)

    Article post on: us.dinhthienbao.com

    Recent Posts

    • Discovery Distances Itself From Homophobic Song Performed By ‘Homestead Rescue’ Star Marty Raney
    • Lith Relic Farm (Best Place to Farm Lith Relics)
    • Our Favorite Cookies, Brownies & Bars
    • Weaning From Swaddling: How and When to Do It
    • How to Remove ChromeSearch.club Homepage (Removal Help)
    • How To Romance The Sims 4 Grim Reaper
    • Laura Coates Husband: CNN’s Senior Legal Analyst is Reportedly Single in 2022!
    • How Did Mexico Start Speaking Spanish?
    • Use this Terraria save editor to get the best items easily
    • How to remove startup and login items on your Mac
    • How to Search Text in Your Documents on Mac
    • All macOS versions from 2001 to 2022
    • Why Movies Cost So Much To Make
    • Where do screenshots go on Mac
    • Upper respiratory infections (URIs, Cat flu) – information for breeders

    © 2022 by cohaitungchi – Synthesize and organize information automatically by computer program.

    The command line in Mac OS X can be a very powerful and fun tool, so it’s good to know how to maneuver around if you find yourself in it. By default, the Mac OS X Terminal uses the Bash shell, which is what these keyboard shortcuts are intended for.

    So if you’re ready to get your feet wet, open up the Terminal and try these shortcuts out, they’re sure to make your command line life easier.

    While the keystrokes will perform some incredibly useful tasks, the complexity isn’t too deep or crazy so you should be able to try all these out within a minute or two. Take a moment to do that, learn a bit more about the command line, and have fun.

    12 Command Line Keyboard Shortcuts for Mac OS X

    These will work in the Mac Terminal for any version of Mac OS X, that includes the default Terminal app and third party terminal applications like iTerm as well. Technically, these should work in Linux and other Bash shells too, but obviously we’re focusing on the Mac here.

    Ctrl + AGo to the beginning of the line you are currently typing on
    Ctrl + EGo to the end of the line you are currently typing on
    Ctrl + LClears the Screen, similar to the clear command
    Ctrl + UClears the line before the cursor position. If you are at the end of the line, clears the entire line.
    Ctrl + HSame as backspace
    Ctrl + RLet’s you search through previously used commands
    Ctrl + CKill whatever you are running
    Ctrl + DExit the current shell
    Ctrl + ZPuts whatever you are running into a suspended background process. fg restores it.
    Ctrl + WDelete the word before the cursor
    Ctrl + KClear the line after the cursor
    Ctrl + TSwap the last two characters before the cursor
    Esc + TSwap the last two words before the cursor

    If you have any other handy keyboard shortcuts or tricks for the command line, share them with us!

    Related

    Enjoy this tip? Subscribe to our newsletter!

    Get more of our great Apple tips, tricks, and important news delivered to your inbox with the OSXDaily newsletter.

    Thank you!

    You have successfully joined our subscriber list.

    Related articles:

    • How to Automatically Change iPhone Wallpaper with Shortcuts
    • How to Find Mac Keyboard Shortcuts
    • How to Install Third-Party Shortcuts on iPhone & iPad
    • 14 Keyboard Shortcuts for Files App on iPad

    20 Comments

    Wonder Article Great piece of Article !!

    See also `stty -a’.

    You’ll find some of those listed above there too. stty is a very useful command though perhaps it’s obscure to most and usually it’s not useful but when it is it’s very useful.

    See stty(1) for more info (that means: section 1 of the man page so man stty).

    A minor correction..

    Ctrl + T swaps the two characters on either side of the cursor.

    It only swaps the last two characters before the cursor when at the end of the line.

    ctrl + arrow keys for fast navigation in text

    hey! how to delete (clear) the whole line? not after or before the cursor. but the whole

    $ bind -P | grep not -v

    abort can be found on “\C-g”, “\C-x\C-g”, “\e\C-g”.
    accept-line can be found on “\C-j”, “\C-m”.
    backward-char can be found on “\C-b”, “\eOD”, “\e[D”.
    backward-delete-char can be found on “\C-h”, “\C-?”.
    backward-kill-line can be found on “\C-x\C-?”.
    backward-kill-word can be found on “\e\C-h”, “\e\C-?”.
    backward-word can be found on “\e[1;5D”, “\e[5D”, “\eb”.
    beginning-of-history can be found on “\e”, “\e[6

    ”.
    end-of-line can be found on “\C-e”, “\eOF”, “\e[4

    ”, “\e[F”.
    exchange-point-and-mark can be found on “\C-x\C-x”.
    forward-char can be found on “\C-f”, “\eOC”, “\e[C”.
    forward-search-history can be found on “\C-s”.
    forward-word can be found on “\e[1;5C”, “\e[5C”, “\ef”.
    glob-complete-word can be found on “\eg”.
    glob-expand-word can be found on “\C-x*”.
    glob-list-expansions can be found on “\C-xg”.
    history-expand-line can be found on “\e^”.
    insert-comment can be found on “\e#”.
    insert-completions can be found on “\e*”.
    insert-last-argument can be found on “\e.”, “\e_”.
    kill-line can be found on “\C-k”.
    kill-word can be found on “\ed”.
    next-history can be found on “\C-n”, “\eOB”, “\e[B”.
    non-incremental-forward-search-history can be found on “\en”.
    non-incremental-reverse-search-history can be found on “\ep”.
    operate-and-get-next can be found on “\C-o”.
    possible-command-completions can be found on “\C-x!”.
    possible-completions can be found on “\e=”, “\e?”.
    possible-filename-completions can be found on “\C-x/”.
    possible-hostname-completions can be found on “\[email protected]”.
    possible-username-completions can be found on “\C-x

    ”.
    possible-variable-completions can be found on “\C-x$”.
    previous-history can be found on “\C-p”, “\eOA”, “\e[A”.
    quoted-insert can be found on “\C-q”, “\C-v”, “\e[2

    ”.
    re-read-init-file can be found on “\C-x\C-r”.
    reverse-search-history can be found on “\C-r”.
    revert-line can be found on “\e\C-r”, “\er”.
    self-insert can be found on ” “, “!”, “\””, “#”, “$”, …
    set-mark can be found on “\[email protected]”, “\e “.
    shell-expand-line can be found on “\e\C-e”.
    start-kbd-macro can be found on “\C-x(“.
    tilde-expand can be found on “\e&”.
    transpose-chars can be found on “\C-t”.
    transpose-words can be found on “\et”.
    undo can be found on “\C-x\C-u”, “\C-_”.
    unix-line-discard can be found on “\C-u”.
    unix-word-rubout can be found on “\C-w”.
    upcase-word can be found on “\eu”.
    yank can be found on “\C-y”.
    yank-last-arg can be found on “\e.”, “\e_”.
    yank-nth-arg can be found on “\e\C-y”.
    yank-pop can be found on “\ey”.

    A useful tip to see all keyboard shortcuts is:

    so to delete the word after the curso, use esc-d ( \ed )

    📅 Last Updated: 13 Jun 2021 07:43 GMT | 👤 User: @c2cDev | Topic: MacOS

    Are you new to Apple Mac computers (iMac, Mac Mini) or Laptops (Macbook Air or Pro) and have previous experience of using computers running Windows OS. You must be familiar with Command Prompt the Command Line Interface for Windows and wondering how to use it on a system running macOS?

    Well, macOS is Unix based and has an app called Terminal which is equivalent to Command Prompt on Windows.

    You can open the Terminal App by following the below steps:

    Using Spotlight Search

    Click Spotlight search icon next to your menu time – type Terminal, open the app.

    Using Finder

    Open Finder, Go to Application -> Utilities and look for Terminal

    Using Keyboard Shortcut

    Press Command + Space and type Terminal, open the app.

    Have Questions? Post them here!

    Try Out Code2care Dev Tools:
    • Online Base64 Encoder Decoder
    • Online URL Encoder Decoder
    • jQuery Keycode Generator
    • Online Image to Base64 Text Convertor
    • Morse Code – Generator and Chart

    Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

    Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
    🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
    We strong support Gender Equality & Diversity.

    If you’re new to the Mac Terminal, think of it as the ultimate command shortcut hub, one that allows you to take control of your operating system in a super quick and efficient way (it’s also something you might use if you’re familiar with UNIX operating systems).

    Learning to use the Terminal is kind of like speaking a different language — you’ll have to familiarize yourself with at least the general rules to use it properly.

    For example, every character you type matters, even spaces; you navigate through lines using your arrow keys; and you have to press the “return,” or “enter,” button to give a command.

    (We’ll run through a few basic commands you might want to use later on.)

    But first, you’ll have to open the Terminal. Here’s how:

    How to open the Terminal on a Mac

    There are two primary avenues you can use to get to the Terminal: the Applications folder in your Finder, or searching in Spotlight. Here’s a quick run-through of both processes.

    Opening Terminal through the Finder

    1. Click the Finder logo, located in the bottom toolbar of your screen (it looks like a two-toned smiling face).

    2. On the left toolbar, click “Applications” (if that was the last folder you visited within the Finder, Finder will open to this folder automatically).

    3. Scroll down and open the “Utilities” folder.

    4. Double click “Terminal” to launch it.

    Opening Terminal through Spotlight

    1. Press the “Command” button and the space bar, simultaneously (this will open a search bar on your screen).

    2. Type “Terminal” (as you type, it should auto-fill).

    3. Double click “Terminal” in the left sidebar to open your Mac’s Terminal

    If you plan on using the Terminal a lot, it’s a good idea to pin it to your computer’s bottom toolbar (the “dock”) for easier access. To do that, right-click the Terminal logo in the dock (it should appear there as long as Terminal is open). Then hover over “Options” and select “Keep in Dock.”

    A few basic commands you can use on a Mac’s Terminal

    Remember: After typing in each command, you’ll have to hit the return button for the command to take hold. Here are a few useful commands to know, and make sure to copy the exact phrasing and spacing below into your commands:

    Open an application:

    Open -a APPLICATION

    Or, if the application has a space in its name:

    Open -a “APPLICATION NAME”

    Open a file using the default application:

    For this, you’ll have to know the command pathway for the file you want to access. To do so, you can either drag the file to the Terminal window to add to the line, or right click the file and select “Copy [NAME]” and then use the Command+V shortcut to paste it into the Terminal. Even though the latter appears to only copy the actual file name, it actually captures the full pathway. In either case, hit the spacebar following the app name and then the command would take hold.

    Open [FILE PATHWAY]

    Open a file using an application you specify:

    Again, you’ll need the file pathway to use this command.

    Open -a “APP NAME” [FILE PATHWAY]

    Open a text-based file using the text editor:

    Note that the file pathway is also fundamental here.

    Open -a Text Edit [FILE PATHWAY]

    If you need to get to your Terminal’s settings, hold down the command key while tapping the comma button. And, in case you want to stop a command you’ve input, you can do that by tapping the window (if it isn’t already selected) and holding down the “control” key and hitting “c.” Or, if you want to repeat a command, simply use the up arrow key to cycle through previously used commands and, when you see the one you want, press “return.”

    Don’t worry if you make a mistake in your command pathways: You’ll just get a message back saying something along the lines of, “No such file or directory exists.”

    I am using Ubuntu 19.10 on a Mac, and so I do not have a Delete key on my keyboard.

    To emulate that key, I can do Fn + Backspace but I would like to choose another combination of keys like Super + Backspace . Is this possible?

    3 Answers 3

    This will do the job:

    Firstly: edit the XKB /usr/share/X11/xkb/symbols/pc file by running the following command in the terminal:

    Secondly: find this line:

    And comment it out by adding // before it like so:

    Thirdly: copy and paste the following code below the commented line in secondly above:

    And save the file.

    Fourthly: clear the XKB cache by running the following command in the terminal:

    Finally: reboot your system to activate your new xkb configuration or reload the new xkb configuration by setting an xkb map layout using the following command in the terminal:

    and test your new key combination.

    This solution should make pressing Super + Backspace work as pressing the Delete key.

    To change the combination to Shift + Backspace you can change PC_SUPER_LEVEL2 to PC_SHIFT_LEVEL2 in thirdly above.

    How to run any mac terminal command with a keyboard shortcut

    A command could emulate a specific keystroke. One way to do this is to create a custom shortcut to run xdotool (source) on Settings > Keyboard > Custom Shortcuts:

    How to run any mac terminal command with a keyboard shortcut

    • Possible duplicate/related: here and here.
    • Another way

    No, it can’t be possible to do it overall, Fn can’t be seen as another key, according to this answer :

    The Fn is not really comparable. It’s a hardware key that’s not directly interfaceable by the operating systems. Pressing Fn and another key causes an entirely different code to be sent to the operating system.
    Examples for this include XF86AudioMute, XF86Eject and so on. The Operating system can’t detect whether Fn is pressed or not.

    I had think that it would be possible using gnome-tweaks package, inside :

    Keyboard & mouse -> Additional Layout Options

    but no, you can define behavior for each special key (from the basical Ctrl to the old Meta key), but because Fn isn’t a software key, you can’t change his function.

    You can create a custom shortcut to do that Delete emulation, but it required a command.

    Comments

    prumbles commented Jul 8, 2019

    It would be great to have the equivalent of Command+K on the Mac terminal. This clears the terminal completely, not the equivalent of typing “clear”, which only scrolls the cursor to the top of the terminal. My use case is the following:

    The text was updated successfully, but these errors were encountered:

    mdtauk commented Jul 8, 2019

    Why just clear screen? Why not a toolbar where common commands can be added as quick shortcuts?

    prumbles commented Jul 8, 2019

    But, this isn’t a bash command, as I think that’s what you are asking. Command+K on a mac doesn’t run any commands in the terminal such as “clear”. it clears the entire terminal buffer. Commands such as “clear” don’t do the equivalent. I personally don’t need a toolbar – I’m fine with adding them to the “Settings.json” file like all the other keyboard shortcuts. Its just that “Clear terminal” is not one of the available options to create a shortcut for. If you use VSCode, the exact equivalent command is “Terminal:Clear”. I map that to Alt+K to get the same experience.

    fzed51 commented Jul 11, 2019

    Are we not talking about the same thing as issue # 1189 ?

    zadjii-msft commented Jul 11, 2019

    @fzed51 Nope, this is unrelated to that one.

    To clarify for future me – cmd + k is not something that’s being handled by bash or the shell. This is the Terminal itself handling the keybinding, and clearing both the buffer and the scrollback.

    You’ve described a user story that makes sense to me, so I’m gonna put this on the backlog.

    eduardonunesp commented Jan 7, 2020

    I would like to help with that if possible, shouldn’t be so difficult right? I mean can be just reset the buffer and initialize again the buffer

    DHowett-MSFT commented Jan 7, 2020

    You should definitely read the comments here. Because of the windows console infrastructure we’re built on it’s not quite that easy.

    eduardonunesp commented Jan 7, 2020

    Ok, I don’t have any idea about the internals of the terminal, however, if in order to clear a buffer after press a key combination is so complex probably it will be impossible to scale the product when adding more complex stuff than this

    DHowett-MSFT commented Jan 7, 2020

    It’s just this issue in particular that’s thornier than most. For compatibility with Windows console applications that do not expect a terminal to be connected, we need to maintain a text buffer for them to read. That’s all. Because we don’t have a way to clear that text buffer (from the terminal side), and we just haven’t written one yet, it’s only more complex than clearing the local screen. It’s not a complexity class issue with all of Terminal.

    eduardonunesp commented Jan 7, 2020

    Gotcha, thanks for the clarification, definitely isn’t a beginners task

    xoofx commented Jan 21, 2020 •

    I’m discovering this while switching to this terminal and this is really annoying.
    I was previously using cls to clear not only the screen but also the history, when you are using the same terminal for hours, and you are running commands that can generate errors, scrolling back is making things very difficult to spot which command is failing (when the errors can span on several pages), the sensitivity of the scroll is making too easy to scroll back to a previous command without noticing.

    So big 👍 for a keystroke as I understand that cls is not meant for the history.

    Thinking about it, also, as a nice improvement, maybe it is something that has a feature request on its own, but a “bird-view” side pane on the right side where we could spot easily where commands are and where are the outputs would be also super useful.

    This comment has been minimized.

    This comment has been minimized.

    This comment has been minimized.

    This comment has been minimized.

    jijiechen commented Nov 8, 2020

    On my terminal, it worked by input tput reset
    But tput clear did not work.

    csabka commented Mar 14, 2021

    I have created a workaround which worked on WSL/bash, SSH/bash (Linux tested) and PowerShell 7 for me with CTRL+ALT+K:

    \u001B[F” >, “name”:”Clear screen and Scrollback”, “keys”: “ctrl+alt+k” >,

    These steps will done with sendInput action:

    1. send home key (if you already type something into shell)
    2. send # (comment out what you have already typed)
    3. send return (save commented out strings to history note: \n : only work on linux so I used \r)
    4. send tput reset or printf with CSI codes (if tput command fails) or Clear-Host (if both commands failed: eg in PowerShell)
    5. send two times up key for history (needs to have history in shells)
    6. send home key
    7. send delete key to remove first character “#” from the beginning (written by step 2.)
    8. send end key to put cursor back to the end (you can continue typing of the command)

    For me the history and scrollback are cleared

    Can we set up global ADB on Mac by adding ADB variable environment? I had this question in mind while writing a tutorial on setting up system-wide ADB and Fastboot on Windows. “ADB command not found” is a common issue for Android users trying to run ADB commands on Mac. Fortunately, there’s an easy way to add ADB to a path on Mac by setting up PATH variable in bash profile and enable universally present ADB and Fastboot.

    Besides, there’s another trick that involves dragging the ‘Platform-tools’ folder to the Mac Terminal. By doing so, you can immediately trigger ADB and Fastboot and start using commands without adding the folder path manually.

    Once you have set up global ADB and Fastboot by adding ADB or Platform-tools to a path via a Bash profile in the Mac Terminal, you’ll be able to run ADB commands from any screen.

    Set up ADB Path in Mac Terminal Bash Profile

    If you want to enjoy global access to the ADB and Fastboot command-line tools right after launching the Mac Terminal, follow the steps described below.

    1. Download the latest Android SDK Platform-tools that contain ADB and Fastboot drivers for Mac. Extract the downloaded zip to get a folder named ‘platform-tools‘.
    2. Now open the Home directory on your Mac. If you don’t know how to do that, there are 3 ways to open it.
      • Press Command+Shift+H on your keyboard.
      • Press Command+Shift+G and enter

    /’.

  • Double-click the Macintosh HD icon on your desktop. Now click Users > Home icon.
  • Click on the Go tab in the Finder bar and select Home.How to run any mac terminal command with a keyboard shortcut
  • Create a new folder called ‘android-sdk-macosx‘ in the Home directory. You can rename it as ‘ADB’ or ‘AndroidSDK’ too if you want.
  • Now, right-click on the ‘platform-tools‘ folder icon and select the Copy “platform-tools” option from the context menu.
  • Paste the ‘platform-tools‘ folder in the new folder you created. You can move this folder to any other location where you won’t accidentally delete them. I moved it to the root of my Macbook Pro’s storage.How to run any mac terminal command with a keyboard shortcut
  • Launch the Mac Terminal app from Finder > Go > Utilities.How to run any mac terminal command with a keyboard shortcut
  • When the Terminal is open, type the following command given below and press the Enter key. In order to avoid typo mistakes, you can simply copy and paste the command into the Terminal window. Just make sure to use the correct path of the ‘platform-tools‘ folder in the command line. You can easily copy the folder path on Mac using the tips in my guide.

    How to run any mac terminal command with a keyboard shortcut

  • In case you moved ‘platform-tools’ to the Home directory, you can use the following command after replacing username with yours.
  • Now that the ADB PATH variable has been added to your bash profile, you need to reload it using the following command. Alternatively, you can just close the Terminal window and re-launch it.

    How to run any mac terminal command with a keyboard shortcut

  • If you want to check the current value of the PATH variable, you can use the following command. Otherwise, just skip to the next step.
  • Since you have already added ADB to Path on your Mac, you can start using ADB or Fastboot commands. It’s time to verify that you have set up ADB properly on your Mac. Just type adb or adb devices in the Terminal and hit the Enter key.How to run any mac terminal command with a keyboard shortcut
  • In case you get the ‘adb: command not found‘ error on your Mac, you might have made some mistake. Try the steps given above again more carefully.
  • Add Terminal Shortcut to Platform-Tools

    Finally, here’s the easiest method to add any folder path to the Mac terminal. Just follow the tip described below to get rid of typing the ‘platform-tools‘ folder path in the Mac Terminal every time you have to use ADB and Fastboot commands. It doesn’t provide a global or system-wide ADB support as the above method does.

    1. Open System Preferences on your Mac.
    2. Click on Keyboard.How to run any mac terminal command with a keyboard shortcut
    3. On the next screen, click on Shortcuts and select Services from the left pane.
    4. Now, look for Files and Folders in the right pane and enable New Terminal at Folder.
    5. The shortcut will be added to the folder context menu. You can close the System Preferences window.
    6. Just right-click on the ‘platform-tools‘ folder icon and select the New Terminal at Folder option.How to run any mac terminal command with a keyboard shortcut
    7. When the Terminal window is launched, you can run any ADB and Fastboot command directly without typing the folder path.

    How to run any mac terminal command with a keyboard shortcut List of ADB devices in Mac Terminal

    If you want to learn more about ADB and Fastboot, read my tutorial describing some more ways to install ADB on Mac. You should also check out these ADB Shell commands and other stuff that you can do on your Android device with ADB.