~kris/dots

srice

ref: 94ef01abf339f7156c69870d969cd635566faddd srice/.config/mksh/functions.sh -rw-r--r-- 799 bytes
94ef01ab — Kris Yotam remove nvim config, add mksh/planrc/gentoo profile, update code+write configs and fastfetch glenda 3 months ago
                                                                                
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
# mksh functions

# search repo names in ~/src/
fs() {
	[ -z "$1" ] && { echo "usage: fs <pattern>"; return 1; }
	pattern=$(echo "$*" | tr '[:upper:]' '[:lower:]')
	matches=""
	count=0
	for d in "$HOME"/src/*/; do
		name=${d%/}
		name=${name##*/}
		lower=$(echo "$name" | tr '[:upper:]' '[:lower:]')
		case "$lower" in
			*"$pattern"*) matches="$matches$name
"; count=$((count + 1)) ;;
		esac
	done
	if [ "$count" -eq 0 ]; then
		printf '\n  \033[2mno matches for\033[0m \033[1m%s\033[0m\n\n' "$*"
		return 1
	fi
	printf '\n  \033[2m%d match(es) for\033[0m \033[1m%s\033[0m\n\n' "$count" "$*"
	echo "$matches" | while IFS= read -r m; do
		[ -n "$m" ] && printf '    \033[36m>\033[0m  %s\n' "$m"
	done
	printf '\n'
}

lp() { cd "$HOME/edu/craft/learn"; }
fcc() { cd "$HOME/edu/craft/freecodecamp"; }