# Start here

Notes, cheatsheets and scripts

This is a collection of notes, cheatsheets and scripts that I refer back from time to time. It is not designed to be coherent or complete, but it works for me.

Or, go back: <https://daitya.info>


# New Mac Setup

Bare minimum apps and configurations that work for me

## Apps

* [ ] [1Password](https://1password.com) - Password manager. *Subscription*.
* [ ] [Firefox](https://www.mozilla.org/en-US/firefox/mac/) and [Chrome](https://www.google.com/chrome/)
* [ ] [Setapp](https://setapp.com) - Netflix for Mac apps. *Subscription*.
* [ ] [Spectacle](https://www.spectacleapp.com) - Move and resize windows. Magnet alternative. *Free*.
* [ ] [Vanilla](https://matthewpalmer.net/vanilla/) - Hide menu bar icons. Bartender alternative. *Free / Pro.*
* [ ] [Alfred](https://www.alfredapp.com) - Replaces Spotlight search on Mac. *Free / Pro.*
* [ ] [Maccy](https://maccy.app) - Clipboard manager. *Free / Tip.*
* [ ] [MeetingBar](https://apps.apple.com/us/app/meetingbar/id1532419400?mt=12) - View meetings on Menu Bar. *Free.*
* [ ] [Brightintosh](https://brightintosh.de) - Increase max brightness. Free.
  * [ ] Paid alternative [Vivid](https://www.getvivid.app).
* [ ] [MuteKey](https://macmenubar.com/mutekey/) - Additional mute controls. *Free.*
* [ ] [Mos](https://mos.caldis.me) - Smoother scrolling. *Free.*

## Browser Plugins

* [ ] Ad blockers
  * [ ] Safari - [Wipr](https://apps.apple.com/us/app/wipr/id1320666476?mt=12)
  * [ ] FF / Chrome - [uBlock Origin](https://github.com/gorhill/uBlock)
* [ ] Privacy -  [Ghostery](https://www.ghostery.com/ghostery-browser-extension/)
* [ ] Read Later - [Instapaper](https://apps.apple.com/us/app/instapaper-save/id1481302432?mt=12) / [Raindrop.io](https://raindrop.io/download)
* [ ] [1Password](https://support.1password.com/getting-started-browser/)

## System Configs

#### **Change TRACKPAD settings**

* [ ] *Preferences -> Trackpad*
  * "Tap to click"&#x20;
  * "Lookup and data detectors" with 3 finger tap
* [ ] "3 finger window drag" - *Preferences -> Accessibility -> Pointer Controls -> Trackpad options -> Enable dragging*

![](/files/-Mg10vu5unREDzZQqqM3)

#### **Create** [**Lock Screen**](/macos/create-lock-screen-shortcut-on-mac) **shortcut** - **`⌥`** + **`L`**

#### **Change Screenshot shortcut** to **`⌘`** + **`shift`** + **`C`**

* *Keyboard Preferences -> Shortcuts -> Screenshots -> Copy picture of a selected area to the clipboard*

#### **Replace Spotlight with Alfred** keyboard shortcut - **`⌘` + `space`**

## `Code``.things`

* [ ] [Homebrew](https://brew.sh) - Package manager for Mac
* [ ] [Customize Terminal](/macos/customize-terminal) - Basic tweaks
* [ ] [Multiple Python](/dev/multiple-python-on-macos) - Using the magic of `pyenv`
* [ ] [Git](/dev/git-basics) - Git basics and cheatsheets
* [ ] [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) - Manage AWS from Terminal
* [ ] [Sublime Text](https://www.sublimetext.com) - Simplest and fastest code editor
  * [ ] Add autosave ([ref](https://lucybain.com/resources/setting-up-sublime-autosave/))

##


# Mac hacks

Handy tips and tricks to use MacOS like a boss

### Take screenshots with shadows

Press `⌘` + `shift` + `4` then press `Space`. The selector will then change into a camera icon, and you can take a screenshot of the selected window with a shadow. Screenshot gets stored on Desktop by default.

*(*[*Source*](https://apple.stackexchange.com/questions/14769/how-does-one-make-screen-captures-with-a-shadow)*)*

### Add custom website search to Firefox

#### To save

1. Go to the website (say Stackoverflow)
2. Right click on the SEARCH field, select `Add A Keyword For This Search`

   ![](/files/LIFYWyaVtk2cd6vUsNQY)
3. Save the bookmark with a custom keyword&#x20;

   ![](/files/MHiw1hR7P5A9kBbi5x14)

#### **To use**

1. In the address bar, just type the customer keyword followed by a space followed by the search query: `<keyword><space><search query>`\
   ![](/files/eGuti0ltviiIg6rQc1Mz)

### Reduce file size - good quality filter in Preview

<https://apple.stackexchange.com/questions/297417/how-to-decrease-pdf-size-without-losing-quality>


# Customize Terminal

* Open Terminal and type nano `.bash_profile`. Or, open it in Sublime Text.
* Paste in the following code
* Hit Control+O to save, then Control+X to exit out of nano

```
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\
[\033[m\]\$ "
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=FxFxBxDxCxegedabagacad alias ls='ls -GFh'
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
```


# Mac Lock Screen Shortcut

Create a custom Lock Screen shortcut on Mac

* Open **Keyboard Preference** Pane
* Go to **Shortcuts** tab
* Select "**App Shortcuts**"
* Click "**+**"
* Select "All Applications", then **type** "`Lock Screen`" (it is case sensitive) and type your shortcut: **`⌥`** + **`L`**.

![](/files/-Mg11em5Y61itxt_aViC)

* Quit System Preferences
* Rejoice and wonder why it isn't the default Lock Screen shortcut in the first place


# Git Basics

Because one does not simply remember all git commands.

Best resource on Git: <https://rogerdudler.github.io/git-guide/>, there is also a [cheatsheet](https://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf).


# Multiple Python versions

Because one does not simply mess with MacOS default Python

## Install Homebrew

Homebrew is a package manager for MacOS, must have CLI utility.

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

## Install latest python

MacOS comes with a python version but you should install the latest stable version of python.

```
 brew install python
```

## Install pip

Download the `get-pip` file

```
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
```

Now run this file to install pip

```
python get-pip.py
```

## Change global default python to latest python

```
sudo ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python
```

## Install pyenv

`pyenv` makes it easy to install, manage, and switch between multiple Pythons versions.

```
brew install pyenv
```

## Install multiple python versions in pyenv

```
pyenv install 3.9.4
pyenv install 2.7.16
```

## Change default python in pyenv to latest and greatest

```
pyenv global 3.9.4
```

## Running pyenv

```
pyenv versions
python -m venv venv
source ./venv/bin/activate
(venv) $ which python
```

To exit the virtual environment

```
deactivate
```

#### References

* <https://opensource.com/article/19/6/python-virtual-environments-mac>
* [https://jacobian.org/2019/nov/11/python-environment-2020/ ](<https://jacobian.org/2019/nov/11/python-environment-2020/ >)


