레이블이 Mac인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Mac인 게시물을 표시합니다. 모든 게시물 표시

mac paste and match style

지금까지 맥에서 서식없이 붙여넣기(붙여넣고 스타일 일치시키기)는 cmd+shift+v 로 알고 있었는데 찾아보니 요렇다.
cmd+shift+option+v

붙여넣고 스타일 일치시키기 단축키가 chrome 과 safari 가 다르다.


google docs 에 정리된 jira url 을 (atlassian)wiki 에 복붙하면 jira 아이콘(링크)가 안되 길래 브라우저 주소표시줄에서 복사하고 다시 붙여넣고 있었다.

크롬에서는 cmd+shift+v 로 하면 서식없이 붙여넣기가 된다.
하지만 wiki 에서는 cmd+shift+option+v 를 사용해야 서식없이 붙이기가 되는것 같다.

ipad is not charging

ipad가 더러워져 흐르는 물에 잠깐 씻은 후 잘 말렸다.
그런데 usb-c 충전이 되지 않는다.
usb-c 케이블을 연결해도 충전표시, 메시지등 아무런 변화가 없다.

OS: 17.1.2
모델명: ipad pro 11(4세대)
해결 시도:
1. 강제 종료(전원+볼륨 버튼) 후 시작 -> 안됨
2. 설정 > ipad 재설정 > 재설정 후 시작 -> 어쩌다 됨, usb-c 를 분리했다 다시 연결하면안됨
3. (mac 에 ipad 백업하고) 설정 > 모든 콘텐츠 및 설정 지우기 > 재설정 후 시작 -> 충전 성공

결국 ipad 전제 리셋(3번방법)으로 하니 정상 충전된다.

replace intel app to apple app

mac intel -> M1(apple silicon)으로 마이그레이션 후
intel kind의 프로세서들은 rosetta2 에뮬레이터가 변환해서 apple silicon 에서도 동작한다.
하지만 변환과정으로 비효율적이다.
activity Monitor.app > kind 로 intel 프로세스를 확인할 수 있다.

아직 apple silicon(arm64) 바이너리가 많이 없지만 있다면 대체해보자.

# file 명령으로 바이너리가 어떤 환경에서 실행 되는지 알 수 있다.
file /bin/sh

# bin/zsh 는 arm64, x86_64 둘다 지원하는 universal binary 다.
file /bin/zsh

# intel 용으로 zsh 를 실행하기
arch -x86_64 /bin/zsh

# arm64 용으로 zsh 를 실행하기
arch -arm64 /bin/zsh

# 그런데 /usr/local/bin/zsh 는 x86_64 바이너리다.
file /usr/local/bin/zsh

# 아래 사이트에서 brew 설치 스크립트를 실행하면
# apple silicon 용(/opt/Homebrew/bin 에 설치) homebrew 로 설치 된다.
# 설후 설정을 보면 HOMEBREW_PREFIX: /opt/Homebrew 로 되어 있다.
brew config

# apple silicon 용 brew 등의 바이너리를 우선 실행할 수 있도록 한다.
export PATH=/opt/Homebrew/bin:$PATH

# 이제 쉘을 재시작하고 zsh 설치해 보자.
# bash 도 arm64 으로 설치하자.
brew install zsh bash

# 새로 설치된 zsh 는 arm64 버전이다.
which zsh
/opt/Homebrew/bin/zsh
file /opt/Homebrew/bin/zsh
/opt/Homebrew/bin/zsh: Mach-O 64-bit executable arm64

# 이제 brew 로 arm64 버전의 프로그램을 설치 할 수 있다.
brew install vim fzf git lsd wegt dog 등등

# 참고로 x86_64 용(/usr/local/bin 에 설치) brew 를 사용하려면
# x86_64 용(/usr/local/bin 에 설치) homebrew 설치하고
arch --x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/
install/HEAD/install.sh)"

# 다음과 같이 사용한다.
arch --x86_64 /usr/local/Homebrew/bin/brew install {패키지이름}

#####

arm64 zellij (/opt/Homebrew/bin/zellij) 0.39.1 을 사용하면 status-bar 등의 코드에서 에러가 발생한다.
SSE2 명령셋등 intel cpu 종속적인 코드가 있어 보인다.

# 당분간은 x86_64 zellij 사용하기 위해 arm64 로 설치된 zellij 는 제거한다.
brew uninstall zellij

# 몇주 후 0.39.2 버전이 나왔고 설치하니 해결되었다.
arch -arm64 brew install zellij

# 버전확인
/opt/homebrew/bin/zellij --version
zellij 0.39.2

# arm64 바이너리 확인
file /opt/homebrew/bin/zellij
/opt/homebrew/bin/zellij: Mach-O 64-bit executable arm64

#####

# 마이그레이션 후 파이썬 설치시
brew install python

# 또는 uname -m 이 x86_64 라면
arch -arm64 brew install python

# 다음과 같은 에러가 발생했다.
Error: An exception occurred within a child process:
  FormulaUnavailableError: No available formula with the name "/opt/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/python".

# 확인해보니 다음 경로 자체가 없었다.
/opt/Homebrew/Library/Taps/homebrew/homebrew-core

# homebrew/core 를 다시 구성후 설치하면 된다.
# 구성에 시간이 좀 걸린다.
brew tap homebrew/core

# 만약 /opt/Homebrew/Library/Taps/homebrew/homebrew-core 경로가 있는 상태에서도 안되면 삭제후 시도해보자.
rm -rf /opt/Homebrew/Library/Taps/homebrew/homebrew-core

#####

# 마이그레이션 후 
# pyenv 로 python 설치하면 다음과 같은 이유로 실패 한다.
pyenv install -v 3.12
ld: warning: duplicate -rpath '/Users/ysoftman/.pyenv/versions/3.12.0/lib' ignored
ld: warning: duplicate -rpath '/opt/homebrew/lib' ignored
ld: warning: search path '/Users/ysoftman/.pyenv/versions/3.12.0/lib' not found
ld: warning: search path '/Users/ysoftman/.pyenv/versions/3.12.0/lib' not found
ld: Undefined symbols:
ld: Undefined symbols:
  _libintl_bindtextdomain, referenced from:
      __locale_bindtextdomain in _localemodule.o
      __locale_bindtextdomain in _localemodule.o
  _libintl_dcgettext, referenced from:
      __locale_dcgettext in _localemodule.o
  _libintl_dgettext, referenced from:
      __locale_dgettext in _localemodule.o
  _libintl_gettext, referenced from:
      __locale_gettext in _localemodule.o
  _libintl_setlocale, referenced from:
      __locale_setlocale in _localemodule.o
      __locale_setlocale in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
      __locale_localeconv in _localemodule.o
  _libintl_textdomain, referenced from:
      __locale_textdomain in _localemodule.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Programs/_freeze_module] Error 1
make: *** Waiting for unfinished jobs....

# libintl.a 라이브러리에 있는 심볼들이 보인다.
# /opt/homebrew/lib/libintl.a 를 참조하지 않는게 문제 같다.
nm /opt/homebrew/lib/libintl.a | rg  "_libintl_(bindtextdomain|dcgettext|dgettext|gettext|setlocale)$"

# 구글링으로 여러 방법들을 시도...
# gettext library 를 찾지 못한다고 해서 다시 설치했지만 안된다.
brew reinstall gettext

# arm64 library 을 찾도록 LDFLAG 를 설정해도 안된다.
export LDFLAGS="-L/opt/homebrew/lib"
export CPPFLAGS="-I/opt/homebrew/include"

# 기존 x86_64 라이브러를 우선 참조하게 되는것 같아 해당 path 를 강제 삭제해도 안된다.
rm -rf /usr/local/Cellar/{gettext,readline}

# arm64 용으로 make gcc 등 컴파일러 최신으로 설치해도 안된다.
arch -arm64 brew install cmake make gcc

# 이번에는 실제 파이썬 소스를 다운받아 다음과 같이 빌드하면 잘된다.
# 아래처럼 configure 로 Makefile 이 생성하면 CC=gcc CXX=g++ 로 설정되어 있다.
git clone https://github.com/python/cpython
cd cpython; ./configure && make -j10

# pyenv 빌드시 clang (Apple clang version 15.0.0) 대신 
# 컴파일러를 gcc(없다면 설치 brew install gcc)로 변경하니 된다.
CC=/opt/homebrew/bin/gcc-13 pyenv install -v 3.12

# 몇달 후 zellij, /opt/homebrew 패키지들을 arm64 로 다시 설치등의 변화가 있었는데,
# 별도 CC 설정없이 clang (Apple clang version 15.0.0) 로도 됐다.
pyenv install -v 3.12

mac input source icon

# mac sonoma 로 업그레이드 하니 terminal, spotlight 등 입력커서가 포커스된 상태에서
# 언어 전환을 하면 다음과 같이 변경된 언어로 표시하는 아이콘이 나타났다 사라진다.
# 매번 한영 전환을 하면 화면 중앙에 변환 인디케이터로 표시된다.
# 참고로 입력 언어 변환은 ctrl+space 대신 alt+space 로 사용하고 있는데, alt+space 후 alt 를 잡고 있어는 한/영이 둘다 표시된다.
# 이렇게 현재 작업중인 커서에 바로 한영이 표시돼 좋은것 같다.

# 그런데 이게 불편한 사람들도 꽤 있어 보인다.
# 커서에서 한영 아이콘을 비활성화 하려면
# 다음 명령줄을 실행하고 재시작한다.
sudo defaults delete /Library/Preferences/FeatureFlags/Domain/UIKit.plist redesigned_text_cursor

# 그리고 아래 명령줄로 바로 비활성할 수 있다.
defaults write kCFPreferencesAnyApplication TSMLanguageIndicatorEnabled 0

delete leftover data on mac

# 맥용량이 부족할 땐 임시,캐시 파일들을 삭제해보자.

# diskonaut 로 보니 이미 삭제된 vscode 관련 데이터가 크게 남아 있었다.
# 앱 캐시와 앱에서 사용하는 데이터 위치다.
/Users/ysoftman/Library/Caches
/Users/ysoftman/Library/Application Support

# 각각 10G 정도의 데이터가 남아 있어서 다음과 같이 삭제했다.
rm -rf /Users/ysoftman/Library/Caches/Code
rm -rf "/Users/ysoftman/Library/Application Support/vscode-cpptools"

# go mod pkgs 캐시 크기가 꽤된다. 
go clean -modcache

# vagrant box 이미지
rm -rf ~/.vagrant.d/boxes/*

# app cache 확인
cd ~/Library/Containers
fd -t d Caches | dust -d1

# app cache 삭제
fd -t d Caches --exec rm -rf {} \;

mac photos export to external disk

# mac photos.app 에서 NTFS 의 외장 하드로 사진을 export(unmodified originals)을 하려는데 write 가 되지 않는다.
# 찾아보니 mac 에서는 NTFS 는 기본적으로 read 만 할 수 있다고 한다.
# /etc/fstab 파일을 다음과 같이 설정하면 write 된다고 하는데 내 경우는 동작하지 않았다.
LABEL=외장하드이름 none ntfs rw,auto,nobrowse

# write 할 수 있는 마운트 프로그램중 무료인 mounty 를 설치하면 된다.
# install
brew install gromgit/fuse/mounty

# mounty app 을 실행하고 remount 하면 NTFS 외장하드에 write 할 수 있다.
# 단점은 속도가 느려서 photos 에서 export 하니 하루종일 걸렸다.
# 참고로 mounty 로 리마운트하면 /Volumes 가 아닌 ~/.mounty/외장하드이름으로 마운트가 된다.

# NTFS 외장 하드의 한곳에 export 된 사진 파일들을 날짜별 디렉토리에 옮기려고 하는데
# 10,000 장이 넘는 파일이 한곳에 있다보니 파일 리스트 파악도 잘 안된다.
# finder 에서 리스트 파악 후 drag&drop 동작도 느려서 이동이 안된다.
# 이경우 fd 커맨드로 다음과 같이 오래된 날짜부터 파악해서 이동하는 명령을 사용하는것이 좋다.
# mkdir -p ../{2021,2022,2023}
fd --changed-before '2021-12-31 23:59:59' | mv -v "../2021"
fd --changed-before '2022-12-31 23:59:59' | mv -v "../2022"
fd --changed-before '2023-12-31 23:59:59' | mv -v "../2023"

brew warning

# brew 설치/삭제 시 다음과 같이 openjdk 에러 발생한다.
Warning: Calling the `appcast` stanza is deprecated! Use the `livecheck` stanza instead.
Please report this issue to the adoptopenjdk/openjdk tap (not Homebrew/brew or Homebrew/homebrew-core),
or even better, submit a PR to fix it:
  /usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk/Casks/adoptopenjdk11.rb:9

# openjdk 저장소를 강제로 untap 후 openjdk 를 삭제해야 한다. 
brew untap --force adoptopenjdk/openjdk
brew uninstall adoptopenjdk11 adoptopenjdk12

# brew doctor 로 발견된 warning 해결하기
brew doctor

#####

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 14.2.

# 해결방법
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

#####

Warning: Some installed kegs have no formulae!
This means they were either deleted or installed manually.
You should find replacements for the following formulae:
  python@2
  ccze
  erlang@19
  spdylay
  boost-python

# 해결방법
brew uninstall --ignore-dependencies python@2 ccze erlang@19 spdylay boost-python

#####

Warning: You have the following deprecated, cask taps tapped:
  caskroom/versions
Untap them with `brew untap`.

# 해결방법
brew untap caskroom/versions

#####

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  cronolog
  delta
  dosbox
  gcal
  glide
  ilmbase
  lua@5.1
  octant
  sdl_net
  sdl_sound
  sshfs
  xml2

# 해결방법
brew uninstall --ignore-dependencies cronolog delta dosbox gcal glide ilmbase lua@5.1 octant sdl_net sdl_sound sshfs xml2

#####

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libDSToolkitV30-v3.4.2.20.dylib
  /usr/local/lib/libevent-1.4.2.1.3.dylib
  /usr/local/lib/libevent_core-1.4.2.1.3.dylib
  /usr/local/lib/libevent_extra-1.4.2.1.3.dylib
  /usr/local/lib/libldap.dylib

# 해결방법
rm -rf  /usr/local/lib/libDSToolkitV30-v3.4.2.20.dylib
rm -rf  /usr/local/lib/libevent-1.4.2.1.3.dylib
rm -rf  /usr/local/lib/libevent_core-1.4.2.1.3.dylib
rm -rf  /usr/local/lib/libevent_extra-1.4.2.1.3.dylib
rm -rf  /usr/local/lib/libldap.dylib

#####

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/evdns.h
  /usr/local/include/event-config.h
  /usr/local/include/event.h
  /usr/local/include/evhttp.h
  /usr/local/include/evrpc.h
  /usr/local/include/evutil.h
  /usr/local/include/memcached/protocol_binary.h
  /usr/local/include/python3.7m/greenlet/greenlet.h

# 해결방법
rm -rf /usr/local/include/evdns.h
rm -rf /usr/local/include/event-config.h
rm -rf /usr/local/include/event.h
rm -rf /usr/local/include/evhttp.h
rm -rf /usr/local/include/evrpc.h
rm -rf /usr/local/include/evutil.h
rm -rf /usr/local/include/memcached/protocol_binary.h
rm -rf /usr/local/include/python3.7m/greenlet/greenlet.h

#####

Warning: Unbrewed '.la' files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected '.la' files:
  /usr/local/lib/libevent.la
  /usr/local/lib/libevent_core.la
  /usr/local/lib/libevent_extra.la

# 해결방법
rm -rf  /usr/local/lib/libevent.la
rm -rf  /usr/local/lib/libevent_core.la
rm -rf  /usr/local/lib/libevent_extra.la

#####

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libevent.a
  /usr/local/lib/libevent_core.a
  /usr/local/lib/libevent_extra.a

# 해결방법
rm -rf  /usr/local/lib/libevent.la
rm -rf  /usr/local/lib/libevent_core.la
rm -rf  /usr/local/lib/libevent_extra.la

#####

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python-certifi
  midnight-commander
  docker-credential-helper-ecr
  docker
  thefuck
  pygments
  docutils
  redis
  python-tabulate
  numpy
  macvim
  tcl-tk
  pyyaml
  python-typing-extensions
  libevent
  six
  black
  wireshark

# 해결방법
brew link --overwrite python-certifi midnight-commander docker-credential-helper-ecr docker thefuck pygments docutils redis python-tabulate numpy macvim tcl-tk pyyaml python-typing-extensions libevent six black wireshark

mac cpu temperature

# mac cpu/gpu 온도 파악하기
sudo powermetrics | grep -i temperature

mac ApplePressAndHoldEnabled

# mac vscode 사용시 영문,숫자키를 누르고 있으면 입력이 계속지 않고 1번만 된다.
# 이때는 앱에 ApplePressAndHoldEnabled 를 비활성화해 적용하면 된다.
# 다음 명령 실행후 vscode 종료(cmd+q) 후 다시 시작하면
# 영문,숫자키를 누르고 있으면 계속 입력된다.
defaults write -g com.microsoft.VSCode ApplePressAndHoldEnabled -bool false

kerberos keychain 등록

# 커버로스 mac keychain 등록하기, 암호변경되면 keychain 에서 변경
# Usage: add-generic-password [-a account] [-s service] [-w password] [options...] [-A|-T appPath] [keychain]
# -l  Specify label (if omitted, service name is used as default label)
# -c  Specify item creator (optional four-character code)

security add-generic-password -a "ysoftman" -l "lemon.com (ysoftman)" -s "lemon.com" -w 'password123' -c "aapl" -T "/usr/bin/kinit"

mac key repeat speed

# mac 에서 vim 이나 터미널에서 커서 이동이나, 삭제등이 느릴때
# 아래 스샷 처럼 keyboard > key repeat:fast, delay until repeat: short 으로 설정하자.

reset mac login password

내가 암호를 변경한건지 계속 사용하던 로그인 암호가 계속 실패한다.
로그인 암호가 동작하지 않을때는 맥북 패스워드를 리셋하자.

맥북 재시작 후 Command(⌘)-R 을 애플 로고 나올때까지 계속 누루고 있으면 복구 화면이 나온다.

이때 Utilities > Terminal > resetpassword 명령을 실행한다.(복구모드 터미널에서만 작동한다.)


mac os 업데이트

# macOS 를 Monterey(12.1) 로 업데이트 했다.

# brew 설치 커맨드 실행하면 xcode 가 오래됐으니 신규버전을 설치하라고 한다.
Error: Your Xcode (12.3) is too outdated.
Please update to Xcode 13.1 (or delete it).
Xcode can be updated from the App Store.

# 하지만 app sotre 에서 xcode 를 update 하면 1시간이 넘도록 진행하다 실패한다.
# xcode 는 아래 apple 홈페이지에서 다운 받아 설치하는 것이 더 빠르다.
# xcode_13.2.1.xip 파일을 다운 후 실행하면 xcode.app 가 풀리고 Applications 로 이동(설치)하면 된다.

# 그리고 CommLineTools 도 삭제하고 다시 설치해야 한다.
# 위 URL 에서 Command Line Tools for Xcode 13.2 다운받아 설치하거나
# xcode-select 로 설치한다.
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
# 버전 확인
pkgutil --pkg-info com.apple.pkg.CLTools_Executables

brew unkown command cask

맥 GUI 앱을 설치 할때 사용하는 cask 옵션이 언제부터인가 동작하지 않는다.
brew cask install docker
Error: Unknown command: cask

brew 2.6.0 부터 cask 가 deprecated 되었고, 이제는 --cask 로만 사용할 수 있다.

다음과 같이 사용하자.
brew install --cask docker

mac add period with double-space

맥에서 타이핑시 가끔 마침표가 찍히는 경우가 있다.
다음과 같이 스페이스바를 연속으로 두번 입력하면 첫번째 스페이스바 한개가 . 로 변한다.
a. b. c. zzz

아래 사진 처럼 keyboard 설정 -> text -> 'add period with double-space' 비활성화해야 한다.

자동 오타 교정(correct spelling automatically)
자동 대문자 변환(capitalize words automatically)
터치바 제안 표시(touch bar typing suggestions)
이참에 모두 사용하지 않도록 변경~

mac cmd+tab 표시 모니터 변경하기

맥북 모니터 + 외부 모니터 사용하는 경우
cmd+tab(app switcher)으로 앱전환 하는 창이 맥북 모니터에만 보여 불편했는데,
알고 보니 dock 이 있는 모니터를 기준으로 표시된다.

# dock 모니터 이동
dock숨김(option+cmd+d 토글) -> 외부 모니터에서 마우스 아래로 내려 dock 표시 확인

이제 외부 모니터에서 cmd+tab 창을 볼 수 있다.

2021년 맥북 교체

2021년 맥북 교체(2021년인데 2019년 모델 받은게 좀 아쉬움)

[macbook]
MacBook Pro (16-inch, 2019)
2.4 GHz 8-Core Intel Core i9
sysctl -a | grep cpu.brand_string
machdep.cpu.brand_string: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
32 GB 2667 MHz DDR4
500 GB NVME
AMD Radeon Pro 5300M 4 GB
Intel UHD Graphics 630 1536 MB

기존 맥북 보다 스펙이 좋아진것도 있지만 개인적으로는 키보드가 버터플라이(butterfly)방식 대신 예전 가위(sissor)방식으로 돌아가서 좋다.
납작한 버터플라이 방식의 키보드는 고장도 잘나고 키감이 너무 안좋았다.



그동안 맥북 교체시마다 개인 환경 구성 스크립트(설치 및 설정 자동 구성)사용했는데,
이번에는 맥북 마이그레이션 지원(migration assistant)을 사용했다.
와이파이를 통해 마이그레이션 완료까지 대략 1시간 정도 걸렸다.



개인 환경 구성 스크립트에 비해
장점 : 기타 프로젝트 폴더나 문서폴더등 모든것을 한번에 마이그레이션 할 수 있어 편하다.
단점 : 10시간,5시간,1시간,10분등 남은 시간 표시는 왔다 갔다 해 믿을게 못된다. 시간이 더 걸린다.

참고 기존 맥북 초기화
전원켜고 바로 cmd+r 을 길게 누르고 디스크유틸리 실행, 여기서 볼륨삭제 후 종료
전원켜고 바로 cmd+r 을 길게 누르고 macOS다시설치 실행

mac builtin command manual page

# mac 환경에서 cd, alias, if 등의 builtin command 의
# manual-page(man page) 는 표시되지 않는다.
# 다음과 같이 cd 명령 설명을 보려고 하면
builtin 에 대략적인 설명 문서만 보인다.
man cd

# bash 를 사용한다면 help 로 설명서를 볼 수 있다.
help cd

# zsh 에는 help 를 사용할 수 없고, run-help 를 사용해야 하는데
# run-help=man 으로 alias 되어 있다.
# run-help alias 를 풀어주고(alias 안되어 있을 수도 있어 stderr null 처리)
unalias run-help 2> /dev/null

# zsh 의 autoloading function 으로 run-help 를 다시 로딩한다.
autoload run-help

# 이제 run-help 로 builtin command 설명서를 볼 수 있다.
run-help cd


#####


# man page 나 --help 로 보이는 문서는 자세하지만 길고,
# 예시도 없어 차근차근 읽어 이해하는데 시간이 걸리는데 
# tldr(too long dont' read)을 사용하면 실제 사용 예시등으로 빨리 파악할 수 있다.

# 설치
npm install -g tldr

# mac 에선 brew 로도 설치 할 수 있다.
brew install tldr

# ls 사용방법 보기
tldr ls

mac pfctl 로 ip 블럭

# 특정 ip 를 블럭해 disconnection test 를 하려고 한다.
# mac 같은 BSD 계열에서는 iptables 대신
# pfctl (packet filter control)을 사용할 수 있다.

# pfctl 활성
sudo pfctl -e

# pfctl 비활성
sudo pfctl -d

# vi /etc/pf.conf 에 직접 블럭할 ip 를 명시한다.
block drop from any to 10.10.10.2
block drop from any to 10.10.10.3
block drop from any to 10.10.10.4

# 또는 ip 그룹을 테이블로 만들고 다음과 같이 지정할 수도 있다.
table <ysoftmantable> persist { 10.10.10.2, 10.10.10.3, 10.10.10.4}
block drop from any to { <ysoftmantable> }

# pf.conf 로딩
sudo pfctl -f /etc/pf.conf

# 이제 위에 명시된 ip 로 outbound 되는 패킷은 모두 블럭된다.

# ysoftmantable 테이블 상태보기
sudo pfctl -t ysoftmantable -vT show

# ysoftmantable 테이블에 ip 추가
sudo pfctl -t ysoftmantable -T add 10.10.10.10
sudo pfctl -t ysoftmantable -T add 10.10.10.11

# ysoftmantable 테이블에서 ip 제거
sudo pfctl -t ysoftmantable -T delete 10.10.10.11

# 생성한 테이블 모두 지우기(T대문자)
sudo pfctl -F Tables

# nat,info,queue,table ... 등 전체지우기
sudo pfctl -F all

# 참고 
man pfctl
man pf.conf

kerberos 패스워드 입력 문제

# mac + iterm2 + zsh(prezto) 환경에서
# 터미널을 오래동안 열어두고 사용하다 보면 어느순간 부터
# kerberos 패스워드 입력이 안되는 경우가 발생한다.
ysoftman@ysoftmanMac ~/workspace/❯ kinit ysoftman
ysoftman@ysoftman-company.com's password:
kinit: failed to read password
ysoftman@ysoftmanMac ~/workspace/❯ mypassword
zsh: command not found: mypassword

# stdin 입력을 테스트 해보면 이상은 없어 보인다.
ysoftman@ysoftmanMac ~/workspace/❯ read a
ysoftman input test
ysoftman@ysoftmanMac ~/workspace/❯ echo $a
ysoftman input test

# iterm 은 닫지 않고 bash 또는 zsh 쉘을 시작해도 같은 문제가 발생하고
# iterm 로 새 터미널을 시작하면 패스워드가 입력된다.
# mac 기본 kint
which kinit
/usr/bin/kinit

# 버전을 보면 오래 된것 같아
kinit --version
kinit (Heimdal 1.5.1apple1)
Copyright 1995-2011 Kungliga Tekniska Högskolan
Send bug-reports to heimdal-bugs@h5l.org

# 새 버전(1.18.2)을 설치 해봤다.
brew install krb5

# 새 버전의 kinit 을 사용하면 패스워드 입력이 잘 된다.
/usr/local/opt/krb5/bin/kinit

# 원래 맥에서 기본 제공하는 /usr/bin/ 의 curl,kinit 같은 프로그램은
# brew link --force 로도 /usr/local/bin/ 에 링크 생성을 못해
# PATH 환경변수에 /usr/local/opt/ 를 추가해야 한다
# export PATH=/usr/local/opt/krb5/bin:$PATH
# 하지만 다음과 같이 /usr/local/opt/krb5/bin/kinit 가 우선하는 상황에서
which -a kinit
/usr/local/opt/krb5/bin/kinit
/usr/bin/kinit

# /usr/local/opt/krb5/bin/kinit 를 사용하면 ssh 접속시 암호를 물어보는 등의 문제가 발생했다.
# 이런 문제로 /usr/local/opt/krb5/bin/kdestroy 하고 원래의 /usr/bin/kinit(klist,kdestroy) 를 사용해야 했다.