-
Notifications
You must be signed in to change notification settings - Fork 0
/
usernames
executable file
·44 lines (40 loc) · 972 Bytes
/
usernames
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
#!/usr/bin/env zsh
while getopts ":n:r" opt; do
case $opt in
n)
username=$OPTARG
updateusername=true
;;
r)
username=nizusan
updateusername=true
;;
esac
done
if [[ $updateusername = true ]]; then
echo 'Previous usernames'
find . -maxdepth 1 -type f -name "*.nix" | \
xargs -I {} \
grep -EH '(home-manager|users)\.users\.[a-z]+' {}
find . -maxdepth 1 -type f -name "*.nix" | \
xargs -I {} sed -i -E "s/(home-manager|users)\.users\.[a-z]+/\1\.users\.$username/g" {}
echo 'New usernames'
find . -maxdepth 1 -type f -name "*.nix" | \
xargs -I {} \
grep -EH '(home-manager|users)\.users\.[a-z]+' {}
else
echo "
USERNAME - update username for nix config files\n\n
SYNOPSIS
username [-r] [-n]\n\n
OPTIONS
-r
\tReset username to 'nizusan'.\n\n
-n <username>
\tUpdate username to custom value.\n\n
"
echo 'Existing usernames'
find . -maxdepth 1 -type f -name "*.nix" | \
xargs -I {} \
grep -EH '(home-manager|users)\.users\.[a-z]+' {}
fi