my-osx-setup

Master Hub for an initial macOS Setup - basic & essentials cli apps, dotfiles, shell commands

View the Project on GitHub hannic/my-osx-setup

Master Hub for an initial macOS Setup

GitHub watchers GitHub watchers Inline docs

to complete a new operating system setup - dotfiles, unix, commands, cli apps 2016 - © hannic

::: warning here be dragons :::

Table of contents


dotfiles

.bash_profile

.bash_prompt

.aliases

Package Manager - Homebrew

Main package manager is brew. Others are pip3, npm, tlmgr

.brew : package manager

$ brew upgrade
$ brew install <package>
$ brew ls <package>

.git : workflow reminder

# local repo
$ git pull
$ git branch
$ git checkout <feature-branch>
$ git commit -am "message"
$ git push 

# remote repo 
open pull request
git merge pull request will merge the changes into master-branch

# local-repo
$ git checkout <master-branch>
$ git pull will synce the code base 

installed brew packages:

faac		lame		libvpx		opus		texi2html
fdk-aac		libav		libxml2		pkg-config	unrar
ffmpeg		libidn2		movgrab		python		wget
freetype	libmagic	mysql		python3		x264
gdbm		libogg		nasm		python@2	xvid
gettext		libpng		nmap		qt		xz
git		libunistring	node		readline	yasm
groovy		libvo-aacenc	openssl		sphinx-doc	youtube-dl
icu4c		libvorbis	openssl@1.1	sqlite
imagemagick	ghostscript 	ko_pron		lux 

lux

(Video-Downloader, [siehe](https://github.com/iawia002/lux))

youtube-dl

$ youtube-dl --extract-audio --recode-video "mp4" --audio-quality 0 -x "https://www.youtube.com/watch?v=Bv0yd9BBIl0"
# best command for downloading youtube videos as audio tracks
$ youtube-dl -i --embed-thumbnail --extract-audio --recode-video "mp4" --audio-quality 0 -x -o '%(playlist)s/%(playlist_title)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLvWzOSZqGLxrGznjlSgBwc1HcCG8b0h8r

# best command to download videos from other sites, 
# see  supported sites: http://ytdl-org.github.io/youtube-dl/supportedsites.html  
$ youtube-dl -f mp4 https://www.srf.ch/play/tv/srf-news/video/street-parade-2019--tanzen-und-trinken-zum-motto-colors-of-unity?id=29533e8c-f546-41d9-8596-86202439c9a0

# convert to mp3
$ youtube-dl -f bestaudio "https://www.youtube.com/playlist?list=PLYRruMbyFRcBVdVN8v4FNkIKkXvL-bZn_" --exec "ffmpeg -i {} -codec:a libmp3lame -qscale:a 0 {}.mp3 "

Terminal (Apple)

.osx : default write com.apple.xxx

.osx 

Terminal (Unix)

Utility commands for start simple webserver, json server, network information (ip address)

# start simple web server on localhost:8000
$ python -m SimpleHTTPServer 8000
$ uptime

# Python 3 equivalent of “python -m SimpleHTTPServer”
$ python3 -m http.server
# or with bindings: 
$ python -m http.server 8000 --bind 127.0.0.1

# lan ip address 
$ ipconfig getifaddr en0
# global ip address
$ curl ipecho.net/plain; echo

$ whoami
$ whois google.com

# get IP address
$ curl ifconfig.me	

#disk usage
$ du -ch 
#disk free
$ du -h
#lists all files und folder with its size (level two) and sorts them
$ du -hd 2 . /Users/yobo/Google\ Drive/ | sort -n -r

$ ifconfig wlan0

# download all files from a website (e.g. index page)
wget -A pdf,jpg -m -p -E -k -K -np http://siik.org/azn/?C=N%3BO=D 

CLI

* wp-cli
* ffmpeg
* scdl 
	* scdl -l https://soundcloud.com/username/sets/sets_13
* youtube-dl   
* json-server
* nmap

Examples

$ for x in ls *.webp; do  ffmpeg -i $x $x.jpg; done

Helper

A collection of shell commands

Apps

Settings of my favorite applications I use on my Mac.

Inventory

Sublime

Precondition: bin directory and .bash_profile exists in home directory

$ ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

For reloading .bash_profile preferences without quitting current terminal settings

source ~/.bash_profile

Open Sublime Text 2 in Terminal

$ subl . 
$ subl <filename|foldername> 

Shortcuts

Sublime:

Shortcut Description
CMD + ALT + Left Mouse button Vertical Selection
CMD + CTRL + J format pretty json

Terminal:

Terminal Description
ctrl+z stop a process
ctrl+a begin of current line
ctrl+e end of current line

Unix

find out the shell you are using

$ echo $0

Cronjob $ crontab -l $ crontab -e

IntelliJ

https://gist.github.com/uarun/4699940


Troubleshooting

SSH & Github

SSH Key - Still asking for password and passphrase

$ ssh-add ~/.ssh/id_rsa
$ ssh-add -K ~/.ssh/id_rsa

Error: Offending RSA key in /var/lib/sss/pubconf/known_hosts:4 Solution: remove line no: 4. Save and Exit, and Retry.

Python

$ python -i <file_name.py>

Install Python on Linux without admin rights

pip3

install Python Index Packages

$ pip3 install <package> ** e.g. pandas **

ML python packages

Upgrade Python package

$ pip3 list --outdated 
$ pip3 install scdl --upgrade; $ pip3 install urllib3 -U

Jupyter Environment

$ pip install --upgrade ipython jupyter
$ ipython notebook

http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python3

Use virtualenv

$ virtualenv venv
$ source venv/bin/activate
$ pip install pafy

Raspberry Pi

wifi settings

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Side Projects

Website Description
moleskine-latex-templates moleskine-latex-templates
r-likert-results r-likert-results
bbb Lorem ipsuem

References

https://guides.github.com/features/mastering-markdown/ https://support.discordapp.com/hc/de/articles/210298617-Grundlagen-des-Markdown-Texts-Chatformatierung-fett-kursiv-unterstrichen-

To Do’s


It is based of the work of xxx (Found here: xxx).

Markdown

Ghostscript

Resize PDF size

gs \
 -sOutputFile=ocomposition_for_computer_musicians_176x250.pdf \
 -sDEVICE=pdfwrite \
 -sPAPERSIZE=isob5 \
 -dCompatibilityLevel=1.4 \
 -dNOPAUSE \
 -dBATCH \
 -dPDFFitPage \
  composition_for_computer_musicians.pdf

iOS

Time Machine

‘tmutil’ is macos command line tool for Time Machine Backups

$ tmutil listbackups
$ tmutil delete /Volumes/Time\ Machine-Backups/Backups.backupdb/<Users MacBook Pro>YYYY-MM-DD-HHMMSS/ 

Network

scan available wifis $ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

returns following information:

SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
Snnj-80697 a8:d3:f7:9d:55:85 -88 100 Y DE WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)

MagicMirror

Commands

// ssh from mac to raspberry pi
ssh pi@10.0.0.x 
// copy file from mac to raspberry pi
scp ...

cd ~/MagicMirror 
npm run start 

cd ~/MagicMirror && DISPLAY=:0 npm start

scp /to/some/file.txt pi@10.0.0.x:~/to/remote/folder

Config

url tbd: linktomyconfig.js

Modules

- MMM-Carousel
- MMM-bernwordclock
- MMM-AareGuru
- calendar 

References

yt-dl

See: https://gist.github.com/hannic/747b14d475eb2530cbcc88966890ba8a

ig-img

See: https://gist.github.com/hannic/37611b1cc258a26512f489e51a7c1a67