archlinux/functions/user

110 lines
2.6 KiB
Text
Raw Normal View History

2025-11-22 23:15:27 +00:00
#!/usr/bin/env bash
revision=0.1a
set -a
set -E
# Create local paths
mkdir -p ~/.local/{bin,functions}
# Generate ssh identity
ssh-keygen -q \
-t ed25519 \
-P "" \
-C "${username}@${hostname}" \
-f ~/.ssh/id_ed25519
mkdir ~/.ssh/sockets/
# Custom bashrc
cat > ~/.local/functions/bashrc <<- 'BASHRC'
#!/usr/bin/env bash
# Shell color
PS1="$(tput setaf 6)[\u@\h \W \$?]\$ $(tput sgr0)"
# Colored prompts
alias ll='ls --color=auto -l -a -h'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
BASHRC
# Btrfs functions
if findmnt / | grep -w -q btrfs
then
cat > ~/.local/functions/btrfs <<- 'btrfs'
#!/usr/bin/env bash
# Btrfs check
function btrfs-check
{
sudo dmesg | grep -i btrfs
}
# # Snapper
# function snapshot-home
# {
# if [ "${*}" ]
# then
# sudo snapper -c home create --description "${*}"
# else
# sudo snapper -c home create --description "$(date)"
# fi
# }
#
# function snapshot-root
# {
# if [ "${*}" ]
# then
# sudo snapper -c root create --description "${*}"
# else
# sudo snapper -c root create --description "$(date)"
# fi
# }
#
# function snapshot-list
# {
# sudo -v
# echo -e '\n\e[1;33mRoot snapshots:\e[0m'
# sudo snapper -c root ls
# echo -e '\n\e[1;33mHome snapshots:\e[0m'
# sudo snapper -c home ls
# echo
# }
#
# function snapshot-delete
# {
# if ! grep -w -q 'root\|home' <<< "${1}" || [ -z "${2}" ]
# then
# echo -e '\n\t\e[1;31mInvalid option, use syntax: ${root,home} $snapshot\e[0m\n'
# return 1
# elif grep -w -q '1' <<< "${2}"
# then
# echo -e '\n\t\e[1;31mUnable to delete "fresh install" snapshot\e[0m\n'
# return 1
# fi
#
# if [[ "${1}" = "root" ]]
# then
# if ls /.snapshots | grep -q $(sed -e 's/-/\\\|/g' <<< "${2}")
# then
# sudo snapper -c root delete "${2}"
# elif ! [ -d /.snapshots/"${2}" ]
# then
# echo -e '\n\t\e[1;31mSnapshot doesn't exist, try again\e[0m\n'
# fi
# elif [[ "${1}" = "home" ]]
# then
# if ls /home/.snapshots | grep -q $(sed -e 's/-/\\\|/g' <<< "${2}")
# then
# sudo snapper -c home delete "${2}"
# elif ! [ -d /home/.snapshots/"${2}" ]
# then
# echo -e '\n\t\e[1;31mSnapshot doesn't exist, try again\e[0m\n'
# fi
# fi
# }
btrfs
fi
if pacman -Q | grep -q yubikey
then
install /dev/stdin ~/yksetup.sh <<- 'yubikey'
$(curl --fail --silent https://git.myvelabs.com/lab/archlinux/raw/branch/master/functions/yubikey)
yubikey
fi