Useful functions for macOS using fish shell.
Install with Fisher (recommended):
fisher install halostatue/fish-macos@v5.x
Not using a package manager?
Copy functions/*.fish
to your fish configuration directory preserving the
directory structure.
Compatibility with macOS versions is maintained on a rolling basis. When possible, backwards compatibility will be maintained as long as the functionality is possible in later versions of macOS. Functions and subcommands may be removed if they are no longer supported on the latest versions of macOS. This will always trigger a major version release.
Utilities for working with MacOS apps. Has the following subcommands:
Shows the bundle identifier for each of the applications found for the pattern
(see app find
for how applications are found).
-x
,--exact
: Perform exact matches only-a
,--all
: Show all matches-q
,--quiet
: Suppress error output-s
,--short
: Prints out the bundle IDs only
$ app bundleid 1password
/Applications/1Password for Safari.app: com.1password.safari
/Applications/1Password.app: com.1password.1password
$ app bundleid -x 1password
/Applications/1Password.app: com.1password.1password
Shows installed apps by the provided pattern or patterns. Searches for apps in
/Applications
, /Applications/Setapp
, /Applications/Utilities
,
~/Applications
, /Appliciations/Xcode.app/Contents/Applications
,
/Developer/Applications
, and /System/Applications
.
-x
,--exact
: Perform exact matches only-a
,--all
: Show all matches-q
,--quiet
: Do not print matches
$ app find -a 1password
/Applications/1Password for Safari.app
/Applications/1Password.app
$ app find -x 1password
/Applications/1Password.app'
Shows the front-most application.
-b
,--bundle-id
: Shows the app bundle ID-p
,--path
: Shows the app path-n
,--name
: Shows the app name-P
,--pid
: Shows the PID of the app-a
,--all
: Shows all details
$ app frontmost
iTerm2'
Extracts macOS app icons as PNG (see app find
for how applications
are found).
-x
,--exact
: Perform exact matches only-oOUTPUT
: Output to the file or directory specified--output OUTPUT
: Output to the file or directory specified-wWIDTH
: Outputs to a maximum of WIDTH pixels--width WIDTH
: Outputs to a maximum of WIDTH pixels
Quits apps identified by the provided pattern or patterns (see app find
for
how applications are found).
-x
,--exact
: Quits only applications with exact matches-r
,--restart
: Restarts the application that was quit
Interacts with the Finder. If a window number parameter is accepted in
a command, the first (front-most) window is number 1
. If a lower window is
specified, or no window is specified, that window becomes the first window.
Makes the first Finder window track with the shell $PWD
. This should be used
in a single shell instance only, and updates only when the $PWD
value is
updated.
Disables Finder directory tracking.
Changes the current path to that of the Finder window.
Changes the current path with pushd
to that of the Finder window.
Print the current path of the Finder window.
Changes the Finder window to the current working directory ($PWD
) using the
column
view.
Changes the Finder window to the current working directory ($PWD
) using the
icon
view.
Changes the Finder window to the current working directory ($PWD
) using the
list
view.
Changes the Finder window to the current working directory ($PWD
) using the
current view.
Removes .DS_Store
files from the paths provided, or the current path if one is
not provided.
finder hidden [off|on|toggle]
Shows or hides hidden files in Finder. Accepts a parameter on
(show the
files), off
(hide the files), or toggle
. If no parameter is given, shows the
current state.
Prints a list of selected folders and files from Finder.
Shows quarantine events from quarantine databases.
Clears quarantine events from quarantine databases.
Cleans the named file(s) of quarantine extended attributes.
Shows or hides the desktop icons. Accepts a parameter on
(show the files),
off
(hide the files), or toggle
. If no parameter is given, shows the current
state.
Returns true if one or more of the named MacOS application exists. This is a
specialized wrapper around app find
that always looks for exact matches.
This was called has:app
, but has been renamed has_app
. The previous versions
will be removed at version 6.
Manage various aspects of the modern MacOS interface.
Works with the Mac AirDrop configurations. Has the following subcommands:
on
: Turns AirDrop on.off
: Turns AirDrop off.status
: Reports the status of AirDrop.
Work with Mac AirPort configurations. Has the following subcommands:
scan
: Scans the current AirPort configurations.ssid
: Prints the current AirPort network SSID.history
: Prints the history of network connections.on
: Turns AirPorton
.off
: Turns AirPortoff
.password
: Recovers the current AirPort network password, or the password for a specified SSID.
Flush the MacOS DNS cache.
Locks the screen.
Clean LaunchServices to remove duplicate 'Open with...' entries.
Set or show the Mac audio volume.
View a man page as a PDF via Preview.app
. PDFs will be cached in
/private/tmp/man PDFs
by default, but this can be overridden with the
universal variable $manp_cache_path
. It will be opened with the default PDF
application by default unless $manp_pdf_app_name
is set.
The cache can be cleared with --clear-cache
.
Add a note to Notes.app.
Quick Look a file from the command-line.
Add a note to Reminders.app.