Skip to content

Commit 8883912

Browse files
committed
.zshrc: add cw(), v() and bytes()
1 parent 3d81086 commit 8883912

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

.zshrc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,35 @@ add-shadow() {
336336
convert "$1" -trim \( +clone -background grey25 -shadow 80x40+5+30 \) +swap -background transparent -layers merge +repage "$1-shadow.png"
337337
}
338338

339+
cw() {
340+
MESSAGE="${1:-work}"
341+
git add -u && git commit -m "$MESSAGE" && git push
342+
}
343+
339344
v() {
340-
nvim $(fzf)
345+
FILE=$(fzf)
346+
print -s "nvim $FILE"
347+
nvim "$FILE"
348+
}
349+
350+
# print bytes in human readable format
351+
bytes() {
352+
BYTE_COUNT="$1"
353+
if [ -z "$BYTE_COUNT" ]; then
354+
echo "Usage: bytes <number_of_bytes>"
355+
return 1
356+
fi
357+
if [ "$BYTE_COUNT" -lt 1024 ]; then
358+
echo "${BYTE_COUNT} B"
359+
elif [ "$BYTE_COUNT" -lt $((1024**2)) ]; then
360+
echo "$((BYTE_COUNT / 1024)) KB"
361+
elif [ "$BYTE_COUNT" -lt $((1024**3)) ]; then
362+
echo "$((BYTE_COUNT / 1024**2)) MB"
363+
elif [ "$BYTE_COUNT" -lt $((1024**4)) ]; then
364+
echo "$((BYTE_COUNT / 1024**3)) GB"
365+
else
366+
echo "$((BYTE_COUNT / 1024**4)) TB"
367+
fi
341368
}
342369

343370
installdeb() {

0 commit comments

Comments
 (0)