Keyboard shortcut to execute a shell command in iTerm2 - keyboard-shortcuts

Say in my repo I tend to frequently do open . or open .gitignore from the command line. I'd like to have keyboard shortcuts for iTerm2 that just do these two.

Here's one way to do it:
In Preferences › Keys › Key Bindings, add a new key binding with these values:
Shortcut of your choosing
Action: Send Text
With value:
open .gitignore
Mind the line-break (you can add it with option-Enter) so as to execute the command and not just paste it.
(I use this with Cmd-S as a shortcut to git status.)

Related

How can I open the ~/.ssh/config file as a text file instead of opening the TextEdit app on Mac?

I have been trying to add my SSH keys to the ssh-agent by following the directions on this GitHub doc: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
This is what I put into the terminal:
root#Nicoles-MacBook-Air nicoletr # eval "$(ssh-agent -s)"
Agent pid 21417
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
The file /var/root/.ssh/config does not exist.
root#Nicoles-MacBook-Air nicoletr # touch ~/.ssh/config
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
But when I hit enter to open the ~/.ssh/config file, the TextEdit app opens instead of a text file that I can modify. I am supposed to modify the config text file but I don't even see any file at all. I am still very new to coding so I would be extremely grateful for any guidance.
Open command
On MacOS, the open command will open file in parameter with the default configured application for this filetype (such as Preview, TextEdit or Safari for some others)
Even though you can override which application is used to open the file, there are more standard solutions to achieve this.
For the sake of completeness, you can override default app by using -a option, for example, if you want to open an html file with TextEdit instead of Safari by default:
open -a TextEdit page.html
More information about open:
Article on scriptingosx.com
Open man page
Alternative
If you would like to edit any file directly from your terminal, you can use packages such as nano, to easily get started with it you can check this article. As an added bonus, it also go through setting brew to easily install package, also from your terminal
There are alternatives to nano (like vi, vim) and to brew (such as macports). They all have their pros and cons depending on the use, though in you case, I don't think your need would justify the steeper learning curve yet
Happy discovering coding !

Add shortcut to open specific url in browser - Intellij Shortcut

I want to add Shortcut to open specific URL (let say localhost:3000) in IntelliJ. I read the documentation and try to figure it out on my own by messing around the Keymap, but No luck. Is this possible? What I want is to create a shortcut to open specific URL. If my custom shortcut is Alt +; then it should open http://localhost:3000. Is this feasible in IntelliJ?
Yes you can do this with the following steps...
1. Define an external Tool for Localhost
File > Settings...
Tools > External Tools
Define your Tool with
Program: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe (in Windows 10)
Arguments: http://localhost:3000
2. Define your shortcut
File > Settings...
Keymap
Choose External Tools > Localhost on the right side
Right click and choose 'Add Keyboard Shortcut'
Type your Shortcut
You should see it in the dialog
3. Use the Shortcut
Hope it helps.

Vagrant up when opening project in PhpStorm

Is there a way to automatically run vagrant up when I open up a project in PhpStorm?
(and may a vagrant halt when closing the project)
I tried to add a task, what actually only runs external programms or tools. My thought was to call a shell-script. But I would prefer to keep this all in PhpStorm and seeking for a possibility to handle all this inside of PhpStorm.
In PHPStorm :
CTRL + SHIFT + A.
Startup Tasks.
in the bottom left corner click on + icon.
Add configuration.
Add shell script.
now you can either enter the content of the command in that case 'vagrant up' or create a .sh file and put the path of it in the path section.
now each time you'll open PHPStorm on this project, your VM will boot up.

How to add a directory to SQL*Plus include path?

I would like to add a directory D:\pl-sql to the include path of SQL*Plus so I can then work with files in that directory like, for example, edit them with this command:
EDIT hello.sql
How can I do that?
ORACLE_PATH is the variable you are looking for. (on Unix) and SQLPATH (for windows)
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b12170/ch3.htm#i1052303
This link explains how you can add to the registry entry for windows..
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b12170/ch3.htm#i1133354
I'm in the habit of creating shortcuts to sqlplusw.exe in my script folders. Edit the shortcut properties to remove anything from the "Start in" field. I can even add the login info on the command line ("Target") so that I can connect instantly with a double-click.

Automating GNUStep from Notepad++

I use GNUStep to compile Objective-C on Windows 7 using GCC and MinGW. I'd like to be able to automate the "make" instruction (with make files) from Notepad++ and have any complier errors reported to Notepad++s console window.
Edit:
What I am trying to do is script GNUStep/Bash to login to the right directory, build the directory, then exit. Currently I have to type in the following:
sh -login -i
$ cd d:\directory
$ make
Does anyone have any experience with this?
Rich
The npp-plugins gives you most of what you are looking for. Install the plugin and:
Press F6 to open the NppExec Execute window
Type 'make' (you may also want to cd to the proper directory first) and click OK
Output from make is shown in the notepad++ console
Another cool feature is that it will save the command if you restart notepad++, so you only need to type 'make' a single time.
You may need to make some tweaks to only show compiler errors, however.
I have done it, with considerable help from my friends.
Create a Bash script called 'nppmake'. I saved it in c:\GNUStep. The file should contain the following:
#! /bin/bash
cd $1
make
Create a DOS batch file called 'nppmake.bat', which again I saved in c:\GNUStep. This file contains the following:
sh --login -i C:\GNUstep\nppmake %1
In N++, go to 'Plugins > NppExec > Execute' and type in the following:
C:\GNUstep\nppmake.bat $(CURRENT_DIRECTORY)
Hit 'Save' and call the script 'make'.
In 'Plugins > NppExec > Advanced Options...', create a menu item, which I called 'Build' and associate it to the script called 'make' (I'm a Visual Studio developer, so 'build' feels more natural to me). Make sure 'Place to the Macros submenu' is checked.
You may need to restart N++ at this point, but then all that is left to do is add the keyboard shortcut. Go to 'Settings > Shortcut Mapper > Plugin Commands' and find 'Build'. I assigned 'Ctrl-Shift-B', is it is the same as VS.
You're done. Now open up a file in a Objective-C project, that has a GNUmakefile, and hit 'Ctrl-Shift-B'. The NppExec window reports any errors, or hopefully a successful build!
Just a small correction to kim3er's answer.
cd $1 make
should be
cd $1
make