新買Mac可能會不熟悉快捷鍵操作,故記錄一些常用的指令 # 基本功能篇 * 全螢幕截圖:Command+Shift+3 * 指定區域截圖:Command+Shift+4 * Touch Bar截圖:Command+Shift+6 * 有陰影效果的視窗截圖:Command+Shift+4,放開後按空白鍵,將相機圖示移動想截取的視窗後按左鍵 * 視窗截圖:Command+Shift+4,4放開後按空白鍵,按住Option鍵後將相機圖示移動想截取的視窗後按左鍵 * 關閉程式:Command+Q * 切換程式視窗:Command+Tab * 同一程式切換視窗: Command + ~ * 刪除檔案: Command + Backspace * 剪下檔案與貼上:Command+C **Command+Option+V** * 強制結束程式:Control+Option+esc * 切到桌面:fn + F11 * 看見隱藏檔案:Command + Shift + . * 微調音量:Shift + Option + 音量鍵 * 讓視窗滿版面(非全螢幕):Option + 左上角的綠色全螢幕鍵 * 讓瀏覽器滿版:fn + F * 快速捲動瀏覽頁面:fn + 方向的上下鍵 ## 通用編輯篇 * 複製:Command+C * Delete(向後刪除): Fn + Backspace * 貼上:Command+V * 去除格式後貼上:Shift+Option+Command+V * 剪下:Command+X * 回復上一步:Command+Z * 全選:Command+A * 超連結:Command+K * 全大寫輸入:按住大寫鍵直到燈亮 * 粗體字: Command+B * 跳字:Option + 左右 * 跳到最左右邊:Command(fn也可) + 左右 * 反引號`: 波浪線 ~ 直接按 ## 瀏覽器使用 * 瀏覽器重新整理:Command+R * 瀏覽器開新分頁:Command+T * 瀏覽器切換至指定分頁:Command+1、Command+2、Command+3(以此類推) * 關閉瀏覽器一個視窗:Command + W * 將關閉視窗還原:Shift + command + T * 跳到最上、下面:Command+箭頭上下鍵 * 上/下一頁:Command + 左/右方向鍵 ## PDF * 新增文字:Control+Command+T * 合併pdf:preview -> view -> 開啟thumbnails(縮覽圖)模式 -> edit -> insert 就可把數個pdf合併; * 合併pdf(2):或是開啟多個視窗(都是thumbnails模式),把想要的頁數拖曳到被合併的pdf中;可插入在任意位置 * 從PDF匯出特定頁面:開啟thumbnails(縮覽圖)模式,選中你所需要匯出的頁面,將選中的PDF拖移或複製(Command + C, Command + v)到想要的位址即可 * 圖片檔轉pdf:在preview即可export成pdf檔 * 快速預覽圖片:框選所有圖片並且按下「空白鍵」 * 回復先前版本:file -> revert to -> browse all versions ## 注音輸入法下的快捷鍵 * ,=Shift + , * 。=Shift + . * :=Shift + ; * .=Option + . * 、=、 * ;=Option + ; * 《=Shift + Option + , * 》=Shift + Option + . * Control+Command⌘+空白鍵: Emoji視窗 ## 英文輸入法快捷鍵,數學符號 * ≥ = Option + . * ≤ = Option + , * √ = Option + V * ¬ = Option + L * ∑ = Option + W * π = Option + P * ƒ = Option + F * ∆ = Option + J ## 改預設編輯文件器 file右鍵 -> get info -> open with ## 生出 .txt textedit -> format -> make plain text https://www.wikihow.com/Create-a-TXT-File-on-Mac # Mac Programming ## 終端機使用 ### 終止程式 按control + c可以停止程式執行 ### shell script - 執行腳本 `$ bash file_name.sh` ### 創立、編輯文件 `$ vim file_name` 按`i`代表insert, 可以開始寫。按`esc`跳脫某個狀態。打`:wq`寫入後quit。 - 創建腳本、編輯 `$ vim file_name.sh` ## 自動排程工作 使用automator, 點application, utility, 然後選 run shell script, 使用zsh即可,然後在底下的內容打`python3 file_name.py` 就像是自己在終端機打指令一樣。 ### 開機時執行工作 按system settings, 搜尋log in, 在log in item的地方加入我們上述的automator產生的app,開機的時候就會執行裡面的指令了。 ## Python 安裝的時候如果使得在終端機無法使用`python`,因為發生command not found的問題時,可以利用zsh shell中`alias`的概念,設定python=python3,VScode也能正常靠按按鍵運行python了。 Open your terminal and run the command: 1. touch .zshrc 2. open ~/.zshrc 3. 在.zshrc中加入`alias python="python3"` ## C/C++ ### MacOs 使用VScode與C++17 https://cse232-msu.github.io/CSE232/vscode_setup/macos.html 如果Mac上面有xcode就不用下載, After installation, I recommend running the `clang --version` command again to see if you get the above output. compile就用下面的command line `g++ a.cpp -o a -std=c++17 -Wall` `g++`相當於`clang++`,Mac上面沒有真正的`g++` ### MacOS VSCode配置c++17環境 (這個比較難用) 1. https://blog.csdn.net/fighting_Kitty/article/details/124774798 2. [visual studio](https://code.visualstudio.com/docs/cpp/config-clang-mac) 3. 不知道為什麼要再disable clang adaptor https://github.com/Microsoft/vscode-cpptools/issues/3005#issuecomment-455418331 - Run and Debug: 先去Terminal > Configure Default Build Task產生tasks.json,.vscode/tasks.json(.vscode跟cpp同位址但隱藏) 加這兩行` "-std=c++17", "-stdlib=libc++",` ,此資料夾底下的cpp檔都可以用,不用再改東西 或是直接把tasks.json變成複製下面全部 [自製方便連結](https://hackmd.io/aEu9x5seRQmum7EXo35RqA) ``` { "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "C/C++: clang++ build active file", "command": "/usr/bin/clang++", "args": [ "-std=c++17", "-stdlib=libc++", "-fcolor-diagnostics", "-fansi-escape-codes", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Task generated by Debugger." } ] } ``` - BUG expected ';' at end of declaration https://stackoverflow.com/questions/27924050/expected-at-end-of-declaration-vector-c - 要用vscode開啟有.vscode的資料夾,才不會有bug ## Python ### Python Package package 放在~/Library/Python Library被隱藏了 ``` a_list = os.listdir(path) # 要sort過 不然沒有照順序 a_list.sort() ``` ### Python 路徑 環境變數 [添加環境變數](https://aronhack.com/zh/python%E5%B8%B8%E8%A6%8B%E5%95%8F%E9%A1%8C-%E5%A6%82%E4%BD%95%E6%9F%A5%E7%9C%8B%E6%88%96%E4%BF%AE%E6%94%B9mac%E4%B8%AD%E7%9A%84path%E7%92%B0%E5%A2%83%E8%AE%8A%E6%95%B8/) `sudo nano /etc/paths` 在裡面添加terminal當初警告你要加入的路徑 ## VSCode ### 常用指令 * Run Without Debugging: fn + Control + F5 * 中斷正在跑的程式:Control + Z * VScode Terminal開啟虛擬環境: Control + Shift + ~ * 快速開啟github專案(去vscode):去github desktop按 Command + Shift + A * 搜尋:Command + F * 開啟Command Palette:Shift + Command + P * VScode keyboard shortcuts https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf * vscode replace: Option + Command + F ### VScode Git/Github 操作 https://ithelp.ithome.com.tw/articles/10267030