Macbook Aur M1 2020 specification


Option (ALT) key is ⌥ Command cmd key is ⌘ Shift key is ⇧ Return key is ↵ Control (CTRL) key is ^

Since on mac keyboard fn key is at left edge, I use it as ctrl . Remap with System preferences -> Keyboard -> Modifier Keys -> Globe key -> ^Control

If tilda and backtick are not on top left corner, you can use different Keyboard -> Input sources -> English British so at least backtick is on top left key.

To remap keys on keyboard you can use hidutil You can find key codes in a table on that link. Than use OR with 0x700000000. I tried Key Codes app but I do not know how to get hex code that is the same as in the table.

To switch switch keys 1 and 2 use 0x70000001e and 0x70000001f

hidutil property --set '{"UserKeyMapping":
# to see what is already mapped
hidutil property --get 'UserKeyMapping'
# clear mappings
hidutil property --set '{"UserKeyMapping":[]}'

To start inserting emoji use: Control + Command + Space

Edit Terminal background I tried to be as it is on ubuntu Chose Pro profile on Terminal -> Preferences -> Profiles

brew install bash

sudo vi /etc/shells
# add

# and now changing the shell will succeed
chsh -s /opt/homebrew/bin/bash

Also change font to Monospace Regular style (you can see it on ubuntu terminall Preferences -> Default -> Text). You can also use Ubuntu Mono Regular Copy ttf file to Libraries (in finder use menu item Go -> Library).

Also in terminal profiles Pro select: When the shell exists: “Close if the shell exited cleanly”.

Very usefull is to install completions for commands

In any window, or shell, you can:

  • ⌘ n new window
  • ⌘ t new tab, ⌘ w close tab

From System Preferences -> Keyboard -> Shortcuts

  • Spotlight
    • ⌘ space spotlight search
    • ⌥ ⌘ space finder search, inside finder you can open files with double click or ⌘ o (enter just renames the file)
  • Mission control
    • ^ up mission control
    • ^ down application windows in all workspaces, use arrow to focus, use tab to select another application and view it’s windows
  • Screenshot
    • ⌘ shift 3 and ⌘ shift 4 to create screenshots for entire and selected area. Press space after ⌘ shift 4 to select window. Screen shots will be on desktop.

With fn F3 (or swipe up with three fingers) you can create new spaces (any number of workspaces) desktops. You can switch between them with left/right swipe with three fingers and you can drag and drop to different workspaces. Full screen apps open their own space. From Mac keyboard shortcuts from support

  • ⌘ H hide front app
  • ⌘ ⌥ H to show only front app
  • Fn-delete is forward del since that key does not exists on macbook air

Click on link by holding ⌘ or ⌥ or ctrl will open new tab (with shift it will focus that new tab), download and open context menu (ctrl click also works for selected text).

To use apple keyboard on ubuntu I tried to remap Fn key, but that is not possible

To connect two monitors on one port you need adapter that supports mst dual external displays For M1 is it not enough to use two ports with two adapters. you need to use usb A to hdmi adapter that is DisplayLink compatible: driver list long description

Another solution using magiclink cable

To show home folder in Finder, go to Finder Preferences -> Sidebar and enable home folder in sidebar. Inside Finder Go menu you can hold ⌥ key to show Library folder. It is by default hidden from user. To permanently enable showing it, go to home folder in finder app, right click on empty space and choose ‘Show View Options’ from dropdown. Than select ‘Show Library Folder’. Some app data can be ~/Library/Containers/com.mydomain.myaoo/Data/Library/Application%20Support/myapp/ When you open the app using ⌘ + space than it is usually from Applications folder, but it could be from Downloads. You can check where app is location by right clicking on app icon in Dock than Options -> Show in finder

I added to .bash_profile:

  • alias ls='ls -Gp' so I can see difference between files and folders

To enable ssh server you need to go “System Preferences -> Sharing -> enable Remote login”

To rename hostname go to System preferences -> Sharing

Position windows using spectacle video. Comparison of all os-x-windoiw-manager. I found interesting hammerspoon blog

Karabiner Elements to change keys

Former name for this app was KeyRemap4MacBook.

Install instructions after allowing karabiner_oberver you need to manually add also the karabiner_grabber by selecting Machintos HD -> /Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_grabber

To map colon to semicolon you need to add entry for semicolon and than edit .config/karabiner/karabiner.json file to add "modifiers": ["shift"]

            "simple_modifications": [
                    "from": {
                        "key_code": "semicolon"
                    "to": [
                            "key_code": "semicolon",
                            "modifiers": ["shift"]

Another solution is ukulele Ukulele contains great manual but it is not easy to remember all changes… Save it and use finder to copy it to Library -> Keyboard Layouts folder and than add that layout in Settings -> Keyboard -> Input Sources, and than check “Show Input menu in menu bar” and select that new layout from top right menu bar.

Update packages

Install homebrew Update bash: brew install bash link

brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt
brew info coreutils

brew install bash-completion

Install meld for mac

On high sierra you need to run

unlink /Applications/

Install java JRE from jre-9.0.4_osx-x64_bin.dmg (not tar.gz) Double click will install. You can check if installed using on safari.

Install vim

brew install vim --override-system-vi
# if you receive error
# xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcode-select --install

Instal pip

sudo easy_install-3.6 pip
pip3 install awscli  --user --upgrade


You can maps pageup in iterm. Do ⌘ , to open Preferences -> Keys -> Key mappings and add ⌘ [ and ⌘ ] to map scroll page down and up. But that does not work well for vim since it show previous page in terminal buffer (not in vim) so for vim use ^b and ^f (^d and ^u for half down up)


  • new disks like sd card will be mounted under /Volumes instead of /media or /mnt


You can run and edit scripts in Script Editor. Open Dictionary in File->Open Dictionary or drag application icon to Script Editor application icon.

# comments
-- this is comment
# this is also comment
{* multi 
comment *}

# continuation character Option l
dialog "This is long line" ¬
buttons { "Great", "OK" }

# Boolean
true, false
# Text
# List
{ 1, "Duke" }
# Record
{name: "Duke", age: 35}

# Operators
"a" & "b"

# variables
set myName to "John"
copy 33 to myAge

Send keys

" you can use app Key codes to find a code
key code 36
keystroke "ASD"
delay 1

Statements can include all above. Simple statement is single line, multiline is compound statements

tell application "Finder"
  -- by position index, first/last or front/back, name
  get the name of window 2
  -- same as get the name of second window
  -- same as get the name of 2nd window
  -- same as get the name of the window after the front window
  -- same as get the name of window "Trash"

  -- name can not be updated, but other (like index) can be updated
  set the index of the last window to 1
  set toolbar visible of the front Finder window to true
  set the sidebar width of  the second Finder window to 240
  set the position of the front Finder window to {94, 134}
  set the bounds of the front Finder window to {24, 96, 524, 396}
  set the target of the front Finder window to home

  open window "Trash"
  -- same as select window "Trash"
  tell the front window
    set the current view to flow view
    set the bounds to {528, 116, 1016, 674}
  end tell

  close window "Trash"
  set savedName to name of front window
  set windowRef to a reference to window 1
  set windowId to theWindow's id
  -- same as set windowId to id of the first window

end tell

If conditional with type casting

if (myVar as string) is equal to "asd" then
end if

If you want to check the type of variable

if class of myVar is string then
end if

If you got exception than wrap with try to do exceptions handling

    set a to a as number
    display dialog "Yes! It's a number!"
end try

-- or

  set windowId to do shell script "defaults read com.duleorlovic.windowShortCuts " & key
on error
  display dialog "Please create window shortcut for key "
end try

Get user input

set theResponse to display dialog "Key (h, j, k, l, semicolon, m, comma, dot, slash, u, i) ?" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
if button returned of theResponse is equal to "Cancel" then
 error number -128
end if
set key to text returned of theResponse

Sample programs

Command is series of words that request an action. Command is directed to a target. Choose file

    set xfile to choose file
    set xpath to POSIX path of xfile

Debugging with display dialog "message". Use double quotes, not single quote.

Array list iterate loop

set theList {1, 2, 3}
set first as item 1 of theList
set first to item 1 of theList
on getPositionOfItemInList(theItem, theList)
    repeat with a from 1 to count of theList
        if item a of theList is theItem then return a
    end repeat
    return 0
end getPositionOfItemInList

set theList to {"Sal", "Ben", "David", "Chris", "Jen", "Lizzie", "Maddie", "Lillie"}
getPositionOfItemInList("Maddie", theList)

String manipulation

Split string

set AppleScript's text item delimiters to "-"
set theTextItems to every text item of windowNameId
set AppleScript's text item delimiters to ""
set windowId to item 2 of the theTextItems

You can run scripts inside bash with osascript -e 'display dialog "Hi"' or for shell scripts (you need to chmod +x filename.txt

display dialog "Hi"

You can also call scpt file

osascript ~/myscript.scpt


Activate window

iTerm supports hotkeys but it is not generic. I rather write window id and hotkey combination in user store using a b or b h commands

do shell script "defaults write com.myname.myapp foo bar"
set myValue to do shell script "defaults read com.myname.myapp foo"

To assign keyboard shortcuts you need to create a service in Automator and create shortcut in System Preferences -> Keyboard -> Shortcuts -> Services That is available in all apps, you can find them on main menu using app name on top left position -> Services. If there is already some shortcut than you need to remap it to another key, I use same with a shift.

Create service for each key, for example activateWindowL (/home/orlovic/Library/Services/activateWindowL.workflow).

on run {input, parameters}
    -- note that mac path is using colons instead of slash
    run script file "Macintosh HD:Users:dule:config:bashrc:mac_scripts:mac_activate_window.scpt" with parameters {"l"}
    return input
end run

Or you can copy all

You can disable any special key for any app so we can use it for our navigation. From System Preferences -> Keyboard -> Shortcuts -> App Chortcuts -> + than select the app and write exact name and add shortcut uncluding ⌥ key:

  • for iTerm I do not need Clear Buffer so now it is ⌘ ⌥ M
  • Mission control -> Move left space I remaped to ^ ⌘ h (also right space ^ ⌘ l)
  • to disable hide front app, it has to be done for each app, for example, Hide Terminal should be remaped to cmd + shift + h here is the list of all mappings:
  • All Applications: Minimise ⇧ ⌘ J
  • Finder: Connect to Server ⇧ ⌘ K
  • Terminal: Clear to Previous Mark ⇧ ⌘ L, Jump to Selection ⇧ ⌘ J, Clear to Start ⇧ ⌘ K, Hide Terminal ⇧ ⌘ H
  • Google Chrome: Hide Google Chrome ⇧ ⌘ H, Jump to Selection ⇧ ⌘ J, Open Location… ⇧ ⌘ L
  • Preview: Rotate Left ⇧ ⌘ L
  • Firefox: Downloads ⇧ ⌘ J, Hide Firefox ⇧ ⌘ H

Mac keyboard shortcuts

Overwrite app shortcuts

To get foremost window chap 3 name property

# open last window
do shell script "open -a Google\\ Chrome"
tell application "iTerm"
       set theWindow to the first item of ¬
               (get the windows whose name is "2. bash")
       if index of theWindow is not 1 then
               set index to 1
               set visible to false
               set visible to true
       end if
end tell
tell application "System Events" to tell process "iTerm"
       perform action "AXRaise" of (first window whose name contains "2.")
end tell


brew unlink imagemagick
brew install [email protected] && brew link [email protected] --force

gem install puma -v 2.11.3 -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib

brew install qt


brew install mysql will will use /tmp/mysql.sock so you can create link to ubuntu folder of mysql socket file

sudo mkdir -p /var/run/mysqld
sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock

To permanently change socket file location you can update

sudo vi /usr/local/etc/my.cnf

To start mysql server you can run mysql.server start To find locaiton of mysql config files

brew --prefix mysql

To see error log

tail -f /usr/local/var/mysql/mac.local.err

Usually enable permissions for sudo chown _mysql /usr/local/var/mysql/* but it is easier to enable for all

sudo chmod -R 777 /usr/local/var/mysql/
sudo chmod 777  /var/run/mysqld/


On Mac I got error

Caused by:
LoadError: Could not open library '/Users/dule/.rvm/gems/ruby-2.6.5/gems/sassc-2.2.1/lib/sassc/libsass.bundle': dlopen(/Users/dule/.rvm/gems/ruby-2.6.5/gems/sassc-2.2.1/lib/sassc/libsass.bundle, 5): no suitable image found.  Did find:
	/Users/dule/.rvm/gems/ruby-2.6.5/gems/sassc-2.2.1/lib/sassc/libsass.bundle: load commands not in a segment
	/Users/dule/.rvm/gems/ruby-2.6.5/gems/sassc-2.2.1/lib/sassc/libsass.bundle: stat() failed with errno=25

which I solved with

gem uninstall sassc
gem install sassc -- --disable-march-tune-native

Android USB Thethering

Download driver (right click open with) to enable usb tethering from android phone (wireless thethering will consume batery). I needed to restart mac to find my phone in network preferences.


Mac user defaults are preferences for user system configurations

defaults read com.mydomain.myapp
defaults read com.mydomain.myapp "MyKey"
defaults write com.mydomain.myapp "MyKey" myvalue
defaults delete com.mydomain.myapp


You can see logs using console application. You can attach iPhone and see logs for it. Filter in Search, follow last logs with Now button.

Closed lid

To keep working after lid is closed you can use app and disable Idle Sleep and Disable Lid Sleep

Open new VLC in separate window using

/Applications/ &


Re-install node

brew uninstall --ignore-dependencies node icu4c
brew install node
brew link --overwrite node

Reinstall node-gyp

rm package-lock.json && rm -rf node_modules && rm -rf ~/.node-gyp
yarn upgrade

Reinstall postgres and postgis

brew update; brew reinstall postgresql; brew reinstall postgis

To start postgres

brew services restart postgresql
ps auxwww | grep postgres

Create postgres user

createuser -s postgres

see logs with

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# upgrade datatabases
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8