Common Scripts

Common Scripts let you put Shell scripts and AppleScript into the Finder context menu. They are useful for turning repeated file processing, project commands, system toggles, Git actions, and internal tools into one right-click action.

Scripts are fully configurable: name, type, icon, whether a selected file is required, whether a selected folder is required, and whether execution logs should be shown.

Script Types

When a Shell script runs, MouseBoost first switches to the folder that contains the current selection. In many project workflows, you can write git status, npm run build, or make directly without adding your own cd.

Available Variables

Variable Meaning
@rfpath Path of the currently selected file or folder.
@rfpaths Paths of multiple selected files or folders.
@rfrawpath Raw path of the currently selected file or folder.
@rfpos Folder that contains the current selection.
@rfposs Folders that contain multiple selected items.
@rfname Selected file or folder name, including extension.
@rfnames Multiple selected names, including extensions.
@rfnam Selected file or folder name without extension.
@rfnams Multiple selected names without extensions.
@rfext Selected file extension.
@rfexts Multiple selected file extensions.
@rday Number of days MouseBoost has been used.
@rloading Show a loading indicator while the script runs; useful for long operations.
@rftocommonpath Choose a favorite folder. Overuse may slow context menu loading.

Variable Usage Tips

If a script needs to process paths, prefer MouseBoost variables instead of manually copying Finder paths.

open @rfpath

Work with the folder that contains the current file:

cd @rfpos

Process multiple selected files:

for file in @rfpaths
do
  echo "$file"
done

For long-running commands, add @rloading:

@rloading
git pull

Default Shell Scripts

Create A Same-Named Folder From A File

After selecting a file, create a folder with the same base name, without the extension.

mkdir @rfpos/@rfnam

tar Compression

After selecting files or folders, create a tar.gz archive in the current directory.

@rloading
cd @rfpos
tar -zcvf @rfpos/@rfnam.tar.gz @rfnames

Restart Finder

killall Finder

Toggle Stage Manager

Available on macOS 13+.

state=$(defaults read com.apple.WindowManager GloballyEnabled 2>/dev/null)
if [ "$state" = "0" ] || [ -z "$state" ]; then
defaults write com.apple.WindowManager GloballyEnabled -bool true
else
defaults write com.apple.WindowManager GloballyEnabled -bool false
fi

Toggle Recent Apps In Stage Manager

Available on macOS 13+.

state=$(defaults read com.apple.WindowManager AutoHide 2>/dev/null)
if [ "$state" = "0" ] || [ -z "$state" ]; then
defaults write com.apple.WindowManager AutoHide -bool true
else
defaults write com.apple.WindowManager AutoHide -bool false
fi

Show Local IP

This script shows an execution log.

ipconfig getifaddr en0 || ipconfig getifaddr en1

Clear Clipboard

pbcopy < /dev/null

Default AppleScript Scripts

Welcome Prompt

The actual copy is generated from the current language and app name. This is a structural example.

set content to "Welcome to use MouseBoost"
set btns to {"Cancel", "Go Review"}
try
    display dialog content buttons btns default button 2 with icon note with title "Tip"
    do shell script "open https://apps.apple.com/app/id1551462255"
on error
    display alert "Canceled"
end try

Toggle Dark / Light Appearance

tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell

Start Screen Saver

tell application "System Events"
start current screen saver
end tell

Switch To Dark Appearance

tell application "System Events"
set dark mode of appearance preferences to true
end tell

Switch To Light Appearance

tell application "System Events"
set dark mode of appearance preferences to false
end tell

Lock Screen

tell application "System Events"
set frontApp to name of first application process whose frontmost is true
tell application frontApp to activate
keystroke "q" using {command down, control down}
end tell

Sleep Display And Lock

do shell script "pmset displaysleepnow"

Sleep

tell application "Finder" to sleep

Toggle Menu Bar Auto-Hide

tell application "System Events"
tell dock preferences
set autohide menu bar to not autohide menu bar
end tell
end tell

Toggle Dock Auto-Hide

tell application "System Events"
tell dock preferences
set autohide to not autohide
end tell
end tell

Eject All External Disks

tell application "Finder"
eject (every disk whose ejectable is true and local volume is true)
end tell

Empty Trash

tell application "Finder"
empty trash
end tell

Dynamic Git Scripts

The Git menu changes based on whether the current folder is a Git repository. If the folder is not a Git repository, MouseBoost can show an initialization entry. If it is already a repository, it can show common Git actions.

Git Init Here

git init @rfpath

Git Pull

@rloading
git pull

Git Push

@rloading
git push

Git Add & Commit

MSG=$(osascript -e 'text returned of (display dialog "Commit message:" default answer "" with title "Git Add & Commit")' 2>/dev/null)
[ -n "$MSG" ] && git add @rfpath && git commit -m "$MSG"

Git Add

git add @rfpath

Git Commit

MSG=$(osascript -e 'text returned of (display dialog "Commit message:" default answer "" with title "Git Commit")' 2>/dev/null)
[ -n "$MSG" ] && git commit -a -m "$MSG"

Git Fetch

@rloading
git fetch --all

Git Status

This script shows an execution log.

git status

Git Log

This script shows an execution log.

git log --oneline -20

Git Diff

This script shows an execution log.

git diff @rfpath

How Advanced Users Can Customize Scripts

Open The Current Folder In An Editor

code @rfpos

Copy Selected Files To A Favorite Folder

cp @rfpath ~/Desktop/

Run A Build In The Current Project

@rloading
npm run build

Send Images To A Custom Tool In Batch

for file in @rfpaths
do
  /path/to/your-tool "$file"
done

Usage Notes