#!/bin/bash # # Updates the Info.plist file for a macOS app bundle to register supported file types and URL schemes. # This only applies the updates common to `script/bundle` and `script/run`. # Must be called from the root directory of the warp repo. set -e if [[ ! -d "script" ]]; then echo "Run this script from the root of your warp repo." exit 1 fi if [[ -z "$WARP_PLIST_PATH" ]]; then echo 'Must set $WARP_PLIST_PATH' exit 1 fi if [[ -n "$GIT_RELEASE_TAG" ]]; then echo "Updating plist Warp version to $GIT_RELEASE_TAG" plutil -insert WarpVersion -string "$GIT_RELEASE_TAG" "$WARP_PLIST_PATH" # We convert our version format to be period-separated integers only to align better with # Apple's guidance on values for `CFBundleVersion` / `CFBundleShortVersionString`. # (They technically only allow [major].[minor].[patch], but it's not enforced.) # This allows IT admins to work with a more stable version of our internal versioning scheme. # A tag like `v0.2025.01.07.08.02.stable_02` would be converted to `0.2025.01.07.08.02.02`. if [[ $GIT_RELEASE_TAG =~ ^v([0-9]+)\.([0-9]{4})\.([0-9]{2})\.([0-9]{2})\.([0-9]{2})\.([0-9]{2})\.[a-z]+_([0-9]{2})$ ]]; then MAJOR="${BASH_REMATCH[1]}" YEAR="${BASH_REMATCH[2]}" MONTH="${BASH_REMATCH[3]}" DAY="${BASH_REMATCH[4]}" HOUR="${BASH_REMATCH[5]}" MINUTE="${BASH_REMATCH[6]}" BUILD="${BASH_REMATCH[7]}" FORMATTED_VERSION="${MAJOR}.${YEAR}.${MONTH}.${DAY}.${HOUR}.${MINUTE}.${BUILD}" echo "Updating plist version to $FORMATTED_VERSION" plutil -replace CFBundleShortVersionString -string "$FORMATTED_VERSION" "$WARP_PLIST_PATH" plutil -replace CFBundleVersion -string "$FORMATTED_VERSION" "$WARP_PLIST_PATH" else echo "Warning: GIT_RELEASE_TAG '$GIT_RELEASE_TAG' does not match expected format vN.YYYY.MM.DD.HH.MM.channel_NN" fi fi if [[ -n "$WARP_SCHEME_NAME" ]]; then echo "Updating plist to support a custom url scheme" # Update the plist that cargo bundle creates to add support for custom URL schemes. Unfortunately, cargo bundle does not support # setting arbitrary plist fields, so we must do this after the fact. plutil -insert CFBundleURLTypes -xml "CFBundleURLNameCustom AppCFBundleURLSchemes$WARP_SCHEME_NAME" "$WARP_PLIST_PATH" fi if [[ -z "$WARP_PLIST_NO_FILE_TYPES" ]]; then echo "Updating plist with supported file types" plutil -insert CFBundleDocumentTypes -xml " CFBundleTypeNameFolder CFBundleTypeRoleEditor LSItemContentTypes public.folder CFBundleTypeNameTerminal shell script CFBundleTypeRoleShell LSItemContentTypes com.apple.terminal.shell-script CFBundleTypeNameUnix Executable File CFBundleTypeRoleShell LSItemContentTypes public.unix-executable CFBundleTypeNameMarkdown File CFBundleTypeRoleEditor LSItemContentTypes net.daringfireball.markdown com.unknown.md net.ia.markdown public.markdown CFBundleTypeNamePlain Text File CFBundleTypeRoleEditor LSItemContentTypes public.plain-text CFBundleTypeNameSource Code File CFBundleTypeRoleEditor LSItemContentTypes public.source-code CFBundleTypeNameSource Code CFBundleTypeRoleEditor LSHandlerRankAlternate CFBundleTypeExtensions c h cc cpp cxx c++ hpp hxx hh h++ m mm cs csx css dart dockerfile containerfile go htm html xhtml java jav js mjs cjs json jsx less lua makefile mk cmake php pl pm py pyi r rb gemspec rs rst sass scss sql swift ts tsx txt vue xml xaml dtd plist yaml yml eyaml eyml toml cfg conf config csv diff env gradle groovy ini log properties svg tex cls lock bat cmd ps1 psd1 psm1 sh bash zsh fish bashrc bash_profile zshrc zshenv profile gitignore gitconfig gitattributes editorconfig hbs handlebars erb tf tfvars proto graphql gql wgsl zig kt kts scala ex exs erl clj cljs coffee fs fsi fsx ml mli vb pug jade ipynb CFBundleTypeNameAll Documents CFBundleTypeRoleEditor LSHandlerRankAlternate LSItemContentTypes public.data " "$WARP_PLIST_PATH" fi # Unfortunately, there isn't a single standard UTI (what goes in LSItemContentTypes) for Markdown # files. Instead, we list all the common ones - see these for more info: # https://github.com/sbarex/QLMarkdown#installation # https://blog.smittytone.net/2021/01/19/how-tools-try-to-own-markdown/ echo "Updating plist with permissions descriptions" plutil -insert NSAppleEventsUsageDescription -string "A program in Warp wants to use AppleScript." "$WARP_PLIST_PATH" plutil -insert NSCameraUsageDescription -string "A program in Warp wants to use the camera." "$WARP_PLIST_PATH" plutil -insert NSMicrophoneUsageDescription -string "A program in Warp wants to use your microphone." "$WARP_PLIST_PATH" plutil -insert NSContactsUsageDescription -string "A program in Warp wants to use your contacts." "$WARP_PLIST_PATH" plutil -insert NSCalendarsUsageDescription -string "A program in Warp wants to use your calendar." "$WARP_PLIST_PATH" plutil -insert NSLocationUsageDescription -string "A program in Warp wants to use your location information." "$WARP_PLIST_PATH" plutil -insert NSPhotoLibraryUsageDescription -string "A program in Warp wants to use your photo library." "$WARP_PLIST_PATH" echo "Disabling use of Liquid Glass on macOS Tahoe" plutil -insert UIDesignRequiresCompatibility -bool true "$WARP_PLIST_PATH"