macOS System Tweaks and Guides for Better Experience, Productivity and Workflow

Import RSA Keys to macOS Keychain

Copy your id_rsa, id_rsa.pub to ~/.ssh/ folder

Step 1 - Store the key in the keychain Just do this once:

ssh-add -K ~/.ssh/[your-private-key]

Enter your key passphrase, and you won't be asked for it again.

(If you're on a pre-Sierra version of OSX, you're done, Step 2 is not required.)

Step 2 - Configure SSH to always use the keychain It seems that OSX Sierra removed the convenient behavior of persisting your keys between logins, and the update to ssh no longer uses the keychain by default. Because of this, you will get prompted to enter the passphrase for a key after you upgrade, and again after each restart.

The solution is fairly simple, and is outlined in this github thread comment. Here's how you set it up:

Ensure you've completed Step 1 above to store the key in the keychain.

If you haven't already, create an ~/.ssh/config file. In other words, in the .ssh directory in your home dir, make a file called config.

In that .ssh/config file, add the following lines:

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

Change ~/.ssh/id_rsa to the actual filename of your private key. If you have other private keys in your ~.ssh directory, also add an IdentityFile line for each of them. For example, I have one additional line that reads IdentityFile ~/.ssh/id_ed25519 for a 2nd private key.

The UseKeychain yes is the key part, which tells SSH to look in your OSX keychain for the key passphrase.

That's it! Next time you load any ssh connection, it will try the private keys you've specified, and it will look for their passphrase in the OSX keychain. No passphrase typing required.

Disable StrictHostKeyChecking in SSH

To disable strict host checking on OS X for the current user, create or edit ~/.ssh/ssh_config and add the following lines:

   StrictHostKeyChecking no

Set macOS Hostname via CLI

sudo scutil --set HostName <NewHostNameHere>

Syntax Highlighting In Nano on Mac OS X

Install Nano from homebrew Create nanorc file with the syntax below

brew install nano
nano ~/.nanorc

nanorc:

include /usr/local/share/nano/asm.nanorc
include /usr/local/share/nano/awk.nanorc
include /usr/local/share/nano/c.nanorc
include /usr/local/share/nano/cmake.nanorc
include /usr/local/share/nano/css.nanorc
include /usr/local/share/nano/debian.nanorc
include /usr/local/share/nano/fortran.nanorc
include /usr/local/share/nano/gentoo.nanorc
include /usr/local/share/nano/groff.nanorc
include /usr/local/share/nano/html.nanorc
include /usr/local/share/nano/java.nanorc
include /usr/local/share/nano/makefile.nanorc
include /usr/local/share/nano/man.nanorc
include /usr/local/share/nano/mgp.nanorc
include /usr/local/share/nano/mutt.nanorc
include /usr/local/share/nano/nanorc.nanorc
include /usr/local/share/nano/objc.nanorc
include /usr/local/share/nano/ocaml.nanorc
include /usr/local/share/nano/patch.nanorc
include /usr/local/share/nano/perl.nanorc
include /usr/local/share/nano/php.nanorc
include /usr/local/share/nano/pov.nanorc
include /usr/local/share/nano/python.nanorc
include /usr/local/share/nano/ruby.nanorc
include /usr/local/share/nano/sh.nanorc
include /usr/local/share/nano/tcl.nanorc
include /usr/local/share/nano/tex.nanorc

Save & Exit

source ~/.zshrc

Force Language Change on iTerm Focus to English

  • Install KeyBoard Maestro
  • Create a group in Groups section. I named my Personal
  • Now create a macro with the name Set iTerm Application Language.
  • Add another trigger -> This application -> Select iTerm -> Select Active -> Repeating every 1 seconds.
  • Add New Action -> Select Set KeyBoard Layout -> Select the keyboard layout (i.e., language preference).
mac image

Disable/Enable SIP (System Integrity Protection)

Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen.
Click Utilities > Terminal.
In the Terminal window, type in:

Status:

csrutil status

Disable:

csrutil disable

Enable:

csrutil enable

Press Enter and restart your Mac.

Running Multi Instances of an Application

Launch the Script Editor choose temporary folder

Copy the command to be executed to the Script Editor

do shell script "open -n <path to application>"

Example

do shell script "open -n /Applications/'Visual Studio Code.app'"

File > Export

Use the following settings:

  • Export As: Your New Application Name
  • Where: Applications
  • File Format: Application

Change The Icon of Your New Application:

In Finder got to Applications folder. Right Click on the new Your New Application application we just created and click Get Info. Drug the original application icon (or any other) to the in the left corner of the "get info" menu.

Lunch Firefox Profile Manager as Application

Launch the Script Editor choose temporary folder

Copy the command to be executed to the Script Editor

do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &"

File > Export

Use the following settings:

  • Save As: Firefox Profile Manager
  • Where: Applications
  • File Format: Application

Change The Icon of Your New Firefox Profile Manager Application:

In Finder got to Applications folder. Right Click on the new Firefox Profile Manager application we just created and click Get Info. Drug the original application to the icon in the left corner of the "get info" menu.

Installing rbenv (ruby send box) - Ruby alternative to the one that macOS uses

Install rbenv with brew

brew install rbenv

Add eval "$(rbenv init -)" to the end of ~/.zshrc or ~/.bash_profile

Install a ruby version

rbenv install 2.3.1

Select a ruby version by rbenv

rbenv global 2.3.1

Open a new terminal window

Verify that the right gem folder is being used with gem env home(should report something in your user folder not system wide)

List listening Ports and Programs and Users (netstat like)

sudo lsof -i -P | grep -i "listen"

Flush DNS

sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache

Google Drive File Sync Fix for macOS

quit Google Drive

cd ~/Library/Application\ Support/Google
mv DriveFS DriveFS.old

relaunch Google Drive

Comments