-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen_a.sh
More file actions
executable file
·65 lines (50 loc) · 1.4 KB
/
open_a.sh
File metadata and controls
executable file
·65 lines (50 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
# Time-stamp: <Sunday 2025-08-03 05:11:36 Jess Moore>
#
# A shorthand method to open the selected file with my
# preferred app.
#
# Usage: open_a.sh [file]
function usage() {
echo "Usage: open_a [file]"
echo ""
echo "Description: Opens the selected file with my preferred app."
echo ""
echo "Arguments:"
echo " file: The selected pdf file to open."
echo ""
exit 1 # Exit with a non-zero status to indicate an error
}
if [[ $# -eq 0 || $* == *"help"* || $* == *"-h"* ]]; then
usage
fi
FILE=$1
DIR=$(pwd)
FILEPATH="${DIR}/${FILE}"
# Get file type
EXT="${FILE##*.}"
case "${EXT}" in
'pdf')
APP=skim;
open "${APP}://${FILEPATH}";;
'xlsx'|'xls')
APP=/Applications/Microsoft\ Excel.app;;
'docx'|'doc')
APP=/Applications/Microsoft\ Word.app;;
*)
echo "Error: ${FILE} is not in a supported file format.";
exit 1;;
esac
APPS=('xlsx' 'xls' 'docx' 'doc')
if [[ ${APPS[*]} == *"${EXT}"* ]]; then
open -a "${APP}" "${FILE}"
fi
echo "Opening ${FILE} with ${APP}..."
## 20250726 Rectangle options
## https://github.com/rxhanson/Rectangle?tab=readme-ov-file
# Also tried setting position with demo.applescript but get repeated 100006 error
open -g "rectangle://execute-action?name=last-three-fourths"
echo "Resizing to last three fourths of display"
open -g "rectangle://execute-action?name=next-display"
echo "Moving to next display where available"