add base setup with dotter
This commit is contained in:
parent
6b0da868bb
commit
42e6595b60
177 changed files with 1062 additions and 70 deletions
32
config/zsh/functions/fedora.zsh
Normal file
32
config/zsh/functions/fedora.zsh
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
dnf-save-install() {
|
||||
file="$DOTS/exports/dnf.txt"
|
||||
echo "$*" >> "$file"
|
||||
sort -u -o "$file" "$file"
|
||||
sudo dnf install -y $(cat "$DOTS/exports/dnf.txt")
|
||||
}
|
||||
|
||||
dnf-load-export() {
|
||||
while read -r line; do
|
||||
sudo dnf copr enable -y "$line"
|
||||
done <"$DOTS/exports/copr.txt"
|
||||
|
||||
sudo dnf install -y $(cat "$DOTS/exports/dnf.txt")
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
sudo dnf upgrade --refresh -y
|
||||
}
|
||||
|
||||
# where did I get this?
|
||||
mayor-upgrade() {
|
||||
if [[ $(dnf check-update -q) ]]; then
|
||||
echo "There are updates pending, update and reboot? [y/N]"
|
||||
read -r answer
|
||||
|
||||
if [[ $answer == 'y' || $answer == 'Y' ]]; then
|
||||
upgrade
|
||||
sc-reboot
|
||||
|
||||
fi
|
||||
fi
|
||||
}
|
||||
89
config/zsh/functions/flatpak.zsh
Normal file
89
config/zsh/functions/flatpak.zsh
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
export FLATPAK_ALIAS_FILE="${DOTS:-$HOME/.config}/config/zsh/aliases/flatpak.zsh"
|
||||
export FLATPAK_EXPORT_FILE="${DOTS:-$HOME/Desktop}/exports/flatpak-apps.txt"
|
||||
|
||||
fp() {
|
||||
set -e
|
||||
generate_flatpak_alias() {
|
||||
local flatpak_alias_file=${1:-$FLATPAK_ALIAS_FILE}
|
||||
[[ -f $flatpak_alias_file ]] && touch "$flatpak_alias_file"
|
||||
local flatpak_binaries_dir="/var/lib/flatpak/exports/bin"
|
||||
if [[ -d "$flatpak_binaries_dir" ]]; then
|
||||
echo -e "\n# Auto-generated aliases for Flatpak applications\n" >> "${flatpak_alias_file}"
|
||||
|
||||
while read -r app; do
|
||||
app_id=$(echo "$app" | awk -F'/' '{print $NF}')
|
||||
alias_name=$(echo "$app_id" | awk -F'.' '{print $NF}' | tr '[:upper:]' '[:lower:]')
|
||||
echo "alias $alias_name='flatpak run $app_id'" >> "${flatpak_alias_file}"
|
||||
done < <(find "$flatpak_binaries_dir" -maxdepth 1 -mindepth 1)
|
||||
|
||||
echo "Done generating Flatpak aliases"
|
||||
echo "Check ${BLD}${BLU}$flatpak_alias_file${RST} to modify auto-generated alias"
|
||||
else
|
||||
echo "${RED}${BLD}Error: ${YLW}$flatpak_binaries_dir${RST} directory does not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
export_flatpak_apps() {
|
||||
local flatpak_export_file=""${1:-$FLATPAK_EXPORT_FILE}
|
||||
flatpak list --columns=application --app > "${flatpak_export_file}"
|
||||
echo "${BLD}${BLU}Flatpak apps exported successfully${RST}"
|
||||
}
|
||||
|
||||
import_flatpak_apps() {
|
||||
local flatpak_export_file=${1:-$FLATPAK_EXPORT_FILE}
|
||||
xargs flatpak install -y < "${flatpak_export_file}"
|
||||
}
|
||||
|
||||
show_help() {
|
||||
echo -e "${BLD}Usage: ${GRN}fp${RST}${YLW} [OPTION]${RST}"
|
||||
echo -e ""
|
||||
echo -e "${BLD} Options:${RST}"
|
||||
echo -e "${YLW} -e, export ${RST}Export a list of installed Flatpak apps to a file"
|
||||
echo -e "${YLW} -i, import ${RST}Install Flatpak apps from exported file"
|
||||
echo -e "${YLW} -g, generate ${RST}Generate aliases for all installed Flatpak apps"
|
||||
echo -e "${YLW} -h, --help ${RST}Show this help"
|
||||
}
|
||||
|
||||
main() {
|
||||
local action=$1
|
||||
|
||||
case $action in
|
||||
"generate"|"-g")
|
||||
echo -en "Enter the location to save the Flatpak alias file, \n(default: ${FLATPAK_ALIAS_FILE}): "
|
||||
read -r user_alias_dir
|
||||
if [[ -n "$user_alias_dir" ]]; then
|
||||
FLATPAK_ALIAS_FILE="$user_alias_dir"
|
||||
fi
|
||||
|
||||
generate_flatpak_alias "${FLATPAK_ALIAS_FILE}"
|
||||
;;
|
||||
|
||||
"export"|"-e")
|
||||
echo -en "Enter the location to save the Flatpak export file (default: ${FLATPAK_EXPORT_FILE}): "
|
||||
read -r user_export_file
|
||||
if [[ -n "$user_export_file" ]]; then
|
||||
FLATPAK_EXPORT_FILE="$user_export_file"
|
||||
fi
|
||||
|
||||
export_flatpak_apps "${FLATPAK_EXPORT_FILE}"
|
||||
;;
|
||||
|
||||
"import"|"-i")
|
||||
echo -en "Enter the location of the Flatpak export file to import (default: ${FLATPAK_EXPORT_FILE}): "
|
||||
read -r user_export_file
|
||||
if [[ -n "$user_export_file" ]]; then
|
||||
FLATPAK_EXPORT_FILE="$user_export_file"
|
||||
fi
|
||||
|
||||
import_flatpak_apps "${FLATPAK_EXPORT_FILE}"
|
||||
;;
|
||||
"--help"|"-h")
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
show_help
|
||||
;;
|
||||
esac
|
||||
}
|
||||
main "$@"
|
||||
}
|
||||
57
config/zsh/functions/functions.zsh
Normal file
57
config/zsh/functions/functions.zsh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# SSH tunnel
|
||||
ssh-tunnel() {
|
||||
|
||||
local_port=$1 && shift
|
||||
remote_port=$1 && shift
|
||||
server=$1 && shift
|
||||
|
||||
echo "Starting SSH Tunnel for $server"
|
||||
|
||||
ssh -N -L "$local_port":localhost:"$remote_port" "$server"
|
||||
}
|
||||
|
||||
# quick wordpress in docker
|
||||
dwps() {
|
||||
image_name="wordpress-development"
|
||||
container_build_path="$HOME/Repos/Private/docker-services/wordpress"
|
||||
original_path="$PWD"
|
||||
|
||||
if [[ "$(docker images -q $image_name 2>/dev/null)" == "" ]]; then
|
||||
cd "$container_build_path"
|
||||
docker build --tag "$image_name" .
|
||||
cd "$original_path"
|
||||
fi
|
||||
|
||||
docker run -d --rm -p 3000:80 --user 1000:1000 -v "$PWD":/var/www/html --name "$image_name" "$image_name"
|
||||
}
|
||||
|
||||
# Print bottlenecks
|
||||
profzsh() {
|
||||
shell=${1-$SHELL}
|
||||
ZPROF=true $shell -i -c exit
|
||||
}
|
||||
|
||||
# Pretty Help
|
||||
alias bathelp='bat --plain --language=help'
|
||||
help() {
|
||||
"$@" --help 2>&1 | bathelp
|
||||
}
|
||||
|
||||
fzf-jq() {
|
||||
echo '' | fzf --print-query --preview="jq -r {q} <$@"
|
||||
}
|
||||
|
||||
function yy() {
|
||||
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||
\cd -- "$cwd"
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
}
|
||||
|
||||
# Zellij
|
||||
function zr() { zellij run --name "$*" -- zsh -ic "$*"; }
|
||||
function zrf() { zellij run --name "$*" --floating -- zsh -ic "$*"; }
|
||||
function ze() { zellij edit "$*"; }
|
||||
function zef() { zellij edit --floating "$*"; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue