├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── tests.yml │ └── zizmor.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── Justfile ├── LICENCE.md ├── README.md ├── completions ├── app.fish ├── finder.fish ├── mac.fish ├── manp.fish └── ql.fish ├── conf.d └── halostatue_fish_macos.fish └── functions ├── __macos_app_bundleid.fish ├── __macos_app_find.fish ├── __macos_app_frontmost.fish ├── __macos_app_icon.fish ├── __macos_app_quit.fish ├── __macos_finder_cd.fish ├── __macos_finder_clean.fish ├── __macos_finder_column.fish ├── __macos_finder_desktop_icons.fish ├── __macos_finder_hidden.fish ├── __macos_finder_icon.fish ├── __macos_finder_list.fish ├── __macos_finder_pushd.fish ├── __macos_finder_pwd.fish ├── __macos_finder_quarantine.fish ├── __macos_finder_selected.fish ├── __macos_finder_track.fish ├── __macos_finder_untrack.fish ├── __macos_finder_update.fish ├── __macos_mac_airdrop.fish ├── __macos_mac_airport.fish ├── __macos_mac_brightness.fish ├── __macos_mac_defaults_query.fish ├── __macos_mac_flushdns.fish ├── __macos_mac_font_smoothing.fish ├── __macos_mac_lsclean.fish ├── __macos_mac_mail.fish ├── __macos_mac_proxy_icon.fish ├── __macos_mac_serialnumber.fish ├── __macos_mac_touchid.fish ├── __macos_mac_touchid_sudo.fish ├── __macos_mac_transparency.fish ├── __macos_mac_version.fish ├── __macos_mac_vol.fish ├── app.fish ├── finder.fish ├── has_app.fish ├── mac.fish ├── manp.fish ├── note.fish ├── ql.fish └── remind.fish /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: halostatue 2 | buy_me_a_coffee: halostatue 3 | ko_fi: halostatue 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: weekly 7 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Test scripts 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: ["main"] 7 | workflow_dispatch: 8 | 9 | permissions: {} 10 | 11 | jobs: 12 | check-fish: 13 | uses: halostatue/halostatue/.github/workflows/fish-tests.yml@0fa19a3bec5383af45c771b04f06a0f4c0bc3bbd # v1.0.1 14 | permissions: 15 | contents: read 16 | -------------------------------------------------------------------------------- /.github/workflows/zizmor.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Actions Security Analysis with zizmor 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | pull_request: 7 | 8 | permissions: {} 9 | 10 | jobs: 11 | zizmor: 12 | uses: halostatue/halostatue/.github/workflows/zizmor.yml@0fa19a3bec5383af45c771b04f06a0f4c0bc3bbd # v1.0.1 13 | permissions: 14 | security-events: write 15 | contents: read 16 | actions: read 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # fish-macos Changelog 2 | 3 | ## 7.0.1 / 2025-04-29 4 | 5 | - Updated the `README` to indicate that `halostatue/fish-macos` depends on 6 | `halostatue/fish-utils-core`, resolving [#4][issue-4]. Thanks for the report, 7 | @iameven. 8 | 9 | - @Samasaur1 fixed a bug with `mac brightness` not working in [#19][pull-19]. 10 | Thanks for the contribution! 11 | 12 | ## 7.0.0 / 2025-01-27 13 | 14 | - Rewrote `mac touchid sudo` again to simplify. 15 | 16 | - It now only works if your macOS specifies `auth include sudo_local` in 17 | `/etc/pam.d/sudo`. The main file will no longer be edited. As a benefit, 18 | `/etc/pam.d/sudo_local` survives reboots and operating system upgrades, so 19 | as long as the `pam_tid.so` and `pam_reattach.so` files are not missing or 20 | do not work, nothing will be broken. 21 | 22 | - If `pam_tid` or `pam_reattach` are included in `/etc/pam.d/sudo`, execution 23 | will halt for the user to remove those settings. 24 | 25 | - The restriction on MacPorts `pam_reattach` has been lifted, because the 26 | management of a broken `/etc/pam.d/sudo_local` is much easier to resolve: 27 | 28 | 1. `open /etc/pam.d` 29 | 2. Use ⌘⌫ in Finder on `sudo_local` to delete the file. Authenticate 30 | (possibly with Touch ID), and everything is fixed. 31 | 32 | - If `pam_tid` and `pam_reattach` are correctly installed, nothing changes. If 33 | the path for `pam_reattach` has changed, both `pam_tid` and `pam_reattach` 34 | will be replaced, which will probably trigger both a Touch ID authorization 35 | request _and_ a password authorization request. 36 | 37 | - Updated `mac version` (which was two versions out of date). 38 | 39 | - Added more documentation. 40 | 41 | ## 6.1.0 / 2025-01-15 42 | 43 | - Added `mac brightness` to change the screen brightness. Adapted from 44 | [mattmc3/macos.fish/functions/bright.fish][bright]. 45 | 46 | - Rewrote `mac touchid sudo` encompassing a number of changes. 47 | 48 | - MacPorts-installed `pam_reattach` is no longer supported and will not be 49 | located. If it is present (even if manually added), then 50 | `mac touchid sudo on` **will** remove it. A warning about this will always 51 | be printed, even if `--quiet` is specified. 52 | 53 | - If `pam_reattach` is not configured with the currently discovered 54 | `pam_reattach`, a message will be printed (even if `--quiet` is specified) 55 | and the existing `pam_reattach` configuration will be removed. 56 | 57 | - Recent versions of macOS support a file `/etc/pam.d/sudo_local` that is kept 58 | during operating system upgrades so that Touch ID support should continue to 59 | work. 60 | 61 | If a migration from `/etc/pam.d/sudo` to `/etc/pam.d/sudo_local` is 62 | detected, a message will be printed, even if `--quiet` is specified. 63 | 64 | ## 6.0.1 / 2025-01-04 65 | 66 | - Added version information to comment tags. 67 | - Switched to long flags where possible. 68 | - Switched to `set --function` instead of `set --local`. 69 | - Updated documentation. 70 | - Added tooling to the Justfile for easier release management. 71 | 72 | ## 6.0.0 / 2024-12-30 73 | 74 | - Removed `has:app`. 75 | 76 | - Updated Code of Conduct to Contributor Covenant 2.1. 77 | 78 | - Tags will no longer have `.x` attached. 79 | 80 | ## 5.1.2 / 2023-02-26 81 | 82 | - Fixed an error where MacPorts-installed `pam_reattach` was not being detected. 83 | 84 | - Added a warning on installing `pam_reattach` with MacPorts and that `sudo` 85 | support must be disabled _before_ uninstalling `pam_reattach`. The 86 | installation of `pam_reattach` with MacPorts is _discouraged_ for this reason, 87 | but still supported. A warning will _always_ be printed when using MacPorts, 88 | even if `--quiet` is specified. 89 | 90 | ## 5.1.1 / 2023-02-21 91 | 92 | - Changed internal use of `has:app` to `has_app`. 93 | 94 | ## 5.1 / 2023-02-19 95 | 96 | - Deprecated `has:app` and replaced with `has_app`. 97 | 98 | - Added `mac touchid` to control Touch ID support for `sudo`. 99 | 100 | ## 5.0 / 2022-12-05 101 | 102 | - Changed `manp` to be compatible with macOS Ventura and prefer not using an 103 | external package (Ghostscript). The solution was adapted from 104 | [man2pdf.sh][man2pdf.sh] by [Pico Mitchell][Pico Mitchell], originally found 105 | via Rob Griffiths’s [blog][blog] and Armin Briegel's 106 | [Scripting OS X][Scripting OS X]. 107 | 108 | - Added `app frontmost` to show the app with the current top window. 109 | 110 | - Removed features no longer supported under macOS Ventura: 111 | 112 | - `mac airport history` (the matching plist is empty) 113 | 114 | - `mac lock-screen` (the underlying binary is missing) 115 | 116 | - Removed `trash`. There are better tools than this function, such as: 117 | 118 | - [trash][trash], a small command-line program that moves files or folders to 119 | the trash. 120 | 121 | - [rmtrash][rmtrash] is a small utility that will move the file to OS X's 122 | Trash rather than obliterating the file (as rm does). 123 | 124 | - [macos-trash][macos-trash] is a small command-line program that moves files 125 | or folders to the trash, written in Swift 126 | 127 | - Improved completion scripts and overall consistency. 128 | 129 | - Added several governance documents, adopting a code of conduct. 130 | 131 | ## 4.0 / 2022-06-11 132 | 133 | - Extracted the various sub-functions only loaded when `app` is run (and `mac` 134 | and `finder`) so that they can be called more reliably. This is now much 135 | better and fixes a bug with `has:app` where applications installed in 136 | /System/Applications (new with macOS 11 and later) were not found. 137 | 138 | - Remove the function `pdfmerge`. This has been turned into a script that will 139 | work both on macOS and on any system with Ghostscript installed. It will be 140 | published later. 141 | 142 | - Fixed the `remind` function so that it will fail if the Reminders app is not 143 | installed _or_ the provided text is empty. 144 | 145 | - Fixed the `note` function so that it will fail if the Notes app is not 146 | installed _or_ the provided text is empty. 147 | 148 | - Added `mac version` command to show the current macOS version in one of 149 | several different ways. This depends on halostatue/fish-utils-core@v2.1 or 150 | higher. 151 | 152 | ## 3.0 / 2022-04-02 153 | 154 | - Rewrote the `app` function to more consistently use `app find` for the other 155 | subcommands. `app find` is more robust and does not depend on glob matching. 156 | Alternative spellings of `app bundleid` are no longer accepted. Various flags 157 | have been changed, added, or removed: 158 | 159 | - All subcommands support `--help` 160 | - All subcommands support `--exact`, which is forwarded to `app find`, which 161 | makes the pattern match stricter, but is not incompatible with `--all`. 162 | - `app find` no longer accepts `--any`; the short form for `--all` is now 163 | `-a`, not `-A`. 164 | - The `app quit` short form for `--restart` is now `-r`, not `-R`. 165 | 166 | - Fixed the remind function definition. 167 | 168 | - Updated the `mac` app to remove some subcommand or argument aliases. 169 | 170 | - `mac airdrop` no longer supports `up` and `down`, but only `on` and `off` 171 | 172 | - Added completion wrappers for `manp` and `ql`. 173 | 174 | - Improved the uninstall function. 175 | 176 | ## 2.0 / 2020-06-28 177 | 178 | - Added `app` function. Adds new functionality and replaces `quitapp`. 179 | - Added `mac` function. Replaces `airdrop` (`mac airdrop`), `airport` 180 | (`mac airport`), `flushdns` (`mac flushdns`), `lock-screen` 181 | (`mac lock-screen`), `lsclean` (`mac lsclean`), and `vol` (`mac vol`). 182 | 183 | - Moved `quarantine` to `finder quarantine`. 184 | - Moved `desktop-icons` to `finder desktop-icons`. 185 | - Removed `finder show-hidden` and `finder hide-hidden`. 186 | - Removed `plistbuddy`. Prefer using `plutil`. 187 | - Removed `dash`; this exists in `halostatue/fish-macos-apps` instead. 188 | - Removed `battery`. Use either `halostatue/fish-battery` or 189 | `oh-my-fish/plugin-battery` instead. 190 | - Removed aliases to `finder` subcommands. 191 | 192 | ## 1.2 / 2019-12-31 193 | 194 | - Added `airdrop`, `trash`, and several aliases to subcommands for `finder` 195 | (matching [oh-my-fish/plugin-osx][oh-my-fish/plugin-osx]). 196 | 197 | - Improved some `finder` subcommands. 198 | 199 | - Fixed a bug in `has:app` and the uninstaller. 200 | 201 | ## 1.1 / 2019-06-17 202 | 203 | - Improved several utilities and added an uninstaller. 204 | 205 | ## 1.0 / 2019-06-16 206 | 207 | - Initial version 208 | 209 | [blog]: https://robservatory.com/open-postscript-files-in-preview-in-macos-ventura/ 210 | [macos-trash]: https://github.com/sindresorhus/macos-trash 211 | [man2pdf.sh]: https://gist.github.com/PicoMitchell/619c12fd6a53ae6ec657514915d4edf9 212 | [oh-my-fish/plugin-osx]: https://github.com/oh-my-fish/plugin-osx 213 | [pico mitchell]: https://github.com/PicoMitchell 214 | [rmtrash]: http://www.nightproductions.net/cli.htm 215 | [scripting os x]: https://scriptingosx.com/2022/11/on-viewing-man-pages-ventura-update/ 216 | [trash]: https://github.com/ali-rantakari/trash 217 | [bright]: https://github.com/mattmc3/macos.fish/blob/main/functions/bright.fish 218 | [issue-4]: https://github.com/halosttue/fish-macos/issues/4 219 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official email address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at [INSERT CONTACT 63 | METHOD]. All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series of 85 | actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or permanent 92 | ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within the 112 | community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.1, available at 118 | . 119 | 120 | Community Impact Guidelines were inspired by 121 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 122 | 123 | For answers to common questions about this code of conduct, see the FAQ at 124 | . Translations are available at 125 | . 126 | 127 | [homepage]: https://www.contributor-covenant.org 128 | [Mozilla CoC]: https://github.com/mozilla/diversity 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | I value any contribution you can provide—a bug report, a feature request, or 4 | code contributions. When contributing code, please note: 5 | 6 | - If tests exist for the project, the test suite should pass. New or changed 7 | functionality should have tests added. The test suite is written with 8 | [fishtape][fishtape]. 9 | 10 | - Code style is mostly provided by `fish_indent`. There are a few things not 11 | covered by `fish_indent`: 12 | 13 | - Where possible, prefer using fish built-ins over external programs like sed 14 | or awk. 15 | 16 | - For simple conditional execution, prefer `and` or `or`. Avoid chaining these 17 | conditions and prefer `if` with `&&` or `||` expressions as appropriate. 18 | 19 | - Use a thoughtfully-named topic branch that contains your change. Rebase your 20 | commits into logical chunks as necessary. 21 | - Use [quality commit messages][quality commit messages]. 22 | - Do not change the version number; when your patch is accepted and a release is 23 | made, the version will be updated at that point. 24 | - Submit a GitHub pull request with your changes. 25 | - New or changed behaviours require new or updated documentation. 26 | 27 | [quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 28 | [fishtape]: https://github.com/jorgebucaran/fishtape 29 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | - Austin Ziegler ([@halostatue][@halostatue]) 4 | - Sam ([@samsaur1][@samasaur1]) 5 | - Evan Minsk ([@iamevn][@iamevn]) 6 | 7 | [@halostatue]: https://github.com/halostatue 8 | [@samsaur1]: https://github.com/samasaur1 9 | [@iamevn]: https://github.com/iamevn 10 | -------------------------------------------------------------------------------- /Justfile: -------------------------------------------------------------------------------- 1 | base := "@halostatue/fish-macos" 2 | 3 | set shell := ['fish', '-c'] 4 | 5 | _list: 6 | @just --list 7 | 8 | # Ensure that all `.fish` files have comment-version tags 9 | prepare version: 10 | #!/usr/bin/env fish 11 | 12 | if ! string match -rq '^[0-9.]+$' '{{ version }}' 13 | echo >&2 "Invalid version {{ version }}" 14 | exit 1 15 | end 16 | 17 | if ! string match -rq '## {{ version }}' &2 "Version {{ version }} is not mentioned in the changelog." 19 | exit 1 20 | end 21 | 22 | for file in **.fish 23 | if ! string match -rq "^# {{ base }}/$file" <$file 24 | sed -i '' -e "1i\\ 25 | # {{ base }}/$file:v{{ version }} 26 | 27 | " $file 28 | end 29 | 30 | sed -i '' \ 31 | -e 's!'$file'$!'$file':v{{ version }}!' \ 32 | -e 's!'$file':v[0-9.]*$!'$file':v{{ version }}!' $file 33 | end 34 | 35 | # Apply a git tag for the version 36 | tag version: 37 | #!/usr/bin/env fish 38 | 39 | if ! string match -rq '^[0-9.]+$' '{{ version }}' 40 | echo >&2 "Invalid version {{ version }}" 41 | exit 1 42 | end 43 | 44 | if ! string match -rq '## {{ version }}' &2 "Version {{ version }} is not mentioned in the changelog." 46 | exit 1 47 | end 48 | 49 | for file in **.fish 50 | if ! string match -rq ':v{{ version }}$' <$file 51 | echo >&2 "File $file is not tagged with version {{ version }}." 52 | exit 1 53 | end 54 | end 55 | 56 | if string match -rq -- '-dirty' (git describe --dirty 2>/dev/null) 57 | echo >&2 "Uncommitted changes are present." 58 | exit 1 59 | end 60 | 61 | set major (string split -f1 . {{ version }}) 62 | set minor (string split -f1,2 . {{ version }} | string join .) 63 | 64 | if git tag | string match -q v$major 65 | git tag -f v$major -m "v$major -> v{{ version }}" 66 | else 67 | git tag v$major -m "v$major -> v{{ version }}" 68 | end 69 | 70 | if git tag | string match -q v$minor 71 | git tag -f v$minor -m "v$minor -> v{{ version }}" 72 | else 73 | git tag v$minor -m "v$minor -> v{{ version }}" 74 | end 75 | 76 | if git tag | string match -q v{{ version }} 77 | git tag -f v{{ version }} 78 | else 79 | git tag v{{ version }} 80 | end 81 | 82 | # Format fish files 83 | fmt: 84 | @fish_indent --write **.fish 85 | 86 | # Lint fish files 87 | lint: 88 | #! /usr/bin/env fish 89 | 90 | for file in **.fish 91 | fish --no-execute $file 92 | end 93 | 94 | # Run tests 95 | test: _install-clownfish _install-fishtape 96 | @fishtape tests/**.test.fish 97 | 98 | _install-fisher: 99 | @type -q fisher || begin; curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher; end 100 | 101 | _install-clownfish: _install-fisher 102 | @type -q mock || fisher install IlanCosman/clownfish 103 | 104 | _install-fishtape: _install-fisher 105 | @type -q fishtape || fisher install jorgebucaran/fishtape 106 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | # MIT Licence 2 | 3 | Copyright © 2019–2025 Austin Ziegler 4 | 5 | Some functions derived from oh-my-fish/plugin-osx, copyright 2014 Brun Ferreira 6 | Pinto. 7 | 8 | `mac mail` function shared originally on the Hawk Wings blog Romulo based on a 9 | script by "pmbuko". It was subsequently updated by Brett Terpstra in 2012, 10 | Mathias Törnblom in 2015, and Andrei Miclaus in 2017. 11 | 12 | From version 5.0, `manp` is based on man2pdf.sh created by Pico Mitchell (of 13 | Random Applications) on 11/16/22, licensed under the MIT license. 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 19 | the Software, and to permit persons to whom the Software is furnished to do so, 20 | subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 27 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 28 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 29 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # halostatue/fish-macos 2 | 3 | [![Version][version]](https://github.com/halostatue/fish-macos/releases) 4 | 5 | Useful functions for macOS using [fish shell][fish]. 6 | 7 | ## Installation 8 | 9 | Install with [Fisher][fisher]: 10 | 11 | ```fish 12 | fisher install halostatue/fish-utils-core@v3 halostatue/fish-macos@v7 13 | ``` 14 | 15 | `halostatue/fish-macos` depends on `halostatue/fish-utils-core@v3` or later. 16 | 17 | ### System Requirements 18 | 19 | - [fish][fish] 3.4+ 20 | - [halostatue/fish-utils-core][core] 21 | 22 | Compatibility with macOS versions is maintained on a rolling basis. When 23 | possible, _backwards_ compatibility will be maintained as long as the 24 | functionality is _possible_ in later versions of macOS. Functions and 25 | subcommands may be removed if they are no longer supported on the latest 26 | versions of macOS. This will always trigger a major version release. 27 | 28 | ## Functions 29 | 30 | ### `app` 31 | 32 | Utilities for working with MacOS apps. Has the following subcommands: 33 | 34 | #### `app bundleid` 35 | 36 | Shows the bundle identifier for each of the applications found for the pattern 37 | (see `app find` for how applications are found). 38 | 39 | ##### Options 40 | 41 | - `-x`, `--exact`: Perform exact matches only 42 | - `-a`, `--all`: Show all matches 43 | - `-q`, `--quiet`: Suppress error output 44 | - `-s`, `--short`: Prints out the bundle IDs only 45 | 46 | ##### Examples 47 | 48 | ```console 49 | $ app bundleid 1password 50 | /Applications/1Password for Safari.app: com.1password.safari 51 | /Applications/1Password.app: com.1password.1password 52 | 53 | $ app bundleid -x 1password 54 | /Applications/1Password.app: com.1password.1password 55 | ``` 56 | 57 | #### `app find` 58 | 59 | Shows installed apps by the provided pattern or patterns. Searches for apps in 60 | `/Applications`, `/Applications/Setapp`, `/Applications/Utilities`, 61 | `~/Applications`, `/Appliciations/Xcode.app/Contents/Applications`, 62 | `/Developer/Applications`, and `/System/Applications`. 63 | 64 | ##### Options 65 | 66 | - `-x`, `--exact`: Perform exact matches only 67 | - `-a`, `--all`: Show all matches 68 | - `-q`, `--quiet`: Do not print matches 69 | 70 | ##### Examples 71 | 72 | ```console 73 | $ app find -a 1password 74 | /Applications/1Password for Safari.app 75 | /Applications/1Password.app 76 | 77 | $ app find -x 1password 78 | /Applications/1Password.app' 79 | ``` 80 | 81 | #### `app frontmost` 82 | 83 | Shows the front-most application. 84 | 85 | ##### Options 86 | 87 | - `-b`, `--bundle-id`: Shows the app bundle ID 88 | - `-p`, `--path`: Shows the app path 89 | - `-n`, `--name`: Shows the app name 90 | - `-P`, `--pid`: Shows the PID of the app 91 | - `-a`, `--all`: Shows all details 92 | 93 | ##### Examples 94 | 95 | ```console 96 | $ app frontmost 97 | iTerm2' 98 | ``` 99 | 100 | #### `app icon` 101 | 102 | Extracts macOS app icons as PNG (see `app find` for how applications are found). 103 | 104 | ##### Options 105 | 106 | - `-x`, `--exact`: Perform exact matches only 107 | - `-oOUTPUT`: Output to the file or directory specified 108 | - `--output OUTPUT`: Output to the file or directory specified 109 | - `-wWIDTH`: Outputs to a maximum of WIDTH pixels 110 | - `--width WIDTH`: Outputs to a maximum of WIDTH pixels 111 | 112 | #### `app quit` 113 | 114 | Quits apps identified by the provided pattern or patterns (see `app find` for 115 | how applications are found). 116 | 117 | ##### Options 118 | 119 | - `-x`, `--exact`: Quits only applications with exact matches 120 | - `-r`, `--restart`: Restarts the application that was quit 121 | 122 | ### `finder` 123 | 124 | Interacts with the Finder. If a window number parameter is accepted in a 125 | command, the first (front-most) window is number `1`. If a lower window is 126 | specified, or no window is specified, that window becomes the first window. 127 | 128 | #### `finder track` 129 | 130 | Makes the first Finder window track with the shell `$PWD`. This should be used 131 | in a single shell instance only, and updates only when the `$PWD` value is 132 | updated. 133 | 134 | #### `finder untrack` 135 | 136 | Disables Finder directory tracking. 137 | 138 | #### `finder cd [window#]` 139 | 140 | Changes the current path to that of the Finder window. 141 | 142 | #### `finder pushd [window#]` 143 | 144 | Changes the current path with `pushd` to that of the Finder window. 145 | 146 | #### `finder pwd [window#]` 147 | 148 | Print the current path of the Finder window. 149 | 150 | #### `finder column [window#]` 151 | 152 | Changes the Finder window to the current working directory (`$PWD`) using the 153 | `column` view. 154 | 155 | #### `finder icon [window#]` 156 | 157 | Changes the Finder window to the current working directory (`$PWD`) using the 158 | `icon` view. 159 | 160 | #### `finder list [window#]` 161 | 162 | Changes the Finder window to the current working directory (`$PWD`) using the 163 | `list` view. 164 | 165 | #### `finder update [window#]` 166 | 167 | Changes the Finder window to the current working directory (`$PWD`) using the 168 | current view. 169 | 170 | #### `finder clean [path...]` 171 | 172 | Removes `.DS_Store` files from the paths provided, or the current path if one is 173 | not provided. 174 | 175 | #### `finder hidden [off|on|toggle]` 176 | 177 | Shows or hides hidden files in Finder. Accepts a parameter `on` (show the 178 | files), `off` (hide the files), or `toggle`. If no parameter is given, shows the 179 | current state. 180 | 181 | #### `finder selected` 182 | 183 | Prints a list of selected folders and files from Finder. 184 | 185 | #### `finder quarantine [show]` 186 | 187 | Shows quarantine events from quarantine databases. 188 | 189 | #### `finder quarantine clear` 190 | 191 | Clears quarantine events from quarantine databases. 192 | 193 | #### `finder quarantine clean FILE...` 194 | 195 | Cleans the named file(s) of quarantine extended attributes. 196 | 197 | #### `finder desktop-icons [off|on|toggle]` 198 | 199 | Shows or hides the desktop icons. Accepts a parameter `on` (show the files), 200 | `off` (hide the files), or `toggle`. If no parameter is given, shows the current 201 | state. 202 | 203 | ### `has_app` 204 | 205 | Returns true if one or more of the named MacOS application exists. This is a 206 | specialized wrapper around `app find` that always looks for exact matches. 207 | 208 | This was called `has:app`, but has been renamed `has_app`. The previous versions 209 | will be removed at version 6. 210 | 211 | ### `mac` 212 | 213 | Manage various aspects of the modern MacOS interface. 214 | 215 | #### `mac airdrop` 216 | 217 | Works with the Mac AirDrop configurations. Has the following subcommands: 218 | 219 | - `on`: Turns AirDrop on. 220 | - `off`: Turns AirDrop off. 221 | - `status`: Reports the status of AirDrop. 222 | 223 | #### `mac airport` 224 | 225 | Work with Mac AirPort configurations. Has the following subcommands: 226 | 227 | - `scan`: Scans the current AirPort configurations. 228 | - `ssid`: Prints the current AirPort network SSID. 229 | - `history`: Prints the history of network connections. 230 | - `on`: Turns AirPort `on`. 231 | - `off`: Turns AirPort `off`. 232 | - `password`: Recovers the current AirPort network password, or the password for 233 | a specified SSID. 234 | 235 | #### `mac brightness` 236 | 237 | Increase or decrease the brightness level. This uses system event key codes. 238 | Supports `up` (increase brightness) and `down` (decrease brightness). 239 | 240 | #### `mac flushdns` 241 | 242 | Flush the MacOS DNS cache. 243 | 244 | #### `mac font-smoothing` 245 | 246 | Enables or disables font smoothing. If no apps are provided, sets the global 247 | font smoothing preference. If apps are provided, font smoothing will be set for 248 | each app. See `app bundleid` for how apps are resolved. 249 | 250 | `mac font-smoothing [options] off|on [APP...]` 251 | 252 | #### `mac lsclean` 253 | 254 | Clean LaunchServices to remove duplicate 'Open with...' entries. 255 | 256 | #### `mac mail` 257 | 258 | Performs operations on Mail.app configuration and database. Before running 259 | vacuum after any OS upgrade, Mail.app must have been opened at least once so 260 | that the database and index formats have been updated. 261 | 262 | Supported subcommands are: 263 | 264 | - `vacuum`: Vacuums the envelope index to improve performance. 265 | - `attachments inline`: Sets Mail.app attachment handling to inline. 266 | - `attachments icon`: Sets Mail.app attachment handling to icon. 267 | 268 | > This started as a process to speed up Mail.app by vacuuming the envelope index 269 | > with a history from a October 2007 [blog post][hawkwings] by Tim Gaden on the 270 | > Hawk Wings blog covering tips and tricks for Apple Mail. It turned into a 271 | > script by [pmbuko][pmbuko] and Romulo and variously updated by Brett Terpstra 272 | > (2012), Mathias Törnblom (2015), Andrei Miclaus (2017) before I ported it to 273 | > Fish in 2022. 274 | 275 | [hawkwings]: http://web.archive.org/web/20071008123746/http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/ 276 | [pmbuko]: https://github.com/pmbuko 277 | 278 | #### `mac proxy-icon` 279 | 280 | Enables or disables the visibility of the proxy icon without delay. macOS 281 | versions older than Monterey always show the proxy icon. 282 | 283 | States: 284 | 285 | - `FLOAT`: Sets the display of the proxy icon to FLOAT fractional seconds. 286 | - `off`: Sets the display of the proxy icon to default. 287 | - `on` Sets the display of the proxy icon to 0 seconds. 288 | - `[status]`: Shows the duration of the proxy icon display. 289 | - `toggle`: Toggles the display of the proxy icon. 290 | 291 | When displaying `status`, `-q` or `--query` can be used to suppress the output. 292 | 293 | #### `mac serialnumber` 294 | 295 | Gets the serial number for the current macOS device. 296 | 297 | #### `mac touchid sudo` 298 | 299 | Enables or disables Touch ID support for `sudo`. Requires administrative 300 | permissions to edit `/etc/pam.d/sudo_local` and executes with `sudo`. If 301 | `pam_reattach` is installed, this will be managed as well. 302 | 303 | The following states may be specified: 304 | 305 | - `off`: Disables Touch ID. 306 | - `on`: Enables Touch ID. 307 | - `[status]`: Shows the status of Touch ID. 308 | - `toggle`: Toggles the status of Touch ID. 309 | 310 | ##### Notes 311 | 312 | In v7 or later, `mac touchid sudo` only manages `/etc/pam.d/sudo_local`. It will 313 | halt if either `pam_tid` or `pam_reattach` are present in `/etc/pam.d/sudo` or 314 | if `/etc/pam.d/sudo` does not include `sudo_local`. 315 | 316 | `/etc/pam.d/sudo_local` survives reboots and operating system upgrades, so as 317 | long as the `pam_tid.so` and `pam_reattach.so` files are not missing or do not 318 | work, nothing will be broken. 319 | 320 | If something breaks while managing `/etc/pam.d/sudo_local`, recovery is easy: 321 | 322 | 1. `open /etc/pam.d` 323 | 2. Use ⌘⌫ in Finder on `sudo_local` to delete the file. Authenticate (possibly 324 | with Touch ID), and everything is fixed. 325 | 326 | #### `mac transparency` 327 | 328 | Enables or disables interface transparency by setting the universal access 329 | "reduce transparency" setting. 330 | 331 | Valid states are: 332 | 333 | - `off`: Disables interface transparency 334 | - `on`: Enables interface transparency 335 | - `[status]`: Shows the status of interface transparency 336 | - `toggle`: Toggles interface transparency 337 | 338 | #### `mac version` 339 | 340 | Shows the current macOS version. 341 | 342 | Options include: 343 | 344 | - `-s`, `--simple`: Removes spaces from the version displayed 345 | - `-l`, `--lowercase`: Converts the version to all lowercase 346 | - `-c`, `--comparable`: Outputs the comparable version value 347 | - `-v`, `--version`: Outputs the macOS version (same as 348 | `sw_vers -productVersion`)' 349 | 350 | #### `mac vol` 351 | 352 | Set or show the Mac audio volume. 353 | 354 | ### `manp` 355 | 356 | View a man page as a PDF via `Preview.app`. PDFs will be cached in 357 | `/private/tmp/man PDFs` by default, but this can be overridden with the 358 | universal variable `$manp_cache_path`. It will be opened with the default PDF 359 | application by default unless `$manp_pdf_app_name` is set. 360 | 361 | The cache can be cleared with `--clear-cache`. 362 | 363 | ### `note` 364 | 365 | Add a note to Notes.app. 366 | 367 | ### `ql` 368 | 369 | Quick Look a file from the command-line. 370 | 371 | ### `remind` 372 | 373 | Add a note to Reminders.app. 374 | 375 | ## Licence 376 | 377 | [MIT](./LICENCE.md) 378 | 379 | ## Change Log 380 | 381 | [CHANGELOG](./CHANGELOG.md) 382 | 383 | ## Contributing 384 | 385 | - [Contributing](./CONTRIBUTING.md) 386 | - [Contributors](./CONTRIBUTORS.md) 387 | - [Code of Conduct](./CODE_OF_CONDUCT.md) 388 | 389 | [version]: https://img.shields.io/github/tag/halostatue/fish-macos.svg?label=Version 390 | [fisher]: https://github.com/jorgebucaran/fisher 391 | [fish]: https://github.com/fish-shell/fish-shell 392 | [core]: https://github.com/halostatue/fish-utils-core 393 | -------------------------------------------------------------------------------- /completions/app.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/completions/app.fish:v7.0.1 2 | 3 | complete --command app --erase 4 | 5 | complete --command app --arguments bundleid \ 6 | --exclusive --condition __fish_use_subcommand \ 7 | --description 'Show bundle IDs for macOS apps' 8 | 9 | complete --command app --arguments find \ 10 | --exclusive --condition __fish_use_subcommand \ 11 | --description 'Find macOS apps by pattern' 12 | 13 | complete --command app --arguments frontmost \ 14 | --exclusive --condition __fish_use_subcommand \ 15 | --description 'Shows the front-most application' 16 | 17 | complete --command app --arguments icon \ 18 | --exclusive --condition __fish_use_subcommand \ 19 | --description 'Extracts a MacOS app icon as a png file' 20 | 21 | complete --command app --arguments quit \ 22 | --exclusive --condition __fish_use_subcommand \ 23 | --description 'Quit macOS apps by pattern' 24 | 25 | for subcommand in bundleid find 26 | complete --command app --condition '__fish_seen_subcommand_from '$subcommand \ 27 | --short-option x --long-option exact --description 'Exact matches only' 28 | 29 | complete --command app --condition '__fish_seen_subcommand_from '$subcommand \ 30 | --short-option a --long-option all --description 'Show all matches' 31 | 32 | complete --command app --condition '__fish_seen_subcommand_from '$subcommand \ 33 | --short-option q --long-option quiet --description 'Quiet (show no output)' 34 | 35 | complete --command app --condition '__fish_seen_subcommand_from '$subcommand \ 36 | --short-option h --long-option help --description 'Help for app '$subcommand 37 | end 38 | 39 | complete --command app --condition '__fish_seen_subcommand_from 'bundleid \ 40 | --short-option s --long-option short --description 'Show only the bundle ID' 41 | 42 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 43 | --short-option b --long-option bundle-id --description 'Shows the app bundle ID' 44 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 45 | --short-option p --long-option path --description 'Shows the app path' 46 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 47 | --short-option n --long-option name --description 'Shows the app name' 48 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 49 | --short-option P --long-option pid --description 'Shows the PID of the app' 50 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 51 | --short-option a --long-option all --description 'Shows all details' 52 | complete --command app --condition '__fish_seen_subcommand_from 'frontmost \ 53 | --short-option h --long-option help --description 'Help for app 'frontmost 54 | 55 | complete --command app --condition '__fish_seen_subcommand_from 'icon \ 56 | --short-option x --long-option exact --description 'Exact matches only' 57 | complete --command app --condition '__fish_seen_subcommand_from 'icon \ 58 | --short-option o --long-option output --description 'Extracts to this file or directory' \ 59 | --force-files 60 | complete --command app --condition '__fish_seen_subcommand_from 'icon \ 61 | --short-option w --long-option width --description 'Uses this pixel width' \ 62 | --no-files 63 | complete --command app --condition '__fish_seen_subcommand_from 'icon \ 64 | --short-option h --long-option help --description 'Help for app 'icon 65 | 66 | complete --command app --condition '__fish_seen_subcommand_from 'quit \ 67 | --short-option x --long-option exact --description 'Exact matches only' 68 | complete --command app --condition '__fish_seen_subcommand_from 'quit \ 69 | --short-option r --long-option restart --description 'Restart after quit' 70 | complete --command app --condition '__fish_seen_subcommand_from 'quit \ 71 | --short-option h --long-option help --description 'Help for app 'quit 72 | -------------------------------------------------------------------------------- /completions/finder.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/completions/finder.fish:v7.0.1 2 | 3 | complete --command finder --erase 4 | 5 | complete --command finder --arguments track \ 6 | --exclusive --condition __fish_use_subcommand \ 7 | --description 'Enables Finder PWD tracking' 8 | complete --command finder --arguments untrack \ 9 | --exclusive --condition __fish_use_subcommand \ 10 | --description 'Disables Finder PWD tracking' 11 | complete --command finder --arguments pwd \ 12 | --exclusive --condition __fish_use_subcommand \ 13 | --description 'Prints the path of the Finder window' 14 | complete --command finder --arguments cd \ 15 | --exclusive --condition __fish_use_subcommand \ 16 | --description 'Changes to the path of the Finder window' 17 | complete --command finder --arguments pushd \ 18 | --exclusive --condition __fish_use_subcommand \ 19 | --description 'Pushes to the path of the Finder window' 20 | complete --command finder --arguments update \ 21 | --exclusive --condition __fish_use_subcommand \ 22 | --description 'Updates the Finder to PWD' 23 | complete --command finder --arguments list \ 24 | --exclusive --condition __fish_use_subcommand \ 25 | --description 'Sets Finder to list view with PWD' 26 | complete --command finder --arguments icon \ 27 | --exclusive --condition __fish_use_subcommand \ 28 | --description 'Sets Finder to icon view with PWD' 29 | complete --command finder --arguments column \ 30 | --exclusive --condition __fish_use_subcommand \ 31 | --description 'Sets Finder to column view with PWD' 32 | complete --command finder --arguments hidden \ 33 | --exclusive --condition __fish_use_subcommand \ 34 | --description 'Shows or hides `hidden` files' 35 | complete --command finder --arguments desktop-icons \ 36 | --exclusive --condition __fish_use_subcommand \ 37 | --description 'Shows or hides desktop icons' 38 | complete --command finder --arguments clean \ 39 | --exclusive --condition __fish_use_subcommand \ 40 | --description 'Cleans .DS_Store files' 41 | complete --command finder --arguments quarantine \ 42 | --exclusive --condition __fish_use_subcommand \ 43 | --description 'Works with file quarantine data' 44 | complete --command finder --arguments selected \ 45 | --exclusive --condition __fish_use_subcommand \ 46 | --description 'Print Finder selected files' 47 | 48 | for subcommand in cd clean column desktop-icons hidden icon list pushd pwd quarantine selected track untrack update 49 | complete --command finder --condition '__fish_seen_subcommand_from '$subcommand \ 50 | --short-option h --long-option help --description 'Help for finder '$subcommand 51 | end 52 | 53 | for subcommand in hidden desktop-icons 54 | complete --command finder --condition '__fish_seen_subcommand_from '$subcommand \ 55 | --arguments off --description 'Turns '$subcommand' off' 56 | complete --command finder --condition '__fish_seen_subcommand_from '$subcommand \ 57 | --arguments on --description 'Turns '$subcommand' on' 58 | complete --command finder --condition '__fish_seen_subcommand_from '$subcommand \ 59 | --arguments toggle --description 'Toggles '$subcommand 60 | complete --command finder --condition '__fish_seen_subcommand_from '$subcommand \ 61 | --arguments status --description 'Shows the status of '$subcommand 62 | end 63 | 64 | complete --command finder --condition '__fish_seen_subcommand_from 'quarantine \ 65 | --arguments show --description 'Shows quarantine events' 66 | complete --command finder --condition '__fish_seen_subcommand_from 'quarantine \ 67 | --arguments clear --description 'Clears all quarantine events' 68 | complete --command finder --condition '__fish_seen_subcommand_from 'quarantine \ 69 | --arguments clean --description 'Removes 'quarantine' attributes from files' \ 70 | --require-parameter --force-files 71 | -------------------------------------------------------------------------------- /completions/mac.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/completions/mac.fish:v7.0.1 2 | 3 | complete --command mac --erase 4 | 5 | complete --command mac --arguments airdrop \ 6 | --exclusive --condition __fish_use_subcommand \ 7 | --description 'Changes AirDrop settings' 8 | complete --command mac --arguments airport \ 9 | --exclusive --condition __fish_use_subcommand \ 10 | --description 'Work with AirPort (WiFi) settings' 11 | complete --command mac --arguments brightness \ 12 | --exclusive --condition __fish_use_subcommand \ 13 | --description 'Adjust the screen brightness level' 14 | complete --command mac --arguments flushdns \ 15 | --exclusive --condition __fish_use_subcommand \ 16 | --description 'Flushes DNS' 17 | complete --command mac --arguments font-smoothing \ 18 | --exclusive --condition __fish_use_subcommand \ 19 | --description 'Manages font smoothing settings' 20 | complete --command mac --arguments lsclean \ 21 | --exclusive --condition __fish_use_subcommand \ 22 | --description 'Cleans LaunchServices to remove duplicate Open with... entries' 23 | complete --command mac --arguments mail \ 24 | --exclusive --condition __fish_use_subcommand \ 25 | --description 'Manage various operations of Mail.app' 26 | complete --command mac --arguments proxy-icon \ 27 | --exclusive --condition __fish_use_subcommand \ 28 | --description 'Manage proxy icon appearance delay' 29 | complete --command mac --arguments transparency \ 30 | --exclusive --condition __fish_use_subcommand \ 31 | --description 'Manage UI transparency' 32 | complete --command mac --arguments vol \ 33 | --exclusive --condition __fish_use_subcommand \ 34 | --description 'Changes Mac volume; accepts 0–100 volume percentage' 35 | 36 | for subcommand in airdrop airport brightness flushdns font-smoothing lsclean mail proxy-icon transparency version vol 37 | complete --command mac --condition '__fish_seen_subcommand_from '$subcommand \ 38 | --short-option h --long-option help --description 'Help for mac '$subcommand 39 | end 40 | 41 | complete --command mac --condition '__fish_seen_subcommand_from brightness' \ 42 | --arguments up --description 'Increases screen brightness' 43 | complete --command mac --condition '__fish_seen_subcommand_from brightness' \ 44 | --arguments down --description 'Decreases screen brightness' 45 | 46 | for subcommand in airdrop proxy-icon transparency 47 | complete --command mac --condition '__fish_seen_subcommand_from '$subcommand \ 48 | --arguments on --description 'Enables '$subcommand 49 | complete --command mac --condition '__fish_seen_subcommand_from '$subcommand \ 50 | --arguments off --description 'Disables '$subcommand 51 | complete --command mac --condition '__fish_seen_subcommand_from '$subcommand \ 52 | --arguments toggle --description 'Toggles '$subcommand 53 | complete --command mac --condition '__fish_seen_subcommand_from '$subcommand \ 54 | --arguments status --description 'Shows the status of '$subcommand 55 | end 56 | 57 | 58 | complete --command mac --condition '__fish_seen_subcommand_from 'airport \ 59 | --arguments scan --description 'Shows available networks' 60 | complete --command mac --condition '__fish_seen_subcommand_from 'airport \ 61 | --arguments ssid --description 'Shows the SSID' 62 | complete --command mac --condition '__fish_seen_subcommand_from 'airport \ 63 | --arguments password --description 'Gets the current WiFi network password' 64 | 65 | 66 | complete --command mac --condition '__fish_seen_subcommand_from 'font-smoothing \ 67 | --arguments on --description 'Enables font smoothing; app IDs can be provided to limit control' 68 | complete --command mac --condition '__fish_seen_subcommand_from 'font-smoothing \ 69 | --arguments off --description 'Disables font smoothing; app IDs can be provided to limit control' 70 | 71 | complete --command mac --condition '__fish_seen_subcommand_from 'mail \ 72 | --arguments vacuum --description 'Vacuums the Mail.app envelope index' 73 | complete --command mac --condition '__fish_seen_subcommand_from 'mail \ 74 | --arguments attachments --description 'Sets Mail.app attachment handling' \ 75 | --require-parameter --no-files 76 | complete --command mac --condition '__fish_seen_subcommand_from 'attachments \ 77 | --arguments inline \ 78 | --description 'Sets Mail.app attachment handling so that they are inline to the message' 79 | complete --command mac --condition '__fish_seen_subcommand_from 'attachments \ 80 | --arguments icon \ 81 | --description 'Sets Mail.app attachment handling so that they are icons on the message' 82 | 83 | complete --command mac --condition '__fish_seen_subcommand_from 'version \ 84 | --short-option s --long-option simple --description 'Simple mac version name' 85 | complete --command mac --condition '__fish_seen_subcommand_from 'version \ 86 | --short-option l --long-option lowercase --description 'Lowercase mac version name' 87 | complete --command mac --condition '__fish_seen_subcommand_from 'version \ 88 | --short-option f --long-option version --description 'Full version number' 89 | complete --command mac --condition '__fish_seen_subcommand_from 'version \ 90 | --short-option c --long-option comparable --description 'Simplified comparable version value' 91 | complete --command mac --condition '__fish_seen_subcommand_from 'version \ 92 | --short-option h --long-option help --description 'Help for mac 'version 93 | 94 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 95 | --arguments mute --description 'Mutes volume' 96 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 97 | --arguments unmute --description 'Unmutes volume' 98 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 99 | --arguments show --description 'Shows the current volume' 100 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 101 | --arguments 10 --description 'Sets the volume to 10%' 102 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 103 | --arguments 20 --description 'Sets the volume to 20%' 104 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 105 | --arguments 30 --description 'Sets the volume to 30%' 106 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 107 | --arguments 40 --description 'Sets the volume to 40%' 108 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 109 | --arguments 50 --description 'Sets the volume to 50%' 110 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 111 | --arguments 60 --description 'Sets the volume to 60%' 112 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 113 | --arguments 70 --description 'Sets the volume to 70%' 114 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 115 | --arguments 80 --description 'Sets the volume to 80%' 116 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 117 | --arguments 90 --description 'Sets the volume to 90%' 118 | complete --command mac --condition '__fish_seen_subcommand_from 'vol \ 119 | --arguments 100 --description 'Sets the volume to 100%' 120 | -------------------------------------------------------------------------------- /completions/manp.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/completions/manp.fish:v7.0.1 2 | 3 | complete --command manp --erase 4 | complete --command manp --wraps man 5 | complete --command manp --exclusive --condition __fish_no_arguments \ 6 | --short-option h --long-option help --description 'Show help for manp' 7 | complete --command manp --exclusive --condition __fish_no_arguments \ 8 | --long-option clear-cache --description 'Clear the man page PDF cache' 9 | -------------------------------------------------------------------------------- /completions/ql.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/completions/ql.fish:v7.0.1 2 | 3 | complete --erase --command ql 4 | complete --command ql --wraps qlmanage 5 | -------------------------------------------------------------------------------- /conf.d/halostatue_fish_macos.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/conf.d/halostatue_fish_macos.fish:v7.0.1 2 | 3 | function _halostatue_fish_macos_uninstall -e halostatue_fish_macos_uninstall 4 | set --function functions app finder has_app mac manp note ql remind 5 | 6 | for cmd in $functions 7 | complete --erase --command $cmd 8 | end 9 | 10 | set --append functions (status function) \ 11 | (functions --all | string match --entire --regex '^__macos_app_|^__macos_finder_|^__macos_mac_') 12 | 13 | functions --erase $functions 14 | end 15 | -------------------------------------------------------------------------------- /functions/__macos_app_bundleid.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_app_bundleid.fish:v7.0.1 2 | 3 | function __macos_app_bundleid 4 | argparse --name 'app bundleid' x/exact a/all h/help q/quiet s/short -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: app bundleid [options] pattern... 9 | 10 | Shows the bundle identifier for each of the applications found for the 11 | pattern (see `app find` for how applications are found). 12 | 13 | Options: 14 | -x, --exact Perform exact matches only 15 | -a, --all Show all matches 16 | -q, --quiet Suppress error output 17 | -s, --short Prints out the bundle IDs only 18 | -h, --help Show this help 19 | 20 | Examples: 21 | > app bundleid 1password 22 | /Applications/1Password for Safari.app: com.1password.safari 23 | /Applications/1Password.app: com.1password.1password 24 | 25 | > app bundleid -x 1password 26 | /Applications/1Password.app: com.1password.1password' 27 | return 0 28 | end 29 | 30 | if test (count $argv) -eq 0 31 | echo >&2 'app bundleid: Not enough arguments.' 32 | __macos_app_bundleid --help >&2 33 | return 1 34 | end 35 | 36 | set --function apps (__macos_app_find $_flag_exact $_flag_all $argv) 37 | or return 1 38 | 39 | for app in $apps 40 | set --local bundle_id (mdls -name kMDItemCFBundleIdentifier -r $app) 41 | 42 | if test -z $bundle_id 43 | set --query _flag_quiet 44 | or echo >&2 'Error getting bundle ID for "'$app'"' 45 | else 46 | if set --query _flag_short 47 | echo $bundle_id 48 | else 49 | echo $app: $bundle_id 50 | end 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /functions/__macos_app_find.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_app_find.fish:v7.0.1 2 | 3 | function __macos_app_find 4 | argparse --name 'app find' x/exact a/all q/quiet h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: app find [options] pattern... 9 | 10 | Shows installed apps by the provided pattern or patterns. Searches for 11 | apps in /Applications, /Applications/Setapp, /Applications/Utilities, 12 | ~/Applications, /Appliciations/Xcode.app/Contents/Applications, 13 | /Developer/Applications, and /System/Applications. 14 | 15 | Options: 16 | -x, --exact Perform exact matches only 17 | -a, --all Show all matches 18 | -q, --quiet Do not print matches 19 | -h, --help Show this help 20 | 21 | Examples: 22 | > app find --all 1password 23 | /Applications/1Password for Safari.app 24 | /Applications/1Password.app 25 | 26 | > app find --exact 1password 27 | /Applications/1Password.app' 28 | return 0 29 | end 30 | 31 | if test (count $argv) -eq 0 32 | echo >&2 'app find: Not enough arguments.' 33 | __macos_app_find --help >&2 34 | return 1 35 | end 36 | 37 | set --function a Applications 38 | set --function paths \ 39 | /$a \ 40 | ~/$a \ 41 | /$a/Setapp \ 42 | /$a/Utilities \ 43 | /$a/Xcode.app/Contents/$a \ 44 | /Developer/Applications \ 45 | /System/Applications 46 | 47 | set --function found 0 48 | 49 | for pattern in $argv 50 | set pattern (string replace '\.app/?$' '' $pattern) 51 | set --local apps {$paths}/*.app {$paths}/*.localized/*.app 52 | for candidate in $apps 53 | set --local found_item 0 54 | 55 | if set --query _flag_exact 56 | if string match --ignore-case --entire --quiet /$pattern.app $candidate 57 | set found_item 1 58 | end 59 | else if string match --ignore-case --entire --quiet $pattern $candidate 60 | set found_item 1 61 | end 62 | 63 | if test $found_item -eq 1 64 | set --query _flag_quiet 65 | or echo $candidate 66 | 67 | set found (math $found + $found_item) 68 | 69 | set --query _flag_quiet 70 | and return 0 71 | 72 | set --query _flag_all 73 | or return 0 74 | end 75 | 76 | end 77 | end 78 | 79 | test $found -gt 0 80 | and return 0 81 | 82 | set --query _flag_quiet 83 | or echo >&2 'No applications found.' 84 | return 1 85 | end 86 | -------------------------------------------------------------------------------- /functions/__macos_app_frontmost.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_app_frontmost.fish:v7.0.1 2 | 3 | function __macos_app_frontmost::info 4 | set --function value (lsappinfo info -only $argv[2] $argv[1] | string split =)[2] 5 | or return 1 6 | 7 | string replace --all '"' '' $value 8 | return 0 9 | end 10 | 11 | function __macos_app_frontmost 12 | argparse --name 'app frontmost' \ 13 | h/help b/bundle-id p/path n/name P/pid a/all \ 14 | -- $argv 15 | or return 1 16 | 17 | if set --query _flag_help 18 | echo 'Usage: app frontmost [options] 19 | 20 | Retrieves details about the front-most application. 21 | 22 | Options: 23 | -b, --bundle-id Shows the app bundle ID 24 | -p, --path Shows the app path 25 | -n, --name Shows the app name 26 | -P, --pid Shows the PID of the app 27 | -a, --all Shows all details 28 | -h, --help Show this help 29 | 30 | Example: 31 | > app frontmost 32 | iTerm2' 33 | return 0 34 | end 35 | 36 | set --function front (lsappinfo front) 37 | or return 1 38 | 39 | set --function items 0 40 | 41 | if set --query _flag_all 42 | set items 4 43 | else 44 | set --query _flag_bundle_id _flag_path _flag_name _flag_pid 45 | set --local missing $status 46 | 47 | switch $missing 48 | case 0 49 | set _flag_all 1 50 | set items 4 51 | case 4 52 | set _flag_name 1 53 | set items 1 54 | case '*' 55 | set items (math 4 - $missing) 56 | end 57 | end 58 | 59 | if set --query _flag_name || set --query _flag_all 60 | set --function name (__macos_app_frontmost::info $front name) 61 | or return 1 62 | end 63 | 64 | if set --query _flag_bundle_id || set --query _flag_all 65 | set --function bundle_id (__macos_app_frontmost::info $front bundleID) 66 | or return 1 67 | end 68 | 69 | if set --query _flag_path || set --query _flag_all 70 | set --function bundle_path (__macos_app_frontmost::info $front bundlepath) 71 | or return 1 72 | end 73 | 74 | if set --query _flag_pid || set --query _flag_all 75 | set --function pid (__macos_app_frontmost::info $front pid) 76 | or return 1 77 | end 78 | 79 | if set --query _flag_all 80 | printf "%s: %s %s (%s)\n" $name $bundle_id $bundle_path $pid 81 | else 82 | if set --query _flag_name 83 | printf "%s" $name 84 | test $items -gt 1 && printf ": " 85 | set items (math $items - 1) 86 | end 87 | 88 | if set --query _flag_bundle_id 89 | printf "%s" $bundle_id 90 | test $items -gt 1 && printf " " 91 | set items (math $items - 1) 92 | end 93 | 94 | if set --query _flag_path 95 | printf "%s" $bundle_path 96 | test $items -gt 1 && printf " " 97 | set items (math $items - 1) 98 | end 99 | 100 | if set --query _flag_pid 101 | if test $items -gt 1 102 | printf "(%s)" $pid 103 | else 104 | printf "%s" $pid 105 | end 106 | end 107 | 108 | printf "\n" 109 | end 110 | end 111 | -------------------------------------------------------------------------------- /functions/__macos_app_icon.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_app_icon.fish:v7.0.1 2 | 3 | function __macos_app_icon 4 | argparse --name 'app quit' x/exact h/help 'o/output=' 'w/width=' -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: app icon [options] pattern... 9 | 10 | Extracts macOS app icons as PNG (see `app find` for how applications 11 | are found). 12 | 13 | Options: 14 | -x, --exact Perform exact matches only 15 | -oOUTPUT Output to the file or directory specified 16 | --output OUTPUT Output to the file or directory specified 17 | -wWIDTH Outputs to a maximum of WIDTH pixels 18 | --width WIDTH Outputs to a maximum of WIDTH pixels 19 | -h, --help Show this help' 20 | return 0 21 | end 22 | 23 | if test (count $argv) -eq 0 24 | echo >&2 'app icon: Not enough arguments.' 25 | __macos_app_icon --help >&2 26 | return 1 27 | end 28 | 29 | 30 | if set --query _flag_exact 31 | set --function apps (__macos_app_find --exact $argv) 32 | or return 1 33 | else 34 | set --function apps (__macos_app_find --all $argv) 35 | or return 1 36 | end 37 | 38 | set --function app_count (count $apps) 39 | 40 | set --function output_path $PWD 41 | if not test -z $_flag_output 42 | if test -e $_flag_output 43 | if test -f $_flag_output 44 | if test $app_count -gt 1 45 | echo >&2 'app icon: More than one application found, but only one output file specified.' 46 | return 1 47 | end 48 | 49 | set output_path (dirname $_flag_output) 50 | set output_file (basename $_flag_output) 51 | else if test -d $_flag_output 52 | set output_path $_flag_output 53 | else 54 | echo >&2 'app icon: Output to a non-file or directory specified.' 55 | return 1 56 | end 57 | else 58 | set output_path $_flag_output 59 | mkdir -p $output_path 60 | end 61 | end 62 | 63 | for app in $apps 64 | set --local icon $app/Contents/Resources/( 65 | defaults read $app/Contents/Info CFBundleIconFile | 66 | string replace --regex '\.icns$' '' 67 | ).icns 68 | 69 | set --local name (basename $app .app)_icon.png 70 | set --local tmp $TMPDIR/$name 71 | set --local max_width (sips -g pixelWidth $icon | tail -1 | awk '{ print $2; }') 72 | 73 | set --local outfile 74 | set --local width 75 | 76 | if test -z $output_file 77 | set outfile $output_path/$name 78 | else 79 | set outfile $output_path/$output_file 80 | end 81 | 82 | if test -z $_flag_width 83 | set width $max_width 84 | else if test $_flag_width -gt $max_width 85 | set width $max_width 86 | else 87 | set width $_flag_width 88 | end 89 | 90 | sips -s format png --resampleHeightWidthMax $width $icon --out $outfile >/dev/null 2>&1 91 | 92 | echo Wrote $app icon to $outfile. 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /functions/__macos_app_quit.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_app_quit.fish:v7.0.1 2 | 3 | function __macos_app_quit 4 | argparse --name 'app quit' x/exact r/restart h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: app quit [options] pattern... 9 | 10 | Quits apps identified by the provided pattern or patterns (see 11 | `app find` for how applications are found). 12 | 13 | Options: 14 | -x, --exact Quits only applications with exact matches 15 | -r, --restart Restarts the application that was quit 16 | -h, --help Show this help' 17 | return 0 18 | end 19 | 20 | if test (count $argv) -eq 0 21 | echo >&2 'app bundleid: Not enough arguments.' 22 | __macos_app_quit --help >&2 23 | return 1 24 | end 25 | 26 | if set --query _flag_exact 27 | set --function apps (__macos_app_find --exact $argv) 28 | or return 1 29 | else 30 | set --function apps (__macos_app_find --all $argv) 31 | or return 1 32 | end 33 | 34 | for app in $apps 35 | printf 'quit app "%s"' $app | osascript >/dev/null 36 | 37 | if set --query _flag_restart 38 | sleep 2 39 | open -a $app 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /functions/__macos_finder_cd.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_cd.fish:v7.0.1 2 | 3 | function __macos_finder_cd 4 | argparse --name 'finder cd' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder cd [options] [window#] 9 | 10 | Changes the current path to the path of the Finder window. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | cd (__macos_finder_pwd::get $argv[1]) 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_clean.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_clean.fish:v7.0.1 2 | 3 | function __macos_finder_clean 4 | argparse --name 'finder clean' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder clean [options] [path...] 9 | 10 | Removes .DS_Store files from the paths provided, or the current path if 11 | one is not provided. 12 | 13 | Options: 14 | -h, --help Show this help' 15 | return 0 16 | end 17 | 18 | if set --query argv[1] 19 | set --function paths $argv 20 | else 21 | set --function paths . 22 | end 23 | 24 | for path in $paths 25 | test -d $path 26 | or continue 27 | 28 | find $path -type f -name '*.DS_Store' -ls -delete 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /functions/__macos_finder_column.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_column.fish:v7.0.1 2 | 3 | function __macos_finder_column 4 | argparse --name 'finder column' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder column [options] [window#] 9 | 10 | Updates the Finder window to PWD using column view. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | __macos_finder_pwd::update --column $argv 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_desktop_icons.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_desktop_icons.fish:v7.0.1 2 | 3 | function __macos_finder_desktop_icons 4 | argparse --name 'finder desktop-icons' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder desktop-icons [options] STATE 9 | 10 | Shows or hides the desktop icons. If not specified, shows the current state. 11 | 12 | States: 13 | off Hides the desktop icons 14 | on Shows the desktop icons 15 | [status] Shows desktop icon visibility 16 | toggle Toggles desktop icon visibility 17 | 18 | Options: 19 | -h, --help Show this help' 20 | return 0 21 | end 22 | 23 | set --function action (string lower -- $argv[1]) 24 | set --function key CreateDesktop 25 | 26 | switch $action 27 | case off 28 | __macos_finder_defaults::set $key false 29 | case on 30 | __macos_finder_defaults::set $key true 31 | case toggle 32 | if test (__macos_mac_defaults_query com.apple.Finder $key 1) -eq 1 33 | __macos_finder_defaults::set $key false 34 | else 35 | __macos_finder_defaults::set $key true 36 | end 37 | case status '' 38 | if test (__macos_mac_defaults_query com.apple.Finder $key 1) -eq 1 39 | echo 'Desktop icons are hidden.' 40 | else 41 | echo 'Desktop icons are visible.' 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /functions/__macos_finder_hidden.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_hidden.fish:v7.0.1 2 | 3 | function __macos_finder_hidden 4 | argparse --name 'finder hidden' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder hidden [options] STATE 9 | 10 | Shows or hides files that are normally hidden from the Finder. If not 11 | specified, shows the current state. 12 | 13 | States: 14 | off Hides files that are normally hidden from the Finder 15 | on Shows files that are normally hidden from the Finder 16 | [status] Shows the status of the hidden files setting 17 | toggle Toggles the hidden files setting 18 | 19 | Options: 20 | -h, --help Show this help' 21 | return 0 22 | end 23 | 24 | set --function action (string lower -- $argv[1]) 25 | set --function key AppleShowAllFiles 26 | 27 | switch $action 28 | case off 29 | __macos_finder_defaults::set $key false 30 | case on 31 | __macos_finder_defaults::set $key true 32 | case toggle 33 | if test (__macos_mac_defaults_query com.apple.Finder $key 0) -eq 1 34 | __macos_finder_defaults::set $key false 35 | else 36 | __macos_finder_defaults::set $key true 37 | end 38 | case status '' 39 | if test (__macos_mac_defaults_query com.apple.Finder $key 0) -eq 1 40 | echo 'Hidden files are visible in finder.' 41 | else 42 | echo 'Hidden files are hidden in finder.' 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /functions/__macos_finder_icon.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_icon.fish:v7.0.1 2 | 3 | function __macos_finder_icon 4 | argparse --name 'finder icon' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder icon [options] [window#] 9 | 10 | Updates the Finder window to PWD using icon view. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | __macos_finder_pwd::update --icon $argv 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_list.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_list.fish:v7.0.1 2 | 3 | function __macos_finder_list 4 | argparse --name 'finder list' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder list [options] [window#] 9 | 10 | Updates the Finder window to PWD using list view. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | __macos_finder_pwd::update --list $argv 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_pushd.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_pushd.fish:v7.0.1 2 | 3 | function __macos_finder_pushd 4 | argparse --name 'finder pushd' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder pushd [options] [window#] 9 | 10 | Changes the current path to the path of the Finder window with pushd. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | pushd (__macos_finder_pwd::get $argv[1]) 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_pwd.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_pwd.fish:v7.0.1 2 | 3 | function __macos_finder_pwd 4 | argparse --name 'finder pwd' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder pwd [options] [window#] 9 | 10 | Prints the path of the Finder window. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | __macos_finder_pwd::get $argv[1] 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_quarantine.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_quarantine.fish:v7.0.1 2 | 3 | function __macos_finder_quarantine::run 4 | set --query argv[1] 5 | or return 1 6 | 7 | set --function databases ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 8 | set --function cmd sqlite3 -separator ' | ' 9 | 10 | for db in $databases 11 | $cmd $db $argv 12 | end 13 | end 14 | 15 | function __macos_finder_quarantine 16 | argparse --name 'finder quarantine' h/help -- $argv 17 | or return 1 18 | 19 | if set --query _flag_help 20 | echo 'Usage: finder [options] [SUBCOMMAND] [FILE...] 21 | 22 | Manage quarantine events. 23 | 24 | Subcommands: 25 | [show] Shows quarantine events by agent and URL. 26 | clean FILE... Removes quarantine attributes from the specified file(s). 27 | At least one file is required. 28 | clear Clears all quarantine events. 29 | 30 | Options: 31 | -h, --help Show this help' 32 | return 0 33 | end 34 | 35 | set --function verb (string lower -- $argv[1]) 36 | set --erase argv[1] 37 | 38 | switch $verb 39 | case show '' 40 | __macos_finder_quarantine::run " 41 | SELECT LSQuarantineAgentName, LSQuarantineDataURLString 42 | FROM LSQuarantineEvent 43 | WHERE LSQuarantineDataURLString != '' 44 | ORDER BY LSQuarantineAgentName, LSQuarantineDataURLString;" 45 | case clear 46 | __macos_finder_quarantine::run 'DELETE FROM LSQuarantineEvent;' 47 | case clean 48 | if not set --query argv[1] 49 | echo >&2 'finder quarantine clean requires at least one file parameter' 50 | return 1 51 | end 52 | 53 | for attr in com.apple.{metadata:{kMDItemDownloadedDate,kMDItemWhereFroms},quarantine} 54 | xattr -r -d $attr $argv 55 | end 56 | case '*' 57 | echo >&2 "finder quarantine: unknown command '"$verb"'. Use 'show', 'clear', or 'clean'." 58 | return 1 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /functions/__macos_finder_selected.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_selected.fish:v7.0.1 2 | 3 | function __macos_finder_selected 4 | argparse --name 'finder selected' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder selected [options] [window#] 9 | 10 | Print the selected files on the command-line. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | echo ' 18 | tell application "Finder" to set theSelection to selection 19 | set output to "" 20 | set itemCount to count theSelection 21 | repeat with itemIndex from 1 to itemCount 22 | if itemIndex is less than itemCount then set theDelimiter to "\n" 23 | if itemIndex is itemCount then set theDelimiter to "" 24 | set currentItem to (item itemIndex of theSelection as alias) 25 | set currentItem to POSIX path of currentItem 26 | set output to output & currentItem & theDelimiter 27 | end repeat' | osascript 28 | end 29 | -------------------------------------------------------------------------------- /functions/__macos_finder_track.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_track.fish:v7.0.1 2 | 3 | function __macos_finder_track 4 | argparse --name 'finder track' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder track [options] 9 | 10 | Makes the first Finder window track with the shell PWD. This should be used 11 | in a single shell instance only, and updates only when the PWD value is 12 | updated. 13 | 14 | Options: 15 | -h, --help Show this help' 16 | return 0 17 | end 18 | 19 | if not functions --query __macos_finder_tracking 20 | function __macos_finder_tracking --on-variable PWD 21 | __macos_finder_pwd::update 22 | end 23 | end 24 | 25 | __macos_finder_pwd::update 26 | end 27 | -------------------------------------------------------------------------------- /functions/__macos_finder_untrack.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_untrack.fish:v7.0.1 2 | 3 | function __macos_finder_untrack 4 | argparse --name 'finder untrack' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder untrack [options] 9 | 10 | Unlinks the shell PWD from the first Finder window. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | functions --erase __macos_finder_tracking 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_finder_update.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_finder_update.fish:v7.0.1 2 | 3 | function __macos_finder_update 4 | argparse --name 'finder update' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: finder update [options] [window#] 9 | 10 | Updates the Finder window to PWD. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | __macos_finder_pwd::update $argv 18 | end 19 | -------------------------------------------------------------------------------- /functions/__macos_mac_airdrop.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_airdrop.fish:v7.0.1 2 | 3 | function __macos_mac_airdrop 4 | argparse --name 'mac airdrop' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac airdrop STATE 9 | 10 | Turns AirDrop on or off. Requires administrative permissions and 11 | executes with sudo. 12 | 13 | States: 14 | off Disables AirDrop. 15 | on Enables AirDrop. 16 | [status] Shows the status of AirDrop. 17 | toggle Toggles the status of AirDrop. 18 | 19 | Options: 20 | -h, --help Show this help' 21 | return 0 22 | end 23 | 24 | set --function subcommand (string lower -- $argv[1]) 25 | set --erase argv[1] 26 | 27 | switch $subcommand 28 | case on 29 | sudo ifconfig awdl0 up 30 | case off 31 | sudo ifconfig awdl0 down 32 | case status '' 33 | ifconfig awdl0 | awk '/status:/ { print $2; }' 34 | case toggle 35 | if test (__macos_mac_airdrop status) == active 36 | __macos_mac_airdrop off 37 | else 38 | __macos_mac_airdrop on 39 | end 40 | case '*' 41 | echo >&2 'mac airdrop: unknown state.' 42 | __macos_mac_airdrop --help >&2 43 | return 1 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /functions/__macos_mac_airport.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_airport.fish:v7.0.1 2 | 3 | function __macos_mac_airport::ssid 4 | __macos_mac_airport::run -I | string replace --filter --regex '\s+SSID: (\S+)' '$1' 5 | end 6 | 7 | function __macos_mac_airport::run 8 | /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport \ 9 | $argv 10 | end 11 | 12 | function __macos_mac_airport 13 | argparse --name 'mac airport' h/help -- $argv 14 | or return 1 15 | 16 | if set --query _flag_help 17 | echo 'Usage: mac airport STATE 18 | mac airport SUBCOMMAND [SSID] 19 | 20 | Performs various WiFi (AirPort) operations. If no state or subcommand is 21 | provided, the scan subcommand will be run by default. Otherwise a state (off, 22 | on, toggle) or a subcommand must be provided. 23 | 24 | States: 25 | off Disables the WiFi adapter. 26 | on Enables the WiFi adapter. 27 | toggle Toggles the status of the WiFi adapter. 28 | 29 | Subcommands: 30 | password [SSID] Shows the password of the current or specified SSID. 31 | scan Scans for WiFi networks.. 32 | ssid Shows the current WiFi network SSID. 33 | status Shows the status of the WiFi adapter. 34 | 35 | Options: 36 | -h, --help Show this help' 37 | return 0 38 | end 39 | 40 | set --function cmd (string lower -- $argv[1]) 41 | set --erase argv[1] 42 | 43 | switch $cmd 44 | case scan '' 45 | printf "Scanning...\r" 46 | __macos_mac_airport::run -s 47 | case network ssid 48 | __macos_mac_airport::ssid 49 | case off 50 | networksetup -setairportpower en0 off 51 | case on 52 | networksetup -setairportpower en0 on 53 | case status 54 | networksetup -getairportpower en0 | string replace --regex '^[^:]+: ' '' | string lower 55 | case toggle 56 | if test (__macos_mac_airport status) == on 57 | __macos_mac_airport off 58 | else 59 | __macos_mac_airport on 60 | end 61 | case password 62 | set --local ssid 63 | if set --query argv[1] 64 | set ssid $argv[1] 65 | else 66 | set ssid (__macos_mac_airport::ssid) 67 | end 68 | 69 | security find-generic-password -D "AirPort network password" -l $ssid -gw 70 | case '*' 71 | echo >&2 'mac airport: Unknown command.' 72 | __macos_mac_airport --help >&2 73 | return 1 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /functions/__macos_mac_brightness.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_brightness.fish:v7.0.1 2 | 3 | function __macos_mac_brightness 4 | argparse --name 'mac brightness' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac brightness [options] DIRECTION 9 | 10 | Adjust the screen brightness level. 11 | 12 | Direction: 13 | up Increases the screen brightness level. 14 | down Decreases the screen brightness level. 15 | 16 | Options: 17 | -h, --help Show this help' 18 | return 0 19 | end 20 | 21 | set --function direction (string lower -- $argv[1]) 22 | set --erase argv[1] 23 | 24 | switch $direction 25 | case down 26 | echo 'tell application "System Events" 27 | key code 145 28 | end tell' | osascript >/dev/null 29 | case up '' 30 | echo 'tell application "System Events" 31 | key code 144 32 | end tell' | osascript >/dev/null 33 | case '*' 34 | echo >&2 'mac brightness: Unknown direction' 35 | __macos_mac_brightness --help >&2 36 | return 1 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /functions/__macos_mac_defaults_query.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_defaults_query.fish:v7.0.1 2 | 3 | function __macos_mac_defaults_query 4 | if set --function value (defaults read $argv[1] $argv[2] 2>/dev/null) 5 | echo $value 6 | else 7 | echo $argv[3] 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /functions/__macos_mac_flushdns.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_flushdns.fish:v7.0.1 2 | 3 | function __macos_mac_flushdns 4 | argparse --name 'mac flushdns' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac flushdns [options] 9 | 10 | Flushes the DNS cache. Requires sudo. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | sudo dscacheutil -flushcache 18 | and sudo killall -HUP mDNSResponder 19 | end 20 | -------------------------------------------------------------------------------- /functions/__macos_mac_font_smoothing.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_font_smoothing.fish:v7.0.1 2 | 3 | function __macos_mac_font_smoothing 4 | argparse --name 'mac font-smoothing' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac font-smoothing [options] off|on [APP...] 9 | 10 | Enables or disables font smoothing. If no apps are provided, sets the 11 | global font smoothing preference. If apps are provided, font smoothing 12 | will be set for each app. See `app bundleid` for how apps are resolved. 13 | 14 | States: 15 | off Turns off font smoothing 16 | on Turns on font smoothing 17 | 18 | Options: 19 | -h, --help Show this help' 20 | return 0 21 | end 22 | 23 | set --function state (string lower -- $argv[1]) 24 | set --erase argv[1] 25 | 26 | switch $state 27 | case on 28 | if test (count $argv) -eq 0 29 | defaults delete -g CGFontRenderingFontSmoothingDisabled 30 | else 31 | for app in (__macos_app_bundleid --exact --short --all $argv) 32 | defaults delete $app CGFontRenderingFontSmoothingDisabled 33 | 34 | if test $app = com.microsoft.VSCode 35 | defaults delete $app.helper CGFontRenderingFontSmoothingDisabled 36 | defaults delete $app.helper.EH CGFontRenderingFontSmoothingDisabled 37 | defaults delete $app.helper.NP CGFontRenderingFontSmoothingDisabled 38 | end 39 | end 40 | end 41 | 42 | case off 43 | if test (count $argv) -eq 0 44 | defaults write -g CGFontRenderingFontSmoothingDisabled -bool false 45 | else 46 | for app in (__macos_app_bundleid --exact --short --all $argv) 47 | defaults write $app CGFontRenderingFontSmoothingDisabled -bool false 48 | 49 | if test $app = com.microsoft.VSCode 50 | defaults write $app.helper CGFontRenderingFontSmoothingDisabled -bool false 51 | defaults write $app.helper.EH CGFontRenderingFontSmoothingDisabled -bool false 52 | defaults write $app.helper.NP CGFontRenderingFontSmoothingDisabled -bool false 53 | end 54 | end 55 | end 56 | 57 | case '*' 58 | echo >&2 'mac font-smoothing: Unknown state.' 59 | __macos_mac_font_smoothing --help >&2 60 | return 1 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /functions/__macos_mac_lsclean.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_lsclean.fish:v7.0.1 2 | 3 | function __macos_mac_lsclean 4 | argparse --name 'mac lsclean' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac lsclean [options] 9 | 10 | Cleans the LaunchServices registration list. 11 | 12 | Options: 13 | -h, --help Show this help' 14 | return 0 15 | end 16 | 17 | /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \ 18 | -kill -r -domain local -domain system -domain user 19 | and killall Finder 20 | end 21 | -------------------------------------------------------------------------------- /functions/__macos_mac_mail.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_mail.fish:v7.0.1 2 | 3 | # Speed up Mail.app by vacuuming the Envelope Index 4 | # - Code from: http://web.archive.org/web/20071008123746/http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/ 5 | # - Originally by "pmbuko" with modifications by Romulo 6 | # - Updated by Brett Terpstra 2012 7 | # - Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compatibility 8 | # - Updated by Andrei Miclaus 2017 to support V4 in Sierra 9 | # - Updated by Austin Ziegler 2022 to not actually care what the OS version is (and translated to fish). The only 10 | # restriction is that you must have opened Mail.app at least once on any OS upgrade so that if any version changes 11 | # have happened, Mail.app has taken care of that for you. 12 | function __macos_mac_mail 13 | argparse --name 'mac mail' h/help -- $argv 14 | or return 1 15 | 16 | if set --query _flag_help 17 | echo 'Usage: mac mail [options] SUBCOMMAND [arg] 18 | 19 | Performs operations on Mail.app configuration and database. 20 | 21 | Before running vacuum after any OS upgrade, Mail.app must have been opened 22 | at least once so that the database and index formats have been updated. 23 | 24 | Subcommands: 25 | vacuum Vacuums the envelope index to improve performance. 26 | attachments inline Sets Mail.app attachment handling to inline. 27 | attachments icon Sets Mail.app attachment handling to icon. 28 | 29 | Options: 30 | -h, --help Show this help' 31 | return 0 32 | end 33 | 34 | set --function subcommand (string lower -- $argv[1]) 35 | set --erase argv[1] 36 | 37 | switch $subcommand 38 | case vacuum 39 | set --function mail_version ( 40 | path filter --type dir ~/Library/Mail/* | 41 | path basename | 42 | string match --all --entire --regex V\\d 43 | ) 44 | set --function mail_path ~/Library/Mail/$mail_version/MailData/Envelope\ Index 45 | 46 | osascript -e 'tell application "Mail" to quit' 47 | 48 | set --function before (ls -lnah $mail_path | awk '{ print $5; }') 49 | /usr/bin/sqlite3 $mail_path vacuum 50 | set --function after (ls -lnah $mail_path | awk '{ print $5; }') 51 | 52 | printf "Mail index before: %s\nMail index after: %s\n" $before $after 53 | osascript -e 'tell application "Mail" to activate' 54 | 55 | case attachments 56 | switch (string lower -- $argv[1]) 57 | case inline 58 | defaults delete com.apple.mail DisableInlineAttachmentViewing 59 | case icon 60 | defaults write com.apple.mail DisableInlineAttachmentViewing -bool true 61 | end 62 | 63 | case '*' 64 | echo >&2 'mac mail: Unknown command.' 65 | __macos_mac_mail --help >&2 66 | return 1 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /functions/__macos_mac_proxy_icon.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_proxy_icon.fish:v7.0.1 2 | 3 | function __macos_mac_proxy_icon 4 | argparse --name 'mac proxy-icon' h/help q/query -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac proxy-icon [options] STATE 9 | 10 | Enables or disables the visibility of the proxy icon without delay. macOS 11 | versions older than Monterey always show the proxy icon. 12 | 13 | States: 14 | FLOAT Sets the display of the proxy icon to FLOAT fractional seconds. 15 | off Sets the display of the proxy icon to default. 16 | on Sets the display of the proxy icon to 0 seconds. 17 | [status] Shows the duration of the proxy icon display. 18 | toggle Toggles the display of the proxy icon. 19 | 20 | Options: 21 | -q, --query When getting status, suppresses output. 22 | -h, --help Show this help' 23 | return 0 24 | end 25 | 26 | set --function state (string lower -- $argv[1]) 27 | set --erase argv[1] 28 | 29 | switch $state 30 | case status '' 31 | set --function value (__macos_mac_defaults_query -g NSToolbarTitleViewRolloverDelay 0.5) 32 | 33 | if set --query _flag_query 34 | test $value -eq 0 35 | else if test $value -eq 0 36 | printf "immediate (0 seconds)\n" 37 | else 38 | printf "%0.2f seconds\n" $value 39 | end 40 | 41 | case toggle 42 | if __macos_mac_proxy_icon --query status 43 | __macos_mac_proxy_icon off 44 | else 45 | __macos_mac_proxy_icon on 46 | end 47 | 48 | case on 49 | defaults write -g NSToolbarTitleViewRolloverDelay -float 0 50 | and killall Finder 51 | 52 | case off 53 | defaults delete -g NSToolbarTitleViewRolloverDelay 54 | and killall Finder 55 | 56 | case '*' 57 | if string match --regex '^\\d+$|^\\d*\.\\d+$' $state 58 | defaults write -g NSToolbarTitleViewRolloverDelay -float $state 59 | and killall Finder 60 | else 61 | echo >&2 'mac proxy-icon: Unknown state.' 62 | __macos_mac_proxy_icon --help >&2 63 | return 1 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /functions/__macos_mac_serialnumber.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_serialnumber.fish:v7.0.1 2 | 3 | function __macos_mac_serialnumber 4 | argparse --name 'mac serialnumber' h/help c/copy -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac serialnumber [options] 9 | 10 | Gets the serial number for the current macOS device. 11 | 12 | Options: 13 | -c, --copy Copy to the clipboard 14 | -h, --help Show this help' 15 | return 0 16 | end 17 | 18 | set --function serial (ioreg -l | string replace --filter --regex --all '^.*"IOPlatformSerialNumber"\s+=\s+"([^"]+)"' '$1') 19 | 20 | set --query _flag_copy && echo $serial | pbcopy 21 | echo $serial 22 | end 23 | -------------------------------------------------------------------------------- /functions/__macos_mac_touchid.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_touchid.fish:v7.0.1 2 | 3 | function __macos_mac_touchid 4 | argparse --name 'mac touchid' h/help q/quiet -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac touchid SUBSYSTEM [STATE] 9 | 10 | Enables or disables Touch ID support. Requires administrative permissions 11 | and executes with sudo. 12 | 13 | Subsystems: 14 | sudo Manages Touch ID support for sudo 15 | 16 | States: 17 | off Disables Touch ID. 18 | on Enables Touch ID. 19 | [status] Shows the status of Touch ID. 20 | toggle Toggles the status of Touch ID. 21 | 22 | Options: 23 | -h, --help Show this help' 24 | return 0 25 | end 26 | 27 | set --function subsystem (string lower -- $argv[1]) 28 | set --erase argv[1] 29 | 30 | if set --query _flag_quiet 31 | set --append argv --quiet 32 | end 33 | 34 | switch $subsystem 35 | case sudo 36 | __macos_mac_touchid_sudo $argv 37 | case '*' 38 | echo >&2 'mac touchid: unknown subsystem.' 39 | __macos_mac_touchid --help >&2 40 | return 1 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /functions/__macos_mac_touchid_sudo.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_touchid_sudo.fish:v7.0.1 2 | 3 | # Massively simplified. This version _only_ works if /etc/pam.d/sudo includes `auth 4 | # include sudo_local` and requires manual removal of `pam_reattach` and `pam_tid` from 5 | # `/etc/pam.d/sudo` _manually_ if present. 6 | 7 | function __macos_mac_touchid_sudo::check_supported 8 | if string match -rq '^\s*auth\s+include\s+sudo_local$' &2 15 | printf >&2 "\n auth include sudo_local\n\n" 16 | printf >&2 "Once this has been added, try again.\n" 17 | 18 | return 1 19 | end 20 | 21 | function __macos_mac_touchid_sudo::check_old_install 22 | set --function found 23 | 24 | string match -rq '^\s*auth\s+sufficient\s+pam_tid\.so' &2 "Sudo support for "$found" present in /etc/pam.d/sudo.\n\n" 33 | echo "This is unsupported by 'mac touchid sudo' and must be manually \ 34 | removed before continuing." | fmt -s >&2 35 | 36 | return 0 37 | end 38 | 39 | return 1 40 | end 41 | 42 | function __macos_mac_touchid_sudo::print_status 43 | set --query _flag_quiet 44 | or printf "%-15s: %s\n" $argv 45 | end 46 | 47 | function __macos_mac_touchid_sudo::remove_one 48 | path is --type file --perm read /etc/pam.d/sudo_local 49 | and grep -q $argv[1] /etc/pam.d/sudo_local 50 | and sudo sed -i '' -e "/$argv[1]/d" /etc/pam.d/sudo_local 51 | end 52 | 53 | function __macos_mac_touchid_sudo::remove 54 | osascript -e 'tell application "System Preferences" to quit' 55 | 56 | for ext in pam_tid pam_reattach 57 | __macos_mac_touchid_sudo::remove_one {$ext} /etc/pam.d/sudo_local 58 | and __macos_mac_touchid_sudo::print_status $ext disabled 59 | end 60 | 61 | if ! test -s /etc/pam.d/sudo_local 62 | # If /etc/pam.d/sudo_local is empty, remove it. 63 | sudo rm -f /etc/pam.d/sudo_local 64 | end 65 | end 66 | 67 | function __macos_mac_touchid_sudo::add 68 | set --function targets 69 | 70 | test -f /etc/pam.d/sudo_local 71 | or sudo touch /etc/pam.d/sudo_local 72 | 73 | if set --query argv[1] 74 | set --function reattach $argv[1] 75 | 76 | if string match -rq '^\s*auth\s+optional\s+'$argv[1] /dev/null 105 | and begin 106 | __macos_mac_touchid_sudo::print_status pam_reattach enabled 107 | __macos_mac_touchid_sudo::print_status pam_tid enabled 108 | end 109 | else 110 | printf "%-10s %-14s %s\n" auth sufficient pam_tid.so | 111 | sudo tee -a /etc/pam.d/sudo_local >/dev/null 112 | and __macos_mac_touchid_sudo::print_status pam_tid enabled 113 | end 114 | end 115 | 116 | function __macos_mac_touchid_sudo 117 | argparse --name 'mac touchid sudo' h/help q/quiet -- $argv 118 | or return 1 119 | 120 | if set --query _flag_help 121 | echo 'Usage: mac touchid sudo [STATE] 122 | 123 | Enables or disables Touch ID support for sudo. Requires administrative 124 | permissions to edit /etc/pam.d/sudo_local and executes with sudo. 125 | 126 | If pam_reattach is installed, this will be managed as well. Note that if 127 | pam_reattach is installed using sudo, it is imperative that Touch ID 128 | support be disabled first or you may be in a situation where you cannot 129 | use sudo. Note that MacPorts-installed pam_reattach will never be used. 130 | 131 | States: 132 | off Disables Touch ID. 133 | on Enables Touch ID. 134 | [status] Shows the status of Touch ID. 135 | toggle Toggles the status of Touch ID. 136 | 137 | Options: 138 | -h, --help Show this help' 139 | return 0 140 | end 141 | 142 | 143 | __macos_mac_touchid_sudo::check_supported 144 | or return 145 | 146 | __macos_mac_touchid_sudo::check_old_install 147 | and return 148 | 149 | set --function subcommand (string lower -- $argv[1]) 150 | set --erase argv[1] 151 | 152 | switch $subcommand 153 | case on 154 | set --local reattach /opt/local /opt/homebrew /usr/local /usr 155 | set reattach (path filter --type file $reattach/lib/pam/pam_reattach.so) 156 | 157 | if set --query reattach[1] 158 | set reattach (string replace --all --regex / \\/ $reattach[1]) 159 | end 160 | 161 | __macos_mac_touchid_sudo::add $reattach 162 | 163 | case off 164 | __macos_mac_touchid_sudo::remove 165 | 166 | case status '' 167 | set --local pam_tid disabled 168 | set --local pam_reattach disabled 169 | 170 | grep -q pam_tid.so /etc/pam.d/sudo_local 171 | and set pam_tid enabled 172 | 173 | grep -q pam_reattach.so /etc/pam.d/sudo_local 174 | and set pam_reattach enabled 175 | 176 | if set --query _flag_quiet 177 | test $pam_tid = enabled 178 | else 179 | __macos_mac_touchid_sudo::print_status pam_tid $pam_tid 180 | __macos_mac_touchid_sudo::print_status pam_reattach $pam_reattach 181 | end 182 | 183 | case toggle 184 | if __macos_mac_touchid_sudo status --quiet 185 | __macos_mac_touchid_sudo off 186 | else 187 | __macos_mac_touchid_sudo on 188 | end 189 | 190 | case '*' 191 | echo >&2 'mac touchid: unknown state.' 192 | __macos_mac_touchid_sudo --help >&2 193 | return 1 194 | end 195 | end 196 | -------------------------------------------------------------------------------- /functions/__macos_mac_transparency.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_transparency.fish:v7.0.1 2 | 3 | function __macos_mac_transparency 4 | argparse --name 'mac transparency' h/help q/query -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac transparency [options] STATE 9 | 10 | Enables or disables interface transparency by setting the universal 11 | access "reduce transparency" setting. 12 | 13 | States: 14 | off Disables interface transparency 15 | on Enables interface transparency 16 | [status] Shows the status of interface transparency 17 | toggle Toggles interface transparency 18 | 19 | Options: 20 | -q, --query When getting status, suppresses output. 21 | -h, --help Show this help' 22 | return 0 23 | end 24 | 25 | set function state (string lower -- $argv[1]) 26 | set --erase argv[1] 27 | 28 | switch $state 29 | case status '' 30 | set function value (__macos_mac_defaults_query com.apple.universalaccess reduceTransparency 0) 31 | 32 | if set --query _flag_query 33 | test $value -eq 0 34 | else 35 | if test $value -eq 0 36 | echo on 37 | else 38 | echo off 39 | end 40 | end 41 | 42 | case on 43 | defaults delete com.apple.universalaccess reduceTransparency 44 | 45 | case off 46 | defaults write com.apple.universalaccess reduceTransparency -bool true 47 | 48 | case toggle 49 | if __macos_mac_transparency status --query 50 | __macos_mac_transparency off 51 | else 52 | __macos_mac_transparency on 53 | end 54 | 55 | case '*' 56 | echo >&2 'mac transparency: unknown state' 57 | __macos_mac_transparency --help >&2 58 | return 1 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /functions/__macos_mac_version.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_version.fish:v7.0.1 2 | 3 | function __macos_mac_version 4 | argparse \ 5 | --exclusive s,v \ 6 | --exclusive l,v \ 7 | --exclusive s,c \ 8 | --exclusive l,c \ 9 | --exclusive v,c \ 10 | h/help s/simple l/lowercase v/version c/comparable -- $argv 11 | 12 | if set --query _flag_help 13 | echo 'Usage: mac version [options] 14 | 15 | Shows the current mac version. 16 | 17 | Options: 18 | -s, --simple Removes spaces from the version displayed 19 | -l, --lowercase Converts the version to all lowercase 20 | -c, --comparable Outputs the comparable version value 21 | -v, --version Outputs the macOS version (same as sw_vers -productVersion)' 22 | return 0 23 | end 24 | 25 | set --function os_version (sw_vers -productVersion) 26 | 27 | if set --query _flag_version 28 | echo $os_version 29 | return $status 30 | end 31 | 32 | set os_version (__macos_version_to_comparable $os_version) 33 | or return 1 34 | 35 | if set --query _flag_comparable 36 | echo $os_version 37 | return 0 38 | end 39 | 40 | switch $os_version 41 | case 1005000 42 | set os_version Leopard 43 | case 1006000 44 | set os_version Snow Leopard 45 | case 1007000 46 | set os_version Lion 47 | case 1008000 48 | set os_version Mountain Lion 49 | case 1009000 50 | set os_version Mavericks 51 | case 1010000 52 | set os_version Yosemite 53 | case 1011000 54 | set os_version El Capitan 55 | case 1012000 56 | set os_version Sierra 57 | case 1013000 58 | set os_version High Sierra 59 | case 1014000 60 | set os_version Mojave 61 | case 1015000 62 | set os_version Catalina 63 | case 1100000 64 | set os_version Big Sur 65 | case 1200000 66 | set os_version Monterey 67 | case 1300000 68 | set os_version Ventura 69 | case 1400000 70 | set os_version Sonoma 71 | case 1500000 72 | set os_version Sequoia 73 | case '*' 74 | return 1 75 | end 76 | 77 | if set --query _flag_simple 78 | set os_version (string replace --all ' ' '' "$os_version") 79 | end 80 | 81 | if set --query _flag_lowercase 82 | set os_version (string lower -- "$os_version") 83 | end 84 | 85 | echo $os_version 86 | end 87 | -------------------------------------------------------------------------------- /functions/__macos_mac_vol.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/__macos_mac_vol.fish:v7.0.1 2 | 3 | function __macos_mac_vol 4 | argparse --name 'mac vol' h/help -- $argv 5 | or return 1 6 | 7 | if set --query _flag_help 8 | echo 'Usage: mac vol [options] LEVEL 9 | 10 | Control the volume level. 11 | 12 | Levels: 13 | mute Mutes the volume level. 14 | unmute Unmutes the volume level. 15 | 0 .. 100 Sets the volume level at LEVEL %. 16 | [show] Shows the current volume level. 17 | 18 | Options: 19 | -h, --help Show this help' 20 | return 0 21 | end 22 | 23 | set --function action (string lower -- $argv[1]) 24 | set --erase argv[1] 25 | 26 | switch $action 27 | case mute 28 | osascript -e 'set volume output muted true' 29 | case unmute 30 | osascript -e 'set volume output muted false' 31 | case (seq 0 100) 32 | osascript -e "set volume output volume "$action 33 | case show '' 34 | if test (osascript -e 'output muted of (get volume settings)') = true 35 | echo muted 36 | else 37 | osascript -e "output volume of (get volume settings)" 38 | end 39 | 40 | case '*' 41 | echo >&2 'mac vol: Unknown level' 42 | __macos_mac_vol --help >&2 43 | return 1 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /functions/app.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/app.fish:v7.0.1 2 | 3 | function app --description 'Operate on macOS applications' 4 | argparse --stop-nonopt h/help -- $argv 5 | 6 | if set --query _flag_help 7 | echo 'Usage: app [options] subcommand [arguments...] 8 | 9 | Operates on macOS apps by name. 10 | 11 | Subcommands: 12 | bundleid Shows the bundleID for installed matching apps 13 | find Shows installed matching apps 14 | frontmost Shows the frontmost application 15 | icon Saves the icon for matching apps to disk 16 | quit Quits and optionally restarts matching apps 17 | 18 | Options: 19 | -h, --help Show this help' 20 | return 0 21 | end 22 | 23 | set --function cmd $argv[1] 24 | set --erase argv[1] 25 | 26 | switch (string lower -- $cmd) 27 | case bundleid 28 | __macos_app_bundleid $argv 29 | case find 30 | __macos_app_find $argv 31 | case frontmost 32 | __macos_app_frontmost $argv 33 | case icon 34 | __macos_app_icon $argv 35 | case quit 36 | __macos_app_quit $argv 37 | case '' 38 | echo >&2 'app: No command provided.' 39 | app --help >&2 40 | return 1 41 | case '*' 42 | echo >&2 'app: Unknown command.' 43 | app --help >&2 44 | return 1 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /functions/finder.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/finder.fish:v7.0.1 2 | 3 | function __macos_finder_defaults::query 4 | set --query argv[1] 5 | or return 1 6 | 7 | set --function value (defaults read com.apple.Finder $argv[1] 2>/dev/null) 8 | or return 1 9 | 10 | switch $value 11 | case 1 12 | true 13 | case '*' 14 | false 15 | end 16 | end 17 | 18 | function __macos_finder_defaults::set 19 | set --query argv[1] 20 | or return 1 21 | 22 | set --query argv[2] 23 | or return 1 24 | 25 | defaults write com.apple.Finder $argv[1] -bool $argv[2] 26 | and killall Finder 27 | end 28 | 29 | function __macos_finder_pwd::get 30 | set --function window 1 31 | 32 | if set --query argv[1] 33 | set window $argv[1] 34 | end 35 | 36 | echo 'tell application "Finder" 37 | if ('$window' <= (count Finder windows)) then 38 | get POSIX path of (target of window '$window' as alias) 39 | else 40 | get POSIX path of (desktop as alias) 41 | end if 42 | end tell' | osascript 43 | end 44 | function __macos_finder_pwd::update 45 | argparse --exclusive column,list,icon column list icon -- $argv 46 | or return 1 47 | 48 | set --function window_count 1 49 | set --function view '' 50 | set --function view_type '' 51 | 52 | if set --query _flag_column 53 | set view_type column 54 | else if set --query _flag_list 55 | set view_type list 56 | else if set --query _flag_icon 57 | set view_type icon 58 | end 59 | 60 | if test $view_type != '' 61 | set view 'set the current view of the front Finder window to '$view_type' view' 62 | end 63 | 64 | set --query argv[1]; and set window_count $argv[1] 65 | 66 | echo 'tell application "Finder" 67 | if ('$window_count' <= (count Finder windows)) then 68 | set the target of window '$window_count' to (POSIX file "'$PWD'") as string 69 | else 70 | open (POSIX file "'$PWD'") as string 71 | end if 72 | ' $view ' 73 | end tell' | osascript >/dev/null 74 | end 75 | 76 | # Based on bashfinder: https://github.com/NapoleonWils0n/bashfinder.git 77 | # and my port to zsh. 78 | function finder --description 'Manipulate the finder with the current shell' 79 | argparse --stop-nonopt h/help -- $argv 80 | 81 | if set --query _flag_help 82 | echo 'Usage: finder [options] subcommand [arguments...] 83 | 84 | Interacts with the Finder. If a window number parameter is accepted in a 85 | command, the first (front-most) window is number 1. If a lower window is 86 | specified, or no window is specified, that window becomes the first window. 87 | 88 | Subcommands: 89 | cd Changes to the path of the Finder window 90 | clean Removes .DS_Store files 91 | column Changes the Finder window to PWD using column view 92 | desktop-icons Shows or hides the desktop icons 93 | hidden Shows or hides files that are normally hidden from the Finder 94 | icon Changes the Finder window to PWD using icon view 95 | list Changes the Finder window to PWD using list view 96 | pushd Changes to the path of the Finder window with pushd 97 | pwd Prints the path of the Finder window 98 | quarantine Manages quarantine events 99 | selected Print the selected files on the command-line 100 | track Makes the first Finder window track with the shell PWD 101 | untrack Disables Finder directory tracking 102 | update Updates the Finder window to PWD 103 | 104 | Options: 105 | -h, --help Show this help' 106 | return 0 107 | end 108 | 109 | set --function verb (string lower -- $argv[1]) 110 | set --erase argv[1] 111 | 112 | switch $verb 113 | case cd 114 | __macos_finder_cd $argv 115 | case clean 116 | __macos_finder_clean $argv 117 | case desktop-icons 118 | __macos_finder_desktop_icons $argv 119 | case hidden 120 | __macos_finder_hidden $argv 121 | case update 122 | __macos_finder_update $argv 123 | case list 124 | __macos_finder_list $argv 125 | case icon 126 | __macos_finder_icon $argv 127 | case column 128 | __macos_finder_column $argv 129 | case pwd 130 | __macos_finder_pwd::get $argv[1] 131 | case pushd 132 | __macos_finder_pushd $argv 133 | case quarantine 134 | __macos_finder_quarantine $argv 135 | case selected 136 | __macos_finder_selected 137 | case track 138 | __macos_finder_track 139 | case untrack 140 | __macos_finder_untrack 141 | case '' 142 | echo >&2 'finder: No command provided.' 143 | finder --help >&2 144 | return 1 145 | case '*' 146 | echo $verb 147 | echo >&2 'finder: Unknown command.' 148 | finder --help >&2 149 | return 1 150 | end 151 | end 152 | -------------------------------------------------------------------------------- /functions/has_app.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/has_app.fish:v7.0.1 2 | 3 | function has_app --description 'Returns true if the named application exists' 4 | # Suppress these flags being passed to __macos_app_find 5 | argparse a/all q/quiet -- $argv 6 | or return 1 7 | 8 | if not set --query argv[1] 9 | echo >&2 Usage: (status function) APPNAME... 10 | return 1 11 | end 12 | 13 | __macos_app_find --exact --quiet $argv 14 | end 15 | -------------------------------------------------------------------------------- /functions/mac.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/mac.fish:v7.0.1 2 | 3 | function mac --description 'Manage several macOS functions' 4 | argparse --stop-nonopt h/help -- $argv 5 | 6 | if set --query _flag_help 7 | echo 'Usage: mac [options] subcommand [arguments...] 8 | 9 | Manage several macOS functions. 10 | 11 | Subcommands: 12 | airdrop Manages AirDrop. 13 | airport Performs various WiFi (AirPort) operations 14 | brightness Changes the screen brightness 15 | flushdns Flushes the DNS cache 16 | font-smoothing Enables or disables font smoothing 17 | lsclean Cleans the LaunchServices registration list 18 | mail Speed up Mail.app by vacuuming the envelope index 19 | proxy-icon Enables or disables proxy icon delay 20 | serialnumber Gets the machine serial number 21 | touchid Manages Touch ID authorization for sudo 22 | transparency Enables or disables interface transparency 23 | version Shows the current macOS version 24 | vol Controls the volume level 25 | 26 | Options: 27 | -h, --help Show this help' 28 | return 0 29 | end 30 | 31 | set --function subcommand (string lower -- $argv[1]) 32 | set --erase argv[1] 33 | 34 | switch $subcommand 35 | case airdrop 36 | __macos_mac_airdrop $argv 37 | case airport 38 | __macos_mac_airport $argv 39 | case brightness 40 | __macos_mac_brightness $argv 41 | case flushdns 42 | __macos_mac_flushdns $argv 43 | case font-smoothing 44 | __macos_mac_font_smoothing $argv 45 | case lsclean 46 | __macos_mac_lsclean $argv 47 | case mail 48 | __macos_mac_mail $argv 49 | case proxy-icon 50 | __macos_mac_proxy_icon $argv 51 | case serialnumber 52 | __macos_mac_serialnumber $argv 53 | case touchid 54 | __macos_mac_touchid $argv 55 | case transparency 56 | __macos_mac_transparency $argv 57 | case vol 58 | __macos_mac_vol $argv 59 | case version 60 | __macos_mac_version $argv 61 | case '' 62 | echo >&2 'mac: No command provided.' 63 | mac --help >&2 64 | return 1 65 | case '*' 66 | echo >&2 'mac: Unknown command.' 67 | mac --help >&2 68 | return 1 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /functions/manp.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/manp.fish:v7.0.1 2 | 3 | # Based on man2pdf.sh created by Pico Mitchell (of Random Applications) 4 | # on 11/16/22, licensed under the MIT license. 5 | function manp --description 'View a man page as a PDF' 6 | set --function cache_path "/private/tmp/man PDFs" 7 | 8 | if set --query --universal manp_cache_path 9 | set cache_path $manp_cache_path 10 | end 11 | 12 | argparse --stop-nonopt h/help C/clear-cache -- $argv 13 | 14 | if set --query _flag_help 15 | echo 'Usage: '(status function)' --help 16 | '(status function)' --clear-cache 17 | '(status function)' [section] [man page] 18 | 19 | Opens a macOS man page as a PDF. The generated PDFs are cached 20 | in $manp_cache_path (/private/tmp/man PDFs). 21 | 22 | Use --clear-cache to clear the cached PDFs manually. By default 23 | they will be cleared on any OS upgrade.' 24 | return 0 25 | end 26 | 27 | if set --query _flag_clear_cache 28 | /bin/rm -rf $cache_path 29 | return $status 30 | end 31 | 32 | set --function man_path (/usr/bin/man -w $argv 2> /dev/null) 33 | 34 | if test -f $man_path 35 | # Save every man page PDF into a sub-folder for the current OS version 36 | # (and build) since man pages can be updated between OS versions, and 37 | # don't want to retrieve an old cached version from a previous OS 38 | # (when not saving to a temporary location). 39 | set --local os_path $cache_path"/"(/usr/bin/sw_vers -productVersion)" ("(/usr/bin/sw_vers -buildVersion)")" 40 | 41 | if not test -d $os_path 42 | # If the man PDFs base path exists, but not the current OS sub- 43 | # folder, that likely means that there has been an OS update 44 | # since the last run, so clear the cache of the old man PDFs 45 | # from the previous OS version by deleting the base path which 46 | # will be re-created when the new latest OS sub-folder is 47 | # created below. 48 | if test -d $cache_path 49 | /bin/rm -rf $cache_path 50 | end 51 | 52 | /bin/mkdir -p $os_path 53 | end 54 | 55 | set --local man_filename (path basename $man_path) 56 | set --local man_section (path extension $man_filename | string replace . '') 57 | set man_filename (string replace .$man_section '' $man_filename) 58 | 59 | if test $man_section != 1 60 | set man_filename $man_filename" ("$man_section")" 61 | end 62 | 63 | set --local pdf_path $os_path/man" "$man_filename.pdf 64 | 65 | if not test -f $pdf_path 66 | /usr/bin/mandoc -T pdf $man_path >$pdf_path 67 | end 68 | 69 | if set --query $manp_pdf_app_name 70 | /usr/bin/open -af $manp_pdf_app_name $pdf_path 71 | else 72 | /usr/bin/open $pdf_path 73 | end 74 | else 75 | /usr/bin/man $argv 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /functions/note.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/note.fish:v7.0.1 2 | 3 | function note --description 'Add a note to Notes.app' 4 | is_mac 'mountain lion' 5 | or return 1 6 | 7 | has_app Notes 8 | or return 1 9 | 10 | if set --query argv 11 | set --function text $argv 12 | else 13 | set --function text (cat - | sed -e 's/$/
/') 14 | end 15 | 16 | test -z $text 17 | or return 1 18 | 19 | set --function head $text[1] 20 | 21 | if set --query text[2] 22 | set --function body $text[2..-1] 23 | end 24 | 25 | if set --query body 26 | set --function properties '{name: "'$head'", body: "'($body[1..-1])'"}' 27 | else 28 | set --function properties '{name: "'$head'"}' 29 | end 30 | 31 | echo 'tell application "Notes" 32 | tell account "iCloud" 33 | tell folder "Notes" 34 | make new note with properties ' $properties ' 35 | end tell 36 | end tell 37 | end tell' | osascript >/dev/null 38 | end 39 | -------------------------------------------------------------------------------- /functions/ql.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/ql.fish:v7.0.1 2 | 3 | function ql --description 'QuickLook a file or directory' 4 | # Updated based on https://gist.github.com/chockenberry/13c15466417b88e40f23e58df8091dac 5 | if set --query argv[1] 6 | qlmanage -p $argv >/dev/null 2>/dev/null 7 | else 8 | set --function root (mktemp -d) 9 | command cat >$root/ql.stdin 10 | set --function mime_type (file --brief --mime-type $root/ql.stdin) 11 | set --function extension (grep $mime_type /etc/apache2/mime.types | awk '{ print $2; }') 12 | 13 | if test -z $extension 14 | qlmanage -p $root/ql.stdin >/dev/null 2>/dev/null 15 | else 16 | mv $root/ql.{stdin,$extension} 17 | qlmanage -p $root/ql.$extension >/dev/null 2>/dev/null 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /functions/remind.fish: -------------------------------------------------------------------------------- 1 | # @halostatue/fish-macos/functions/remind.fish:v7.0.1 2 | 3 | function remind --description 'Add a reminder to Reminders.app' 4 | is_mac 'mountain lion' 5 | or return 1 6 | 7 | has_app Reminders 8 | or return 1 9 | 10 | if set --query argv 11 | set --function text $argv 12 | else 13 | set --function text (cat - | sed -e 's/$/
/') 14 | end 15 | 16 | test -z $text 17 | and return 0 18 | 19 | echo $text : text 20 | 21 | echo 'tell application "Reminders" 22 | tell the default list 23 | make new reminder with properties {name: "'$text'"} 24 | end tell 25 | end tell' | osascript >/dev/null 26 | end 27 | --------------------------------------------------------------------------------