macOS

Page content

some adaption for macOS

CUPS

enable cups

cupsctl WebInterface=yes
  • http://localhost:631/printers/

Shell

macOS is using zsh since while. If you wanna switch back to bash, here some Notes …"

Switch to Bash

chsh -s /bin/bash

Switch to Zsh

chsh -s /bin/zsh

install brew

the famous package manager for macOS

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

install keychain

if you work with ssh agent, you may wanna try keychain …

brew install keychain

build .bash_profile

this will overwrite your existing .bash_profile

cp ~/.bash_profile ~/.bash_profile.$(date "+%s")~

cat << 'EOF' > ~/.bash_profile
echo "hi .bash_profile"

export BASH_SILENCE_DEPRECATION_WARNING=1
eval "$(/opt/homebrew/bin/brew shellenv)"
[ -r ~/.bashrc ] && . ~/.bashrc

echo "bye .bash_profile"
EOF

chmod 700 ~/.bash_profile

build .bashrc

same here …

cp ~/.bashrc ~/.bashrc.$(date "+%s")~

cat << 'EOF' > ~/.bashrc
echo "hi .bashrc"

# Keychain Startup
eval $(keychain --eval id_ed25519)

alias ..="cd .."
alias ...="cd ..."
alias ll="ls -l"
alias lla="ls -la"

echo "bye .bashrc"
EOF

chmod 700 ~/.bashrc

profile

let’s create some profile folder

cat << 'EOF' >> ~/.bashrc

# include /etc/profile.d
if [ -d /etc/profile.d ]; then
  for f in `ls /etc/profile.d`; do . /etc/profile.d/$f; done
fi
EOF

test -d /etc/profile.d || sudo mkdir /etc/profile.d
sudo chmod 777 /etc/profile.d

add profile.git

add some aliases for git …

cat << 'EOF' > /etc/profile.d/profile.git
# Git Stuff, by Stöge, 2022-09-08

# https://git-scm.com/docs/gittutorial
# https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
# https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
# https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell

# Pull/Push
alias gil='git pull'
alias gis='git push'
alias gipupu='git push; git pull; git push; git pull'

# Status
alias gs="git status"
alias gss="git status -s"
alias gssb="git status -s -b"

# Config
alias gcl="git config --list --show-origin |sort"
alias git_config_list="git config --list --show-origin |sort"

# Remote
alias gr="git remote"
alias grv="git remote -v"
alias grso="git remote show origin"

# Log
alias gl='git log'
alias gls='git log --stat'
alias glp1='git log -p -1'
alias glp2='git log -p -2'
alias glp3='git log -p -3'
alias glpo='git log --pretty=oneline'
alias glpr='git log --pretty=reference'
alias glpf='git log --pretty=format:"%h - %an, %ar : %s"'

# All in One
alias gitac='git add . && git commit -m "update"'
alias gitacp='git add . && git commit -m "update" && git push'
alias gitacfp='git add . && git commit -m "$(curl -sk whatthecommit.com/index.txt)" && git push'
EOF

sudo chmod 755 /etc/profile.d/profile.git

UpdateDB

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

ColoredTerminals

mkdir ~/SolidColors
cp /System/Library/Desktop\ Pictures/Solid\ Colors/* ~/SolidColors/

Terminal -> Preferences -> Profiles -> Background -> Image -> ~/SolidColors

-> delete unwanted Colors from ~/SolidColors

i3

Script to grab your Public IP, Dualstack capable

cd /tmp
wget https://ip.inno.ch/download/i3.tar.gz
tar xfz i3.tar.gz i3
sudo mv i3/i3 /usr/local/bin/

Test Script

user@host $ i3
IPv4: 83.xxx.xxx.xxx
IPv6: 2a0b:xxxx:xxxx:xxxx::1

Put PublicIP to Variable

user@host $ myip=$(i3 -b -4)
user@host  $ echo $myip
83.xx.xx.xx

Bash Autocompletion

brew install bash-completion
echo -e "# Bash Autocompletion\n[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion\n" >> .bashrc
source ~/.bashrc

vnsta

brew install vnstat
  /opt/homebrew/opt/vnstat/bin/vnstatd --nodaemon --config /opt/homebrew/etc/vnstat.conf

Find App Listening on Port

sudo lsof -i -n -P | grep TCP

hidden command for ‘install-app-allow-anywhere’ on ventura

you wanna install apps via brew and run them on your mac ? -> this needs the “Allow applications downloaded from ‘Anywhere’” - button, which you can enable with the following hidden command:

sudo spctl --master-disable

Terminal & CLI

  • CTRL-A -> Beginning of the Line
  • CTRL-E -> End of the Line
  • CTRL-K -> Delete from Cursor until EOL

Terminal Settings, Keyboard, enable ‘Use Option as Meta key’

-> # and other Stuff will not work anymore :(

  • OPT-B -> one Word backward
  • OPT-F -> one Word forward

Networking Stuff

List Network Services

networksetup listallnetworkservices
stoege@macos ~ % networksetup listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
ThinkPad Lan
Thunderbolt Ethernet Slot 2
Thunderbolt Bridge
Wi-Fi
iPhone USB
vpn1
vpn2
vpn3

List Search Domains

networksetup -getsearchdomains Wi-Fi

Set Search Domains

networksetup -setsearchdomains vpn1 mydomain.net my2domain.net

Serial Console

Serial Console to APU

mac root# cu -l /dev/cu.usbserial-1430 -s 115200
Connected.

Any Comments ?

sha256: b267537f4260bf42b8e354cd6951bdee41b9b54b00c412bfa670da370cc588ac