Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 143ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
i

icloud

Recently created Least recently created Recently updated Least recently updated

timmy / Mac iCloud 目錄自動切換腳本

Last active 5 hours ago automation bash directory icloud macos script

這段腳本切換到使用者的 iCloud Drive 目錄 (Mobile Documents/com~apple~CloudDocs),確認目錄存在後切換到該目錄,並輸出當前工作目錄位置。

0 0 0 1
1 #!/bin/bash
2
3 BASE_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs"
4
5 # 確認目錄是否存在
6 if [ -d "$BASE_DIR" ]; then
7 echo "切換到目標目錄: $BASE_DIR"
8 cd "$BASE_DIR" || { echo "無法進入目標目錄,退出腳本。"; exit 1; }
9 fi