-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaliases
More file actions
102 lines (78 loc) · 3.26 KB
/
Copy pathaliases
File metadata and controls
102 lines (78 loc) · 3.26 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
##########
# Aliases
##########
# MacOS
alias dt='cd ~/Desktop; pwd'
# ls
alias ls='ls -G'
alias ll='ls -alF'
alias la='ls -A'
# grep
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# dev
alias ghd='cd ~/Documents/GitHub; ll; pwd'
alias pn='pnpm'
# Canary
alias canary-unsafe='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --disable-web-security'
# brew under Rosetta
alias ibrew='arch -x86_64 /usr/local/bin/brew'
# Pixel sync
alias pixel-sync='adb-sync ~/Pictures/Sync'
############
# Functions
############
# Create an animated GIF from a video. Requires ffmpeg.
function video2gif() {
input=$1 && ffmpeg -y -i $input -vf fps=10,scale=1920:-1:flags=lanczos,palettegen "$input-palette.png" && ffmpeg -y -i $input -i "$input-palette.png" -loop -1 -filter_complex "fps=10,scale=1080:-1:flags=lanczos[x];[x][1:v]paletteuse" "$input.gif"
rm $input-palette.png
}
# Sync a local directory to a connected Android device using ADB.
function adb-sync() {
# List connected devices
adb devices
local default_source="."
local default_destination="/storage/emulated/0/DCIM/Camera"
# Use the provided source directory or fall back to the default
local source_dir="${1:-$default_source}"
# Use the provided destination directory or fall back to the default
local destination_path="${2:-$default_destination}"
# Echo the inputs with ASCII colors and emojis
echo -e "\033[1;32m📂 Source Directory: \033[0m$source_dir"
echo -e "\033[1;34m📁 Destination Path: \033[0m$destination_path"
# Execute the adb push command
adb push "${source_dir%/}/." "$destination_path"
# Get the file count in the destination directory
echo -e "\033[1;33m🔍 Fetching file count in destination directory...\033[0m"
local file_count=$(adb shell "ls \"$destination_path\" | wc -l")
echo -e "\033[1;36m📋 File Count in $destination_path: $file_count\033[0m"
}
function pixel-clean() {
# List connected devices
adb devices
local default_destination="/storage/emulated/0/DCIM/Camera"
# Use the provided destination directory or fall back to the default
local destination_path="${1:-$default_destination}"
# Get file count in the directory before deletion
local file_count=$(adb shell "ls -1 \"$destination_path\" 2>/dev/null | wc -l")
file_count=${file_count:-0} # Default to 0 if the directory doesn't exist or is empty
# Warning with file count
echo -e "\033[1;31m⚠️ WARNING: $destination_path contains $file_count file(s). This will delete all files. Continue? (y/N)\033[0m"
read -r confirmation
if [[ "$confirmation" == "y" || "$confirmation" == "Y" ]]; then
echo -e "\033[1;33m🗑️ Deleting all files in $destination_path...\033[0m"
adb shell "rm -rf \"$destination_path\"/*"
# Verify the directory contents after deletion
echo -e "\033[1;33m🔍 Verifying $destination_path...\033[0m"
local remaining_files=$(adb shell "ls -A \"$destination_path\" 2>/dev/null")
if [[ -z "$remaining_files" ]]; then
echo -e "\033[1;32m✅ Directory is empty: $destination_path\033[0m"
else
echo -e "\033[1;31m❌ Directory is not empty:\033[0m"
echo -e "\033[1;34m$remaining_files\033[0m"
fi
else
echo -e "\033[1;34m❌ Operation canceled.\033[0m"
fi
}