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.
Shell Safe rm🔗
Source shell-safe-rm github
A much safer replacement of bash rm
with ALMOST FULL features of the origin rm
command.
Initially developed on Mac OS X, then tested on Linux.
Using safe-rm
, the files or directories you choose to remove will move to $HOME/.Trash
instead of simply deleting them. You could put them back whenever you want manually.
If a file or directory with the same name already exists in the Trash, the name of newly-deleted items will be ended with the current date and time.
Install with npm:
npm i -g safe-rm
Add Alias to your zshrc config
alias rm='safe-rm'
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/autoconf.nanorc
include /usr/local/share/nano/awk.nanorc
include /usr/local/share/nano/c.nanorc
include /usr/local/share/nano/changelog.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/default.nanorc
include /usr/local/share/nano/elisp.nanorc
include /usr/local/share/nano/fortran.nanorc
include /usr/local/share/nano/gentoo.nanorc
include /usr/local/share/nano/go.nanorc
include /usr/local/share/nano/groff.nanorc
include /usr/local/share/nano/guile.nanorc
include /usr/local/share/nano/html.nanorc
include /usr/local/share/nano/java.nanorc
include /usr/local/share/nano/javascript.nanorc
include /usr/local/share/nano/json.nanorc
include /usr/local/share/nano/lua.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/nanohelp.nanorc
include /usr/local/share/nano/nanorc.nanorc
include /usr/local/share/nano/nftables.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/po.nanorc
include /usr/local/share/nano/postgresql.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/rust.nanorc
include /usr/local/share/nano/sh.nanorc
include /usr/local/share/nano/spec.nanorc
include /usr/local/share/nano/tcl.nanorc
include /usr/local/share/nano/tex.nanorc
include /usr/local/share/nano/texinfo.nanorc
include /usr/local/share/nano/xml.nanorc
Save & Exit
source ~/.zshrc
Disable/Enable Gatekeeper🔗
Disable Gatekeeper
sudo spctl --master-disable
Enable Gatekeeper
sudo spctl --master-enable
Check Status
spctl --status
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.
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"
Disable "last login" at Terminal🔗
cd ~/
touch .hushlogin
Flush DNS🔗
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
Fix Missing /Users/Shared Folder🔗
Create he missing /Users/Shared folder
sudo mkdir -p /Users/Shared/
Fix permissions for the /Users/Shared folder
sudo chmod -R 1777 /Users/Shared
Google Drive File Sync Fix for macOS🔗
quit Google Drive
cd ~/Library/Application\ Support/Google
mv DriveFS DriveFS.old
relaunch Google Drive