-
Notifications
You must be signed in to change notification settings - Fork 0
/
.shellfn
81 lines (66 loc) · 1.81 KB
/
.shellfn
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
#! /bin/bash
# Shell functions
# Display the weather. Optionally, provide a location argument.
weather() {
curl "wttr.in/$1"
}
# Display more detailed wind and cloud weather for a location.
meteogram() {
finger "$1@graph.no"
}
colorscheme() {
NUM=$1
SCHEMES=($(ls -1 "$HOME/.config/kitty/themes/themes"))
while true
do
SCHEME="${SCHEMES[$NUM % ${#SCHEMES[@]}]}"
kitty @ set-colors --all --configured "$HOME/.config/kitty/themes/themes/$SCHEME"
echo "Colorscheme set to $SCHEME. ($NUM)"
NUM=$((NUM + 1))
sleep 1
done
}
spinfo() {
ALBUM_ART=$(playerctl metadata mpris:artUrl | sed 's/open.spotify.com/i.scdn.co/')
ARTIST=$(playerctl metadata xesam:artist)
ALBUM=$(playerctl metadata xesam:album)
TITLE=$(playerctl metadata xesam:title)
icat "$ALBUM_ART"
echo "$TITLE"
echo "$ALBUM"
echo "$ARTIST"
}
# Clear displayed images.
iclear() {
SLEEP=${1:-0}
sleep "$SLEEP"
kitty +kitten icat --clear
}
# Display an image inline in the terminal.
icat() {
kitty +kitten icat --align left "$1"
}
# Show git branch info with description.
branch-info() {
active=" "
for branch in $(git branch); do
if [[ "$branch" == "*" ]]; then
active="*"
continue
fi
description=$(git config "branch.$branch.description")
printf '%s \e[33m%s\e[0m\t%s\n' "$active" "$branch" "$description"
if [[ "$active" == "*" ]]; then
active=" "
fi
done
}
cleanup() {
BASE=$1
BRANCHES=$(git for-each-ref refs/heads --format="%(refname:short)" | grep -vE "(develop|master|rc-v\d+\.\d+\.\d+)")
while IFS= read -r branch; do
if ! git cherry "$BASE" "$branch" | grep -q "^+"; then
git branch -D "$branch"
fi
done < <(echo "$BRANCHES")
}