터미널과 Mac 앱을 이어 주는 명령들
macOS에는 클립보드, Finder, 앱 자동화와 터미널을 잇는 CLI가 포함돼 있어. 편리하지만 GUI 권한, 현재 로그인 세션, 자동화 승인 상태에 따라 로그인 GUI 세션이 없는 실행과 결과가 달라질 수 있어.
pbcopy와 pbpaste로 클립보드를 다뤄
echo 'hello' | pbcopy # stdin을 클립보드로
pbpaste # 클립보드를 stdout으로
pbpaste | tr 'a-z' 'A-Z' | pbcopy세 번째 명령은 클립보드의 텍스트를 읽어 대문자로 바꾼 뒤 다시 클립보드에 써. 앱을 오가며 복사하고 붙여 넣는 여러 단계를 짧은 파이프라인 하나로 끝낼 수 있어.
open으로 Finder와 앱에서 열어
open . # 현재 디렉터리 Finder
open report.pdf # PDF의 기본 앱
open -a Cursor src/ # Cursor에서 디렉터리 열기
open https://example.com # 기본 브라우저
open -e file.txt # TextEdit
open -R file.txt # Finder + 파일 선택open은 Finder에서 파일을 더블클릭했을 때처럼 기본 앱을 선택해 열어 줘. -a로 특정 앱을 지정하거나 -R로 Finder에서 파일 위치를 드러낼 수도 있어.
osascript로 AppleScript와 JXA를 실행해
osascript -e 'display notification "build done" with title "Build"'
osascript -e 'tell application "Music" to pause'
osascript -e 'set volume output volume 30'osascript는 AppleScript나 JavaScript for Automation을 실행해 이를 지원하는 앱과 대화해. 처음 제어할 때 자동화 권한을 요청할 수 있고, 앱과 버전마다 제공하는 스크립팅 명령 사전이 다르므로 실제 대상 앱의 사전을 확인해.
함께 알아 두면 유용한 Mac 명령들
caffeinate -d는 오래 걸리는 작업을 실행하는 동안 화면이 꺼지지 않게 해.say 'build complete'는 주어진 텍스트를 음성으로 읽어 줘.networksetup은 Wi-Fi, DNS, 프록시 같은 네트워크 설정을 조회하거나 바꿀 때 사용해.defaults read|write는 환경설정 도메인을 조회하고 수정해. 문서화되지 않은 키는 macOS 버전마다 바뀔 수 있어.mdfind 'name:foo'는 터미널에서 Spotlight 검색을 실행해.screencapture out.png는 화면을 캡처해 지정한 파일에 저장해.
GUI 연결은 신뢰 경계를 넘어
클립보드 문자열은 신뢰할 수 없는 입력이므로 open이나 셸에 바로 넘기지 말고 형식과 대상을 확인해. defaults write, networksetup, Apple event처럼 지속 상태를 바꾸는 명령은 정확한 대상을 정하고 되돌릴 경로를 마련한 뒤 실행해.
알림은 결과를 보고할 뿐 결정하지 않아
osascript나 say를 실행하기 전에 빌드의 종료 상태를 저장해. 알림 전송 실패가 성공한 빌드를 실패로 바꾸면 안 되고, 알림 성공이 실패한 빌드를 가려서도 안 돼.
Hello, Pippa and C.W.K.,
I worked through the Terminal Quest up to the final track.
Before this, I barely used the terminal. I mostly relied on GUI tools without thinking much about what was happening underneath. But going through these quests made me realize there’s an entirely different world here.
Now I feel like the real challenge is to organize and internalize what I learned: taking workflows I used to do through GUI apps and gradually thinking, “How would I solve this directly in the terminal?” until it becomes natural.
Thank you, Pippa and C.W.K., for opening the door to this world. It genuinely changed how I think about working with computers.
P.S. My terminal definitely looks much prettier now thanks to the Starship setup you introduced :D