-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.function
executable file
·35 lines (30 loc) · 1.06 KB
/
.function
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
mk () { mkdir -p "$@" && cd "$@" }
brewopen () {
open "https://formulae.brew.sh/formula/$1"
}
gif () {
# If no file is specified, use the latest .mov file in ~/Desktop
if [[ -z "$1" || "$1" == "--delete" ]]; then
echo "No file specified. Converting the latest .mov file in ~/Desktop."
file=$(ls -t ~/Desktop/*.mov | head -n 1)
if [[ -z "$file" ]]; then
return 1
fi
else
file="$1"
# Ensure the file exists
if [[ ! -f "$file" ]]; then
echo "File not found: $file"
return 1
fi
fi
# Based on https://gist.github.com/SheldonWangRJT/8d3f44a35c8d1386a396b9b49b43c385
output_file="${file%.*}.gif"
ffmpeg -y -i "$file" -v quiet -vf scale=iw/2:ih/2 -pix_fmt rgb8 -r 10 "$output_file" && gifsicle -O3 "$output_file" -o "$output_file"
echo "Converted $file to $output_file."
# If --delete flag is specified, also delete the original file
if [[ "$1" == "--delete" || "$2" == "--delete" ]]; then
echo "Deleting $file."
rm "$file"
fi
}