Skip to content

Commit 82c4a08

Browse files
authored
8/13/2025 (#49)
1 parent 87691ab commit 82c4a08

3 files changed

Lines changed: 71 additions & 20 deletions

File tree

.10_macos.bash

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ fi
2525

2626
# Homebrew packages
2727
if command -v brew &> /dev/null; then
28+
# Apps
29+
[[ -d /Applications/LinearMouse.app ]] || brew install --cask linearmouse
30+
[[ -d /Applications/Rectangle.app ]] || brew install --cask rectangle
31+
32+
# CLI tools
2833
command -v dive > /dev/null || brew install dive
2934
command -v gawk > /dev/null || brew install gawk
3035
command -v gdate > /dev/null || brew install coreutils
36+
command -v gh > /dev/null || brew install gh
3137
command -v gsed > /dev/null || brew install gnu-sed
3238
command -v jq > /dev/null || brew install jq
3339
command -v rename > /dev/null || brew install rename
@@ -47,21 +53,32 @@ if command -v brew &> /dev/null && ! command -v mas &> /dev/null; then
4753
brew install mas
4854
# Installed applications aren't enumerated immediately, `mas list` may return nothing
4955
fi
50-
if command -v mas &> /dev/null; then
51-
mas_list=$(mas list)
52-
for app_id in $(
53-
# 1Password for Safari
54-
# echo "1569813296"
55-
# Kindle
56-
echo "302584613"
57-
# Menu World Time
58-
# echo "1446377255"
59-
# WhatsApp
60-
# echo "310633997"
61-
); do
62-
echo "${mas_list}" | grep "^${app_id} " &> /dev/null || mas install "${app_id}"
63-
done
64-
fi
56+
# if command -v mas &> /dev/null; then
57+
# mas_list=$(mas list)
58+
# for app_id in $(
59+
# # ----- Applications -----
60+
# # TODO: Keka (paid)
61+
# # Kindle
62+
# echo "302584613"
63+
# # TODO: LibreOffice (paid)
64+
# # TODO: Maccy (paid)
65+
# # Menu World Time
66+
# # echo "1446377255"
67+
# # NordVPN
68+
# # echo "905953485"
69+
# # Telegram
70+
# # echo "747648890"
71+
# # WhatsApp
72+
# # echo "310633997"
73+
# # ----- Safari Extensions -----
74+
# # 1Password for Safari
75+
# echo "1569813296"
76+
# # Grammarly for Safari
77+
# echo "1462114288"
78+
# ); do
79+
# echo "${mas_list}" | grep "^${app_id} " &> /dev/null || mas install "${app_id}"
80+
# done
81+
# fi
6582

6683
# macOS DNS flush
6784
flush() {

.20_git.bash

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ __git_funcs() {
3737
local stash_name
3838
stash_name="$(cat /dev/urandom | base32 | tr -dc 'A-Z0-9' | head -c 16)"
3939
git stash push --message "${stash_name}" || return 1
40-
if git branch --list main > /dev/null; then
40+
if [[ $(git branch --list main) ]]; then
4141
git fetch origin main:main
4242
git rebase origin/main
4343
else
@@ -60,10 +60,35 @@ __git_funcs() {
6060
fi
6161
}
6262

63+
# Copy changes from one clone to another
64+
# @param {string} $1 The original/old git root
65+
# @param {string} $2 The new git root
66+
gcopy() {
67+
git -C "$1" status --porcelain=v1 | while read -r state file; do
68+
if [[ "${state}" == *D* ]]; then
69+
# Copy deletions
70+
echo -e "\033[91mX\033[0m ${file}"
71+
rm -rf "${2:?}/${file}"
72+
elif [[ "${state}" == *R* ]]; then
73+
# Copy renames
74+
before="${file% -> *}"
75+
after="${file#* -> }"
76+
echo -e "\033[95m>\033[0m ${before} -> ${after}"
77+
git -C "$2" mv --force "${before}" "${after}"
78+
cp "$1/${after}" "$2/${after}"
79+
else
80+
# Copy modifications
81+
echo -e "\033[92m*\033[0m ${file}"
82+
mkdir -p "$2/$(dirname "${file}")"
83+
cp "$1/${file}" "$2/${file}"
84+
fi
85+
done
86+
}
87+
6388
gupdate() {
6489
git pull > /dev/null
6590

66-
if git branch --list main > /dev/null; then
91+
if [[ $(git branch --list main) ]]; then
6792
git fetch origin main:main
6893
git merge --no-edit origin/main
6994
else

.20_nodejs.bash

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,25 @@ __nodejs_bun
2626

2727

2828
__nodejs_funcs() {
29-
# @link https://github.com/npm/npm/issues/15536#issuecomment-392657820
29+
# @param {string=} $1 npm list depth
30+
# @see https://github.com/npm/npm/issues/15536#issuecomment-392657820
3031
ndeprecated() {
31-
jq -r '.dependencies,.devDependencies|keys[] as $k|"\($k)@\(.[$k])"' package.json | while read -r line; do \
32+
npm list "--depth=${1:-0}" | awk '{ print $NF }' | tail -n +2 | grep -v 'deduped' | while read -r line; do \
3233
printf "%s: " "${line}"
33-
[ "$(npm show "${line}" | grep --count --extended-regexp '^DEPRECATED')" != "0" ] && \
34+
[ "$(npm view "${line}" | grep --count --extended-regexp '^DEPRECATED')" != "0" ] && \
3435
printf "\e[1;31m""DEPRECATED\n""\e[0m" || \
3536
printf "\e[1;32m""not deprecated\n""\e[0m"
3637
done
3738
}
3839

40+
# @param {string=} $1 npm list depth
41+
# @see https://stackoverflow.com/a/70591428
42+
nmodified() {
43+
npm list "--depth=${1:-0}" | awk '{ print $NF }' | tail -n +2 | grep -v 'deduped' | \
44+
xargs -I {} bash -c "npm view {} time.modified _id | awk '{print \$3}' | sed -e \"s/'//g\" | tr '\n' ' ' && echo" | \
45+
sort
46+
}
47+
3948
# Find the minimum Node version supported by all package.json's engines
4049
# @param {string=} $1 Package name
4150
nengine() {

0 commit comments

Comments
 (0)