rxliuli blog rxliuli blog -

Questions and Confusions for Mac Beginners

PrefaceSwitched to an M2 MacBook, as a long-term Windows user, I have encountered many problems and confusions up to now. Some have been solved, while others have not yet found a solution. Here, I record and share them.SystemHow to Add FontsPreviously, my daily font was Sarasa Gothic, which is not outstanding, but its main advantage is supporting Simplified and Traditional Chinese, Japanese, and English in a unified style.The basic steps are similar to Windows: download the ttc file, click to open it, and wait for the verification to pass. However, this process is very slow on a Mac, so slow that I thought there was a bug.How to Keep the Mac Awake with the Lid Closed When Connected to an External DisplayAlthough I found a bunch of answers, it turns out that all you need to do is connect to power and set the external monitor as the primary display.There is still a bug, sometimes I cannot wake it up using an external keyboard and mouse.How to Reverse Mouse Scrolling DirectionThis was one of the very first things I was not used to, but it can be adjusted by using a tool called SCROLL REVERSER to set it to reverse.Checking for Global Shortcut Key Conflicts on MacI haven’t found a truly viable solution, so I will continue to search for Mac’s shortcut key settings through Google and asking questions.How to Use Other Input MethodsSimply download the system’s input methods, then you can switch input methods using ctrl+space.Since it conflicts with the shortcut key for suggestions in vscode, I changed it to ctrl+shift+space.Using Function Keys on Mac Without Pressing FnEnable Use F1, F2, etc. keys as standard function keys in system preferences, ref: https://support.apple.com/102439I found that the shortcut key for refreshing the browser page, F5, does not work…How to Hide from Dock When Closing the Main Window of an AppThis depends on whether the app supports this behavior, for example, SSR supports minimizing to the top right corner after closing the window, but Proxifier does not support it and must occupy a place in the dock.How to List and Switch Between All WindowsMac’s command+tab can only switch applications, but not multiple windows within the same application.To switch between multiple windows of the same application, use the command+~ shortcut.To list all windows, you can use the ctrl+top shortcut, but it’s not possible to switch using a shortcut, moving the right hand from the mouse to the keyboard and back to the mouse is too counterintuitive, and the sizes being different is strange.Using alt-tab can restore behavior similar to Windows.Disabling Right-Click Menu in ChromeBy default, Chrome displays several integrated right-click menu items for Mac, which are not practical most of the time and need to be disabled.Well, it seems this issue is unsolvable, which is really unfortunate. ref: https://superuser.com/questions/1012292/Changing Cursor Movement Shortcuts to Windows Style in InputThe cursor movement shortcuts on Mac might be good, but there is obviously a significant difference from Windows.In Windows, the following keys are generally used to move the cursor:Home/End to jump to the beginning/end of the lineCtrl+Home/End to jump to the beginning/end of the textCtrl+Left/Right to jump to the beginning/end of the wordAll the above keys can be used in combination with Shift.This issue can be mitigated by configuring global keyboard mapping with Karabiner-Elements.How to Download DMG Files from Third PartiesNot addressed yetHow to Kill a Specific ProcessSometimes a background program freezes and needs to be restarted, but Activity Monitor seems unable to right-click to kill a process.Use the Linux commands ps + kill -9In Activity Monitor, first select the process you want to kill, then click the ⊗ in the navigation bar.Disabling Cmd+Shift+A Triggering “No manual entry for setting;type=a” on MacIn JetBrains’ IDEs, Cmd+Shift+A triggers “No manual entry for setting;type=a,” another example of Mac’s “helpful” shortcuts.This can be resolved by:Opening System Preferences => Keyboard => Shortcuts => ServicesDisabling Text => Search man Page Index in TerminalAutomatically Close Notifications in the Top Right CornerSometimes the system pops up notifications, such as software updates, but these notifications will stay visible in the top right corner indefinitely unless actively closed, which is very annoying. I would prefer them to automatically hide like in Windows and be viewable in the notification list if needed.Tools like Automator seem to only set shortcuts for closing notifications and cannot automatically close system notifications after a few seconds.Set Gmail Web Version as the Default System Mail ClientThe built-in mail client on Mac might be useful, but having gotten used to Gmail, I want to set Gmail as the default system mail client. This process is much more complicated than on Windows, refer to the tutorial: https://support.apple.com/102362How to Synchronize Files to a Phone via USB DifferentiallyThe actual need is to synchronize the OneDrive and the e-book reader’s directory. Surprisingly, when connecting an Android phone to a Mac, files cannot be transferred directly through Finder. It requires Google’s Android File Transfer program, which does not support differential sync.This helps understand why some people dislike Mac, saying it’s too closed, as its support for non-Apple products is quite poor.Disable the Mouse Move to Bottom Right Corner to Show NotesOpen System Preferences => Search “Hot Corners” => Hot CornersRemove the note trigger in the bottom right corner.FinderDeleting Icons from the Desktop in MacUse Command+Delete to delete the selected icon.Quick Switch Between WindowsUsing Ctrl+Left/Right can switch between adjacent windows, which is very useful for quickly accessing commonly used windows during development. (Restores the old behavior similar to multiple windows, abandoning the mobile-like practice of one app covering the screen)Display Hidden FilesCommand+Shift+. can temporarily toggle the display of hidden files.Use the following method for a permanent setting (seems not to work for file selectors triggered by browsers):123defaults write com.apple.finder AppleShowAllFiles -bool true # Show hidden filesdefaults write com.apple.finder AppleShowAllFiles -bool false # Hide hidden fileskillall Finder # Restart FinderHow to Paste a File PathSometimes, after copying a file path, you may want to quickly open it in Finder. You can use the Command+Shift+G shortcut, then paste the path.Open Terminal or VSCode in the Current DirectoryAfter selecting a directory, go to Finder => Services => New iTerm2 Window Here to open it.This is actually different from what was expected to open the current directory and is also relatively slow.Well, it’s actually also available in the right-click context menu’s submenu.Opening iTerm2 for the first time will have two terminals, which appears to be a bug.You can use szContext to customize the context menu.Changing the Default Program for Opening a FileIn Finder, right-click on a file of the type you wish to change, to bring up the context menu.In the menu, select the “Get Info” option.In the dialog that appears, expand the “Open With” option.Choose the program you want to set as the default for opening this type of file, and click on “Change All…” below.Selecting the Always Open With option when opening an application is confusing; it turns out it only applies to that specific file.A better tool for this is duti, which can get or set the default program for a specific file type. This is particularly useful for batch changing the default application from Xcode to Visual Studio Code for opening certain file types.123456789101112# https://github.com/moretension/dutibrew install duti# from https://github.com/vscode-icons/vscode-icons/blob/74220b6f8389ad5c5d9f68b2029d91460de2b374/src/iconsManifest/languages.ts#L319filetypes=(.as .ada .prw .affect .al .ansible .g4 .any .htaccess .cls .apib .apl .applescript .adoc .asp .asm .ats .ahk .au3 .avcs .azcli .azure-pipelines.yml .bal .bat .bats .bzl .bf .bicep .bib .biml .blade.php .blitzbasic .bolt .bsq .buf.yaml .c .cal .cabal .Caddyfile .casc .cddl .ceylon .cfc .cfm .clojure .clojurescript .yml .cmake .CMakeCache.txt .cbl .ql .coffee .cfml .confluence .ckbk .cpp .h .cr .cs .css .feature .cu .pyx .dal .dart .dhall .html .diff .d .dockerfile .dtx .env .dot .dox .drl .dust .dylan .earthfile .edge .eex .es .ex .elm .erb .erl .yaml .falcon .fql .f .ftl .fs .fthtml .gspec .gml .gcode .gen .git .glsl .glyphs .gp .go .api .gd .gr .gql .gv .groovy .haml .hbs .prg .hs .haxe .hcl .helm.tpl .hjson .hlsl .hosts .http .aff .hy .hypr .icl .imba .4gl .ini .ink .iss .io .janet .java .js .jsx .jekyll .jenkins .jinja .json .jsonc .jsonnet .json5 .jl .id .k .kv .ks .kt ..kusto .tex .lat .less .flex .ly .lisp .lhs .log .lol .lsl .lua .mk .md .marko .mat .ms .mdx .mediawiki .mel .mmd .meson.build .mjml .pq .ep .mongo .mson .ne .nim .nimble .nix .nsi .nunjucks .m .mm .ml .o3 .w .things .pas .pddl .plan .happenings .pl .pl6 .pgsql .php .pine .requirements.txt .txt .dbgasm .ddl .polymer .pony .pcss .ps1 .prisma .pde .pro .rules .properties .proto .pug .pp .purs .arr .py .pyowo .qvs .qml .qs .r .rkt .cshtml .raml .re .red .res .rst .rex .tag .rmd .robot .rb .rs .san .sas .sbt .scad .scala .sce .scss .sdl .shader .sh .slang .ice .slim .ss .sn .eskip .tpl .snort .sol .rq .sqf .sql .nut .stan .bazel .do .stencil .html.stencil .st.css .styled .styl .svelte .swagger .swift .swig .link .sv .tt .teal .tt3 .tera .tf .sty .textile .JSON-tmLanguage .YAML-tmLanguage .Tiltfile .toit .toml .ttcn3 .tuc .twig .ts .tsx .typoscript .u .vb .wsf .vm .v .vhdl .vim .volt .vue .wai .wasm .wy .wgsl .wt .wl .wurst .wxml .xmake.lua .xml .xquery .xsl .bison .yang .zig)for filetype in "${filetypes[@]}"do duti -s com.microsoft.VSCode $filetype all if [ $? -ne 0 ]; then echo "Failed to set default program for $filetype" fidoneHow to Rename FilesSelect the file and press Enter to rename it, or choose Rename from the right-click menu.How to Cut FilesWell, it must use Command+C and then move the file with Command+Option+V. This is Mac only, even other programs on Mac support Command+X.Third-party enhancement tool XtraFinder does not support M1.How to Create a New Finder Window with a ShortcutIn Finder, use Command+N to create a window, unlike Ctrl+E, which can be very conveniently done with one hand.How to Copy File Names in BulkWell, just select multiple files with Command+C and then paste in a text editor to get the filenames, no special tools needed. ref: https://discussions.apple.com/thread/1850895How to Close All Finder WindowsIn a Finder window, press Option+Command+W to close all windows of the current application.ApplicationsVideo PlayerOn Windows, PotPlayer is widely used for its power and simplicity. Since it’s apparently not supported on Mac, I switched to an open-source tool iina. The control bar is a bit odd, but it’s manageable with keyboard controls for progress.Music PlayerAlthough iina also supports music playback, I found an open-source music player museeks.Clipboard History ManagementUse the open-source program Maccy for management, GitHub: https://github.com/p0deje/MaccyHow to Convert WAV+CUE to FLACUse Mediahuman Audio Converter, refer to: https://www.reddit.com/r/audiophile/comments/s7ftf3/help_with_cue_splitter_program_for_mac/What to Use for Sandboxing ToolsParallels can install Windows, but $80 is a bit expensive.Solved with utm, note that downloading Windows 11 ARM is a bit troublesome. It must be downloaded and converted using a Windows system from uup dump. Sharing a merged iso file, ref: https://pan.baidu.com/s/1wDPVJRNP27dMv2s1f74TlQ#4qx8.EffectHow to Record GIFsUse the open-source tool kap as a substitute for ScreenToGif on Windows. It doesn’t support trimming and scaling the timeline but is basically usable (especially the feature of selecting application windows, it’s dumb that screen recording tools don’t support it).DevelopmentDisable or Modify System Shortcuts on MacFirstly, Ctrl+Space, which is the shortcut for switching input methods, can be modified in Shortcuts => Input Sources.Next, Ctrl+Command+Space, which by default brings up the emoji menu, can be changed in Shortcuts => App Shortcuts to a complex and seldom-used shortcut.Disable Command+Alt+M, the shortcut for minimizing the window, also in Shortcuts => App Shortcuts, change it to a complex and seldom-used shortcut.Turn off Cmd+Shift+C for creating terminals, as it easily conflicts with browser shortcuts. – Actually, this is a VSCode shortcut.How to Use Shortcuts Similar to Ctrl+Home/Ctrl+End to Move the CursorBy default, the shortcuts on Mac for moving the cursor are:Use Command+Up/Down to jump to the beginning/end of a line (paragraph).Use Option+Left/Right to jump to the beginning of the previous word/end of the next word.Use Command+Top/Bottom to jump to the beginning/end of the text.All the above keys can be combined with Shift.In VSCode, Command+Down is occupied by the Idea shortcut editor.action.goToDeclaration and needs to be disabled.Configuring Terminal Command Line PromptUse iTerm2 and oh-my-zsh.Unable to Use the Run Script Feature in VSCodeError: The terminal process "/bin/zsh '-c', 'pnpm run dev'" failed to launch (exit code: 127).This is resolved after installing iTerm2 and oh-my-zsh, which is odd.Automatic Merging When Pulling Code with Git PullCurrently, using git pull always prompts to enter a commit message, but there should be a configuration to disable this behavior.12git config --global branch.autosetupmerge alwaysgit config --global branch.autosetuprebase alwaysref: https://stackoverflow.com/questions/5480069/Did not take effectSwitching Tabs in VSCodeOkay, IDEA’s default Alt+Left/Right on the Windows platform conflicts with macOS’s own cursor navigation. The following shortcuts can alleviate this issue:Command+Shift+N to open a file – this is the JetBrains IDE shortcut.Command+Alt+Left/Right to move the cursor back/forward to the next position in opened files.Ctrl+Tab to switch tabs (obviously, this shortcut is not very convenient to press).Disabling Alt Key from Typing Special CharactersUnfortunately, this issue seems to be unsolvable as well; it’s a behavior of the built-in macOS input method and there’s no setting to change it.Strange Sound When Launching Android StudioDisable the sound of the emulator:12hw.audioInput = nohw.audioOutput = noUse the following script to disable sound for all emulators:123456789#!/bin/bashfind ~/.android/avd -name "config.ini" | while read linedo awk '!/audio/' $line > tmp rm $line mv tmp $line echo "hw.audioInput = no" >> $line echo "hw.audioOutput = no" >> $linedoneThen clean the data and cold reboot the emulator.Modifying the Hosts File1sudo code /etc/hostsref: https://www.jianshu.com/p/752211238c1bDisabling Automatic Creation of .DS_Store Files on MacSince using a Mac, it’s easy to see this file in git submissions, and its location is unpredictable, which is annoying. So, it’s desired to disable it, here is the answer from chatgpt:You can enter the following command in the terminal to disable macOS from automatically creating .DS_Store files:1defaults write com.apple.desktopservices DSDontWriteNetworkStores trueThis will prevent macOS from creating .DS_Store files on network volumes. If you want to prevent macOS from creating .DS_Store files in local folders, you can enter another line of command in the terminal:1defaults write com.apple.desktopservices DSDontWriteStores trueTo make these changes take effect, you need to log out and log back into your macOS account. If you want to re-enable the creation of .DS_Store files, you can replace “true” with “false” in the above two commands and log out and back into your system account again.Configuring iTerm2 Terminal ShortcutsSurprisingly, the inline cursor movement shortcuts of the widely used terminal tool on Mac are not consistent with the default Mac shortcuts. The expected consistency with Mac includes:Cmd+Left to move to the beginning of the lineCmd+Right to move to the end of the lineOption+Left to move to the beginning of the wordOption+Right to move to the end of the wordThis requires modifying the Key Mappings Preset.ref: https://superuser.com/a/1157575/1078727Disabling iTerm2’s Confirmation Prompt on CloseThis option can be found in Settings => General => Closing.The Input Method Theme in JetBrains IDE Does Not Follow the SystemCurrently, the system theme is dark, but the input method theme is light. It seems to be a bug in JetBrains IDE, and the only workaround is to restart the IDE. Related issue: https://youtrack.jetbrains.com/issue/IDEA-252482/How to Create an ICNS Icon FileCreating and publishing a Mac app requires using a specified icon.12345678910111213141516# 1. Prepare a single image with the maximum size of 1024x1024, rename it to icon.png; other sizes can be generated via terminal commands.# 2. Create a folder named icons.iconset either by right-clicking or using a command.mkdir icons.iconset# 3. Use the "Terminal" to quickly create image files of various required sizes.sips -z 16 16 icon.png -o icons.iconset/icon_16x16.pngsips -z 32 32 icon.png -o icons.iconset/icon_16x16@2x.pngsips -z 32 32 icon.png -o icons.iconset/icon_32x32.pngsips -z 64 64 icon.png -o icons.iconset/icon_32x32@2x.pngsips -z 128 128 icon.png -o icons.iconset/icon_128x128.pngsips -z 256 256 icon.png -o icons.iconset/icon_128x128@2x.pngsips -z 256 256 icon.png -o icons.iconset/icon_256x256.pngsips -z 512 512 icon.png -o icons.iconset/icon_256x256@2x.pngsips -z 512 512 icon.png -o icons.iconset/icon_512x512.pngsips -z 1024 1024 icon.png -o icons.iconset/icon_512x512@2x.png# 4. Run the following command in the terminal to get the icon.icns file.iconutil -c icns icons.iconset -o icon.icnsNote: The icon.png image file and the icons.iconset folder should be saved in the same directory. Start the “Terminal” and switch to the same directory.

博客在允许 JavaScript 运行的环境下浏览效果更佳。

JavaScript mac 博客 浏览效果

相关推荐 去reddit讨论