addet aliases again..

This commit is contained in:
pika 2025-05-17 14:48:53 +02:00
parent a7f7a17b6f
commit 3340fdabd0
2 changed files with 581 additions and 969 deletions

View file

@ -1,117 +1,93 @@
# CAUTION: # INFO:
# ╭─────────────────────────╮ # ╭──────────╮
# │ DOES NOT GET SOURCED !! │ # │ defaults │
# ╰─────────────────────────╯ # ╰──────────╯
__getOS-Release__() { alias please="sudo"
# # Ensure _sudo is set
# [ -z "${_sudo+x}" ] && _sudo="sudo"
# Define command_exists if not already defined # ─< easier dir up >────────────────────────────────────────────────────────────────────────
# command_exists() { command -v "$1" >/dev/null 2>&1; } alias ..="cd .."
# Load OS release information # ─< colored ip >───────────────────────────────────────────────────────────────────
[ -f /etc/os-release ] && . /etc/os-release || return 1 alias ip="ip --color=always"
DISTRO="${ID}:${ID_LIKE}"
case "$DISTRO" in
*debian*)
if command_exists nala; then
alias search="nala search"
alias install="$_sudo nala install --assume-yes"
alias update="$_sudo nala update && $_sudo nala upgrade --full"
alias remove="$_sudo nala purge"
else
alias search="apt-cache search"
alias install="$_sudo apt-get install --yes"
alias update="$_sudo apt-get update && $_sudo apt-get upgrade"
alias remove="$_sudo apt-get purge"
fi
alias unbreak="$_sudo dpkg --configure -a"
;;
*arch*)
if command_exists paru; then
alias search="paru -Ss --color always"
alias install="paru -S --color always --noconfirm"
alias update="paru -Syu --color always"
alias remove="paru -R --color always"
elif command_exists yay; then
alias search="yay -Ss --color always"
alias install="yay -S --color always --noconfirm"
alias update="yay -Syu --color always"
alias remove="yay -R --color always"
else
alias search="$_sudo pacman -Ss --color always"
alias install="$_sudo pacman -S --color always --noconfirm"
alias update="$_sudo pacman -Syu --color always"
alias remove="$_sudo pacman -R --color always"
fi
;;
*rhel* | *fedora*)
alias search="dnf search"
alias install="$_sudo dnf install -y --skip-missing"
alias update="$_sudo dnf update -y"
alias remove="$_sudo dnf remove -y"
;;
*suse*)
alias search="zypper search"
alias install="$_sudo zypper install --no-confirm"
alias update="$_sudo zypper update"
alias remove="$_sudo zypper remove"
;;
*alpine*)
alias install="$_sudo apk add"
alias update="$_sudo apk update && $_sudo apk upgrade"
alias remove="$_sudo apk del"
;;
*)
echo "Unsupported distro: $ID"
return 1
;;
esac
}
_alias() {
alias please="sudo"
# ─< easier dir up >────────────────────────────────────────────────────────────────────────
alias ..="cd .."
# ─< weather >──────────────────────────────────────────────────────────────────────────────
alias www="curl wttr.in/Ulm"
# ─< colored ip >───────────────────────────────────────────────────────────────────
alias ip="ip --color=always"
# ─< check for rg >─────────────────────────────────────────────────────────────────────────
if command_exists rg; then
alias grep="rg --color=always"
else
alias grep="grep --color=always"
fi
if command_exists curl; then
# ─< linutil >──────────────────────────────────────────────────────────────────────────── # ─< linutil >────────────────────────────────────────────────────────────────────────────
alias linutil="curl -fsSL https://christitus.com/linux | sh" alias linutil="curl -fsSL https://christitus.com/linux | sh"
alias "linutil-dev"="curl -fsSL https://christitus.com/linuxdev | sh" alias "linutil-dev"="curl -fsSL https://christitus.com/linuxdev | sh"
# ─< weather >──────────────────────────────────────────────────────────────────────────────
alias www="curl wttr.in/Ulm"
else
echo_missing "curl"
fi
# ─< telnet (starwars) >──────────────────────────────────────────────────────────────────── # ─< check for rg >─────────────────────────────────────────────────────────────────────────
if command_exists telnet; then if command_exists rg; then
alias starwars="telnet -a telehack.com" alias grep="rg --color=always"
alias hl="rg --passthrough"
else
echo_missing "ripgrep"
alias grep="grep --color=always"
alias hl="grep --passthrough"
fi
# ─< define copy command >────────────────────────────────────────────────────────────────
if command_exists wl-copy; then
copy() {
if cat "$1"; then
command cat "$1" | wl-copy
else
"$1" | wl-copy
fi fi
}
elif command_exists xclip; then
copy() {
if cat "$1"; then
command cat "$1" | wl-copy
else
"$1" | xclip -selection clipboard
fi
}
else
echo_missing "wl-clipboard | xclip"
fi
[[ -f "$HOME/go/bin/lazygit" ]] && # ─< telnet (starwars) >────────────────────────────────────────────────────────────────────
alias lazygit="$HOME/go/bin/lazygit" && if command_exists telnet; then
alias lg="lazygit" alias starwars="telnet -a telehack.com"
fi
# ─< cli explorer >─────────────────────────────────────────────────────────────────────── if command_exists hyprpanel; then
if command_exists yazi; then alias get_cpu='for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done'
echo_info "yazi is the explorer of choise" fi
alias lf="yazi || ya pack -i"
# ─< rsync >────────────────────────────────────────────────────────────────────────────────
if command_exists rsync; then
alias scp="rsync -avP"
alias cp="rsync -avP"
else
echo_missing "rsync"
fi
# Set up Neovim aliases based on environment
if command_exists nvim; then
alias cnvim="command nvim"
alias nvim="$(choose_nvim)"
nv() {
NVIM_APPNAME="$1" command nvim "${@:2}"
}
if [ -d "$HOME/.config/nvdev" ]; then
alias nvdev='NVIM_APPNAME="nvdev" command nvim'
alias neodev='NVIM_APPNAME="nvdev" neovide --fork'
fi
else
echo_missing "neovim"
fi
# ─< cli explorer >───────────────────────────────────────────────────────────────────────
if command_exists yazi; then
echo_info "yazi is the explorer of choice"
# ─< yazi move when exit >────────────────────────────────────────────────────────────────
function y() { function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp" yazi "$@" --cwd-file="$tmp"
@ -120,121 +96,67 @@ _alias() {
fi fi
rm -f -- "$tmp" rm -f -- "$tmp"
} }
elif command_exists ranger; then
echo_info "ranger is the explorer of choise" alias lf="y || ya pack -i"
elif command_exists ranger; then
echo_info "ranger is the explorer of choice"
alias lf="ranger" alias lf="ranger"
elif command_exists lf; then elif command_exists lf; then
echo_info "lf is the explorer of choise" echo_info "lf is the explorer of choice"
fi else
echo_missing "yazi"
fi
# ─< rsync >──────────────────────────────────────────────────────────────────────────────── # ─< colorized ls >─────────────────────────────────────────────────────────────────────────
if command_exists rsync; then if command_exists exa; then
alias scp="rsync -avP"
alias cp="scp"
fi
# ─< colorized ls >─────────────────────────────────────────────────────────────────────────
if command_exists exa; then
alias ls="exa --icons -l --git" alias ls="exa --icons -l --git"
alias l="exa --long --no-filesize --no-permissions --no-time --git --colour-scale --icons" alias l="exa --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias ll="exa --all --long --no-filesize --no-permissions --no-time --git --colour-scale --icons" alias ll="exa --all --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias tree="exa --icons -l --tree" alias tree="exa --icons -l --tree"
elif command_exists lsd; then elif command_exists lsd; then
alias ls="lsd -l -1 -h1 --almost-all --git" alias ls="lsd -l -1 -h1 --almost-all --git"
alias l="lsd -1" alias l="lsd -1"
alias ll="lsd -1 --almost-all" alias ll="lsd -1 --almost-all"
alias clearl="command clear && l" alias clearl="command clear && l"
alias tree="lsd --tree" alias tree="lsd --tree"
elif command_exists eza; then elif command_exists eza; then
alias ls="eza --icons --long --git" alias ls="eza --icons --long --git"
alias l="eza --icons -l" alias l="eza --icons -l"
alias ll="eza --icons -laa" alias ll="eza --icons -laa"
alias tree="eza --icons -l --tree" alias tree="eza --icons -l --tree"
else else
echo_missing "exa | eza | lsd"
alias ls="ls --color=always -lAph" alias ls="ls --color=always -lAph"
alias l="ls --color=always -lph -w1" alias l="ls --color=always -lph -w1"
alias ll="ls --color=always -lph" alias ll="ls --color=always -lph"
fi fi
# Function to determine which Neovim command to use # ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
choose_nvim() { if command_exists trash; then
if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then alias rm="trash $@"
# If in a graphical environment, use Neovide
if command_exists neovide; then
echo "neovide --fork"
return
fi
elif [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
fi
# Default to nvim
echo "command nvim"
}
# Set up Neovim aliases based on environment
if command_exists nvim; then
alias cnvim="command nvim"
alias nvim="$(choose_nvim)"
if [ -d "$HOME/.config/nvchad" ]; then
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
alias neochad='NVIM_APPNAME="nvchad" neovide --fork'
fi
fi
# Tmux session manager
if command_exists tmux; then
ta() {
if tmux list-sessions >/dev/null 2>&1; then
echo "-- tmux session active! | Connecting to active session --"
sleep 0.3
tmux attach
else
echo "-- No tmux session found! | Creating one --"
sleep 0.3
tmux
fi
}
alias ts="tmux source $HOME/.tmux.conf"
fi
# ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
if command_exists trash; then
alias rm="trash"
alias t="trash" alias t="trash"
alias tlist="trash -list" elif command_exists trash-cli; then
elif command_exists trash-cli; then alias rm="trash-cli $@"
alias rm="trash-cli"
alias t="trash-cli" alias t="trash-cli"
alias tlist="trash-list" else
else echo_missing "trash-cli"
echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --" fi
fi
# ─< bat alias >──────────────────────────────────────────────────────────────────────────── # ─< bat alias >────────────────────────────────────────────────────────────────────────────
if command_exists batcat; then if command_exists batcat; then
alias cat="batcat --color=always -p --paging=never" alias cat="batcat --color=always -p --paging=never"
alias less="batcat --paging always --color=always" alias less="batcat --paging always --color=always"
elif command_exists bat; then # alias gd="batcat --diff"
elif command_exists bat; then
alias cat="bat --color=always -p" alias cat="bat --color=always -p"
alias less="bat --paging always --color=always" alias less="bat --paging always --color=always"
fi # alias gd="bat --diff"
else
echo_missing "bat"
fi
# ─< wireguard alias >──────────────────────────────────────────────────────────────────── # ─< fastfetch >────────────────────────────────────────────────────────────────────────────
if command_exists wg-quick; then if command_exists fastfetch; then
alias wgup="wg-quick up"
alias wgdown="wg-quick down"
fi
# ─< wireshark / termshark alias >────────────────────────────────────────────────────────
if command_exists termshark; then
alias ws="$_sudo termshark"
fi
# ─< fastfetch >────────────────────────────────────────────────────────────────────────────
if command_exists fastfetch; then
alias ff="fastfetch" alias ff="fastfetch"
alias clearff="command clear & fastfetch" alias clearff="command clear & fastfetch"
alias clearf="command clear & fastfetch" alias clearf="command clear & fastfetch"
@ -244,12 +166,26 @@ _alias() {
git clone https://git.k4li.de/mirrors/fastfetch.git "$HOME/.local/share/fastfetch" >/dev/null 2>&1 git clone https://git.k4li.de/mirrors/fastfetch.git "$HOME/.local/share/fastfetch" >/dev/null 2>&1
exec "$SHELL" exec "$SHELL"
fi fi
fi else
echo_missing "fastfetch"
# ─< d stands for docker >────────────────────────────────────────────────────────────────── fi
if command_exists docker; then
alias inst_lazydocker="curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash"
# INFO:
# ╭──────────────────╮
# │ containerization │
# ╰──────────────────╯
__podman__() {
alias up="podman-compose up"
alias down="podman-compose down"
alias pull="podman-compose pull"
alias dr="podman run --rm -it"
alias drs="podman-compose down && podman-compose up -d --remove-orphans --force-recreate"
alias ds="podman ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dcs="podman-compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dl="podman-compose logs -f"
alias dc="podman-compose"
}
__docker__() {
alias up="docker compose up" alias up="docker compose up"
alias down="docker compose down" alias down="docker compose down"
alias pull="docker compose pull" alias pull="docker compose pull"
@ -260,68 +196,169 @@ _alias() {
alias dcs="docker compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'" alias dcs="docker compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dl="docker compose logs -f" alias dl="docker compose logs -f"
alias dc="docker compose" alias dc="docker compose"
alias appupdate="docker compose pull && docker compose up -d --force-recreate" # check_for_updates() {
drweb() { # if ! command -v jq &>/dev/null; then
drweb_help() { # echo -e "${RED}Error: jq is required but not installed. Please install jq.${NC}"
echo "Usage: drweb <server_type> [directory] [port]" # return 1
echo " server_type: Type of server to use (nginx or php)" # fi
echo " directory: Directory to serve (default: current directory)" #
echo " port: Port to use (default: 8080)" # if ! docker compose version &>/dev/null; then
return # echo -e "${RED}Error: docker compose is not available.${NC}"
} # return 1
# fi
if [[ "$1" == "--help" || "$1" == "-h" ]]; then #
drweb_help # local updated=false
return # local images
fi # images=$(docker compose config --format json | jq -r '.services[] | .image' 2>/dev/null)
#
local server_type="$1" # if [[ -z "$images" ]]; then
local dir="${2:-./}" # echo -e "${RED}Error: No Docker images found in the compose configuration.${NC}"
local port="${3:-8080}" # return 1
# fi
if [[ ! -d "$dir" ]]; then #
echo "Error: Directory $dir does not exist" # for image in $images; do
drweb_help # echo -e "${CYAN}Checking for updates for image: ${YELLOW}$image${NC}"
return 1 #
fi # # Get local image digest
# local local_digest
case "$server_type" in # local_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}') # 2>/dev/null
nginx) #
if [[ -f "$dir/index.html" || -f "$dir/index.php" ]]; then # # If no local digest exists, force check
docker run -p "$port:80" -v "$dir:/usr/share/nginx/html:ro" nginx:alpine # if [[ -z "$local_digest" ]]; then
echo "Nginx is serving $dir on port $port" # echo -e "${YELLOW}Image not present locally. Update needed.${NC}"
# updated=true
# continue
# fi
#
# # Get remote digest using pull --dry-run
# local remote_digest
# remote_digest=$(docker pull --quiet "$image" 2>/dev/null | awk '/Digest:/{print $2}')
#
# # Fallback to manifest inspect if dry-run fails
# if [[ -z "$remote_digest" ]]; then
# remote_digest=$(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect -v "$image" | jq -r '.Descriptor.digest')
# fi
#
# if [[ -z "$remote_digest" ]]; then
# echo -e "${RED}Failed to retrieve remote digest. Performing forced check...${NC}"
# # Fallback method: Pull image and compare before/after digests
# local pre_pull_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}')
# docker pull --quiet "$image" >/dev/null
# local post_pull_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}')
#
# if [[ "$pre_pull_digest" != "$post_pull_digest" ]]; then
# echo -e "${GREEN}Update found during forced pull${NC}"
# updated=true
# fi
# continue
# fi
#
# # Compare digests
# if [[ "$local_digest" != "$remote_digest" ]]; then
# echo -e "${GREEN}Update available for $image${NC}"
# updated=true
# else
# echo -e "${YELLOW}No update available for $image${NC}"
# fi
# done
#
# if $updated; then
# echo -e "${CYAN}Pulling updates and recreating containers...${NC}"
# docker compose pull --quiet && docker compose up -d --force-recreate
# else
# echo -e "${GREEN}All images are up to date. No action needed.${NC}"
# fi
# }
# Check for required dependencies
check_for_updates() {
local compose_cmd
# Determine available compose command
if command -v docker-compose &>/dev/null; then
compose_cmd="docker-compose"
elif docker compose version &>/dev/null; then
compose_cmd="docker compose"
else else
echo "Error: No index.html or index.php found in $dir" echo "Error: docker-compose or docker compose not found."
drweb_help
return 1 return 1
fi fi
;;
php)
if [[ -f "$dir/index.php" || -f "$dir/index.html" ]]; then
docker run -p "$port:80" -v "$dir:/var/www/html" php:7.4-apache
echo "PHP Apache is serving $dir on port $port"
else
echo "Error: No index.php or index.html found in $dir"
drweb_help
return 1
fi
;;
*)
echo "Error: Unsupported server type '$server_type'"
drweb_help
return 1
;;
esac
}
fi
# ─< g stands for GIT >───────────────────────────────────────────────────────────────────── # Check for compose file
if command_exists git; then if [ ! -f docker-compose.yml ] && [ ! -f docker-compose.yaml ] && [ ! -f compose.yml ]; then
echo "Error: No docker-compose.yml/yaml found in current directory."
return 1
fi
# Pull images and capture output
local pull_output
if ! pull_output=$(LC_ALL=C $compose_cmd pull 2>&1); then
echo "Error pulling images:"
echo "$pull_output"
return 1
fi
# Check for updated images
local updated=0
if echo "$pull_output" | grep -q "Downloaded newer image"; then
updated=1
fi
# Update containers if needed
if [ $updated -eq 1 ]; then
echo "Updates found. Updating containers..."
$compose_cmd up -d
echo "Cleaning up old images..."
docker system prune -f
echo "Update completed."
else
echo "All containers are up to date. Current versions:"
$compose_cmd images | awk '{if(NR>1) print $2, $3, $4}'
fi
}
alias appupdate="check_for_updates"
if ! command_exists gmd; then
alias gmd='bash -c "$(curl -sLo- https://raw.githubusercontent.com/ajayd-san/gomanagedocker/main/install.sh)" && "$SHELL"'
fi
# ─< install lazydocker >─────────────────────────────────────────────────────────────────
alias inst_lazydocker="curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash"
}
# INFO:
# ╭─────╮
# │ git │
# ╰─────╯
__git__() {
# ─< lazygit >────────────────────────────────────────────────────────────────────────────
if command_exists lazygit; then
alias lg="lazygit"
fi
# ───────────────────────────────────────< aliases >─────────────────────────────────────
alias g="git" alias g="git"
alias gs="git status -sb" alias gs="git status -sb"
alias gsl="git status" alias gsl="git status"
alias gm='git checkout main && git merge' alias gm='git checkout main && git merge'
alias gc="git clone --recurse-submodule" alias gc="git clone --recurse-submodule"
alias gd="git diff"
# alias ga="gd $1 && git add"
alias gp='echo "${CYAN}Updating submodules..${NC}" && git submodule update --init --recursive && echo "${CYAN}Pulling down submodules..${NC}" && git pull --recurse-submodule'
alias gms='git maintenance start'
alias gcm="git commit -m"
alias gpu="git push --recurse-submodule=on-demand"
ga() {
if [ -n "$2" ]; then
git diff ${1:-.}
git add ${1:-.}
git commit -m "$2"
else
gd ${1:-.}
git add ${1:-.}
fi
}
# ──────────────────────────────────────< functions >────────────────────────────────────
gcl() { gcl() {
if [ -z "$2" ]; then if [ -z "$2" ]; then
git clone --depth=1 "https://github.com/$1" git clone --depth=1 "https://github.com/$1"
@ -343,78 +380,220 @@ _alias() {
git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1" "$2" git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1" "$2"
fi fi
} }
alias grs="git restore --staged" gsu() {
alias gd="git diff" echo "${CYAN}Updating submodules recursively with -> ${YELLOW}${BOLD}git submodule update --init --recursive${NC}"
ga() { git submodule update --init --recursive &&
git diff "$1" && echo "${CYAN}${BOLD}-- Updated submodules recursively --${NC}"
git add "$1"
} echo "${CYAN}${BOLD}-- Checking submodule branches... --${NC}"
alias gp="git pull --recurse-submodule" git submodule foreach '
alias gms='git maintenance start' echo "${RED}Submodule: $name ${NC}"
alias gsu="git submodule foreach git pull && git add . && git commit -m ' updated 📌submodules' && echo '-- Committed changes, pushing now..' && sleep 1 && git push" branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached")
alias gcm="git commit -m" if [ "$branch" = "detached" ]; then
alias gpu="git push --recurse-submodule=on-demand" default_branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch || echo "main")
if command_exists lazygit; then echo "${RED}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}"
alias lg="lazygit" git checkout $default_branch
else
echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}"
fi fi
'
echo "${CYAN}Pulling down updates recursively with -> ${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}"
git submodule foreach git pull --recurse-submodule &&
echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}"
gUpdateModules() {
if ! git diff --exit-code .; then
echo "${CYAN}${BOLD}Staging changes...${NC}"
git add . || echo "GIT ADD MISSFUNCTION"
sleep 0.3
if git commit -m " update: submodules"; then
echo "${GREEN}${BOLD}commit message ${RED}' update: submodules'${GREEN} successfully commited${NC}"
else
echo "${RED}${BOLD}Failed to commit changes.${NC}"
return 1
fi
else
echo "${GREEN}${BOLD}No changes to commit.${NC}"
return 1
fi
}
if gUpdateModules; then
if git push; then
echo "${GREEN}${BOLD}Push successful.${NC}"
else
echo "${RED}${BOLD}Failed to push changes.${NC}"
return 1
fi
fi
}
gwip() {
# Fetch the latest changes from the remote
git fetch
# Get the current branch name
local branch
branch=$(git rev-parse --abbrev-ref HEAD)
# Check if there are any changes on the remote branch
if git diff --quiet "$branch" "origin/$branch"; then
if [ -n "$2" ]; then
local commit_files="${1:-.}"
local commit_message="${2:-wip}"
else
local commit_message="${1:-wip}"
fi fi
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
git add "${commit_files:-.}"
git commit -m "$commit_message"
git push
else
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
fi
}
[[ -f "$HOME/go/bin/lazygit" ]] &&
alias lazygit="$HOME/go/bin/lazygit" &&
alias lg="lazygit"
} }
_coding_() { # ─< wireshark / termshark alias >────────────────────────────────────────────────────────
# ─< h stands for HUGO >────────────────────────────────────────────────────────────────── if command_exists termshark; then
if command_exists hugo; then alias ws="$_sudo termshark"
alias h='hugo' fi
alias hs='if [ -d ./public ]; then; echo "found public folder, cleaning it.." && command rm -rf ./public && hugo server -D --noHTTPCache --disableFastRender; else; hugo server -D --noHTTPCache --disableFastRender; fi' # --bind "$(get_ip)"'
fi
# ─< VSCodium >───────────────────────────────────────────────────────────────────────────── # ─< Function to determine which Neovim command to use >──────────────────────────────────
if command_exists codium; then choose_nvim() {
alias code="codium" if [ -n "$TMUX" ]; then
export EDITOR="codium" # If inside an active tmux session, use nvim
fi echo "command nvim"
# Function to get the IP address
get_ip() {
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
}
# Check if npm is available, then create the alias
if command_exists npm; then
npmrun() {
npmrun_help() {
echo "Usage: npmrun [environment] [optional:port]"
echo " environment: The npm environment you want to run (e.g. dev)"
echo " port: Port to use (default: 8000)"
return return
} elif [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
if [[ "$1" == "--help" || "$1" == "-h" ]]; then # If in a graphical environment, use Neovide
npmrun_help if command_exists neovide; then
echo "neovide --fork"
return return
fi fi
local env="$1"
local port="${2:-8080}"
npm run "$env" -- --host="$(get_ip)" --port="$port"
}
fi fi
# Default to nvim
echo "command nvim"
}
if command_exists bc; then # Tmux session manager
math() { if command_exists tmux; then
echo "$*" | bc -l ta() {
} if tmux list-sessions >/dev/null 2>&1; then
echo "-- tmux session active! | Connecting to active session --"
sleep 0.3
tmux attach
else else
echo_error "No bc, so no math will work" echo "-- No tmux session found! | Creating one --"
sleep 0.3
tmux
fi fi
}
alias ts="tmux source $HOME/.tmux.conf"
else
echo_missing "tmux"
fi
# Zellij session manager
# if command_exists zellij; then
# za() {
# # local zsession='zellij list-sessions | tail -1 | grep -q EXITED'
# if ! zellij list-sessions >/dev/null 2>&1; then
# echo "-- Zellij session active! | Connecting to existing session --"
# sleep 0.3
# zellij attach
# elif ! zellij list-sessions | tail -1 | grep -q EXITED; then
# echo "-- Zellij session active! | Connecting to existing session --"
# sleep 0.3
# zellij attach
# else
# echo "-- No Zellij session active! | Creating one --"
# sleep 0.3
# zellij
# fi
# }
# alias ta="za"
#
# # alias zs="zellij setup --dump-config > $HOME/.config/zellij/config.yaml"
# fi
# Function to get the IP address
get_ip() {
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
}
# ─< h stands for HUGO >──────────────────────────────────────────────────────────────────
if command_exists hugo; then
alias h='hugo'
alias hs='hugo server -D --noHTTPCache --disableFastRender' # --bind "$(get_ip)"'
fi
# Check if php is available, then create the alias
# if command_exists php; then
# alias phprun="php artisan serve --host=$(get_ip) --port=8000"
# fi
# Check if npm is available, then create the alias
# if command_exists npm; then
# npmrun() {
# npmrun_help() {
# echo "Usage: npmrun [environment] [optional:port]"
# echo " environment: The npm environment you want to run (e.g. dev)"
# echo " port: Port to use (default: 8000)"
# return
# }
# if [[ "$1" == "--help" || "$1" == "-h" ]]; then
# npmrun_help
# return
# fi
#
# local env="$1"
# local port="${2:-8080}"
#
# npm run "$env" -- --host="$(get_ip)" --port="$port"
# }
# fi
missing() {
local e=(
bash
zsh
fzf
curl
git
docker
nvim
)
for i in "$e{[@]}"; do
if ! command_exists $i; then
echo_missing "$i"
fi
done
} }
main() { main() {
__getOS-Release__ # ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
# __getPackager__ if command_exists git; then
_alias __git__
_coding_ else
echo_missing "git"
fi
# ─< d stands for docker >──────────────────────────────────────────────────────────────────
if command_exists docker; then
__docker__
elif command_exists podman-compose; then
__podman__
else
echo_missing "docker | podman"
fi
} }
main main

593
.zshrc
View file

@ -22,6 +22,7 @@ check_root() {
# ───────────────────────────────────< Message storage >───────────────────────────────── # ───────────────────────────────────< Message storage >─────────────────────────────────
typeset -A _MESSAGES typeset -A _MESSAGES
_MESSAGES=( _MESSAGES=(
[missing]=""
[error]="" [error]=""
[warn]="" [warn]=""
[info]="" [info]=""
@ -40,6 +41,10 @@ echo_error() {
_MESSAGES[error]+="${RED}$1${NC}\n" _MESSAGES[error]+="${RED}$1${NC}\n"
} }
echo_missing() {
_MESSAGES[missing]+="${YELLOW} 󱥸 $1${NC}\n"
}
echo_warning() { echo_warning() {
_MESSAGES[warn]+="${YELLOW}⚠️ $1${NC}\n" _MESSAGES[warn]+="${YELLOW}⚠️ $1${NC}\n"
} }
@ -50,21 +55,23 @@ echo_info() {
# Display stored messages # Display stored messages
error_log() { error_log() {
[[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}" ]] && return 0 [[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}${_MESSAGES[missing]}" ]] && return 0
typeset -A headers colors typeset -A headers colors
headers=( headers=(
missing "⚠️ MISSING ESSENTIALS ⚠️"
error "❌ Errors" error "❌ Errors"
warn "⚠️ Warnings" warn "⚠️ Warnings"
info " Info" info " Info"
) )
colors=( colors=(
missing "$YELLOW"
error "$RED" error "$RED"
warn "$YELLOW" warn "$YELLOW"
info "$CYAN" info "$CYAN"
) )
for type in error warn info; do for type in error warn info missing; do
[[ -n "${_MESSAGES[$type]}" ]] && { [[ -n "${_MESSAGES[$type]}" ]] && {
printf "\n${BOLD}${colors[$type]}=== ${headers[$type]} ===${NC}\n" printf "\n${BOLD}${colors[$type]}=== ${headers[$type]} ===${NC}\n"
printf "${_MESSAGES[$type]}" printf "${_MESSAGES[$type]}"
@ -162,593 +169,19 @@ __get_Packager__() {
esac esac
} }
__podman__() {
alias up="podman-compose up"
alias down="podman-compose down"
alias pull="podman-compose pull"
alias dr="podman run --rm -it"
alias drs="podman-compose down && podman-compose up -d --remove-orphans --force-recreate"
alias ds="podman ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dcs="podman-compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dl="podman-compose logs -f"
alias dc="podman-compose"
}
__docker__() {
alias up="docker compose up"
alias down="docker compose down"
alias pull="docker compose pull"
alias d="docker"
alias dr="docker run --rm -it"
alias drs="docker compose down && docker compose up -d --remove-orphans --force-recreate"
alias ds="docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dcs="docker compose ps -a --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'"
alias dl="docker compose logs -f"
alias dc="docker compose"
# check_for_updates() {
# if ! command -v jq &>/dev/null; then
# echo -e "${RED}Error: jq is required but not installed. Please install jq.${NC}"
# return 1
# fi
#
# if ! docker compose version &>/dev/null; then
# echo -e "${RED}Error: docker compose is not available.${NC}"
# return 1
# fi
#
# local updated=false
# local images
# images=$(docker compose config --format json | jq -r '.services[] | .image' 2>/dev/null)
#
# if [[ -z "$images" ]]; then
# echo -e "${RED}Error: No Docker images found in the compose configuration.${NC}"
# return 1
# fi
#
# for image in $images; do
# echo -e "${CYAN}Checking for updates for image: ${YELLOW}$image${NC}"
#
# # Get local image digest
# local local_digest
# local_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}') # 2>/dev/null
#
# # If no local digest exists, force check
# if [[ -z "$local_digest" ]]; then
# echo -e "${YELLOW}Image not present locally. Update needed.${NC}"
# updated=true
# continue
# fi
#
# # Get remote digest using pull --dry-run
# local remote_digest
# remote_digest=$(docker pull --quiet "$image" 2>/dev/null | awk '/Digest:/{print $2}')
#
# # Fallback to manifest inspect if dry-run fails
# if [[ -z "$remote_digest" ]]; then
# remote_digest=$(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect -v "$image" | jq -r '.Descriptor.digest')
# fi
#
# if [[ -z "$remote_digest" ]]; then
# echo -e "${RED}Failed to retrieve remote digest. Performing forced check...${NC}"
# # Fallback method: Pull image and compare before/after digests
# local pre_pull_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}')
# docker pull --quiet "$image" >/dev/null
# local post_pull_digest=$(docker image inspect "$image" --format '{{index .RepoDigests 0}}')
#
# if [[ "$pre_pull_digest" != "$post_pull_digest" ]]; then
# echo -e "${GREEN}Update found during forced pull${NC}"
# updated=true
# fi
# continue
# fi
#
# # Compare digests
# if [[ "$local_digest" != "$remote_digest" ]]; then
# echo -e "${GREEN}Update available for $image${NC}"
# updated=true
# else
# echo -e "${YELLOW}No update available for $image${NC}"
# fi
# done
#
# if $updated; then
# echo -e "${CYAN}Pulling updates and recreating containers...${NC}"
# docker compose pull --quiet && docker compose up -d --force-recreate
# else
# echo -e "${GREEN}All images are up to date. No action needed.${NC}"
# fi
# }
# Check for required dependencies
check_for_updates() {
local compose_cmd
# Determine available compose command
if command -v docker-compose &>/dev/null; then
compose_cmd="docker-compose"
elif docker compose version &>/dev/null; then
compose_cmd="docker compose"
else
echo "Error: docker-compose or docker compose not found."
return 1
fi
# Check for compose file
if [ ! -f docker-compose.yml ] && [ ! -f docker-compose.yaml ] && [ ! -f compose.yml ]; then
echo "Error: No docker-compose.yml/yaml found in current directory."
return 1
fi
# Pull images and capture output
local pull_output
if ! pull_output=$(LC_ALL=C $compose_cmd pull 2>&1); then
echo "Error pulling images:"
echo "$pull_output"
return 1
fi
# Check for updated images
local updated=0
if echo "$pull_output" | grep -q "Downloaded newer image"; then
updated=1
fi
# Update containers if needed
if [ $updated -eq 1 ]; then
echo "Updates found. Updating containers..."
$compose_cmd up -d
echo "Cleaning up old images..."
docker system prune -f
echo "Update completed."
else
echo "All containers are up to date. Current versions:"
$compose_cmd images | awk '{if(NR>1) print $2, $3, $4}'
fi
}
alias appupdate="check_for_updates"
if ! command_exists gmd; then
alias gmd='bash -c "$(curl -sLo- https://raw.githubusercontent.com/ajayd-san/gomanagedocker/main/install.sh)" && "$SHELL"'
fi
}
__git__() {
# ─< lazygit >────────────────────────────────────────────────────────────────────────────
if command_exists lazygit; then
alias lg="lazygit"
fi
# ───────────────────────────────────────< aliases >─────────────────────────────────────
alias g="git"
alias gs="git status -sb"
alias gsl="git status"
alias gm='git checkout main && git merge'
alias gc="git clone --recurse-submodule"
alias gd="git diff"
# alias ga="gd $1 && git add"
alias gp='echo "${CYAN}Updating submodules..${NC}" && git submodule update --init --recursive && echo "${CYAN}Pulling down submodules..${NC}" && git pull --recurse-submodule'
alias gms='git maintenance start'
alias gcm="git commit -m"
alias gpu="git push --recurse-submodule=on-demand"
ga() {
if [ -n "$2" ]; then
git diff ${1:-.}
git add ${1:-.}
git commit -m "$2"
else
gd ${1:-.}
git add ${1:-.}
fi
}
# ──────────────────────────────────────< functions >────────────────────────────────────
gcl() {
if [ -z "$2" ]; then
git clone --depth=1 "https://github.com/$1"
else
git clone --depth=1 "https://github.com/$1" "$2"
fi
}
gck() {
if [ -z "$2" ]; then
git clone --recurse-submodules --depth=1 "https://git.k4li.de/$1"
else
git clone --recurse-submodules --depth=1 "https://git.k4li.de/$1" "$2"
fi
}
gcs() {
if [ -z "$2" ]; then
git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1"
else
git clone --recurse-submodules --depth=1 "git@git.k4li.de:$1" "$2"
fi
}
gsu() {
echo "${CYAN}Updating submodules recursively with -> ${YELLOW}${BOLD}git submodule update --init --recursive${NC}"
git submodule update --init --recursive &&
echo "${CYAN}${BOLD}-- Updated submodules recursively --${NC}"
echo "${CYAN}${BOLD}-- Checking submodule branches... --${NC}"
git submodule foreach '
echo "${RED}Submodule: $name ${NC}"
branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached")
if [ "$branch" = "detached" ]; then
default_branch=$(git config -f $toplevel/.gitmodules submodule.$name.branch || echo "main")
echo "${RED}${BOLD}Submodule $name is detached. Checking out ${YELLOW} $default_branch${RED}...${NC}"
git checkout $default_branch
else
echo "${GREEN}${BOLD}Submodule $name is on branch $branch.${NC}"
fi
'
echo "${CYAN}Pulling down updates recursively with -> ${YELLOW}${BOLD}git submodule foreach git pull --recurse-submodule${NC}"
git submodule foreach git pull --recurse-submodule &&
echo "${GREEN}${BOLD}-- pulled down submodules recursively --${NC}"
gUpdateModules() {
if ! git diff --exit-code .; then
echo "${CYAN}${BOLD}Staging changes...${NC}"
git add . || echo "GIT ADD MISSFUNCTION"
sleep 0.3
if git commit -m " update: submodules"; then
echo "${GREEN}${BOLD}commit message ${RED}' update: submodules'${GREEN} successfully commited${NC}"
else
echo "${RED}${BOLD}Failed to commit changes.${NC}"
return 1
fi
else
echo "${GREEN}${BOLD}No changes to commit.${NC}"
return 1
fi
}
if gUpdateModules; then
if git push; then
echo "${GREEN}${BOLD}Push successful.${NC}"
else
echo "${RED}${BOLD}Failed to push changes.${NC}"
return 1
fi
fi
}
gwip() {
# Fetch the latest changes from the remote
git fetch
# Get the current branch name
local branch
branch=$(git rev-parse --abbrev-ref HEAD)
# Check if there are any changes on the remote branch
if git diff --quiet "$branch" "origin/$branch"; then
if [ -n "$2" ]; then
local commit_files="${1:-.}"
local commit_message="${2:-wip}"
else
local commit_message="${1:-wip}"
fi
echo "${CYAN}No changes on the remote branch. Adding changes and pushing with ${RED}${BOLD}'$commit_message'${NC}${CYAN} commit.${NC}"
git add "${commit_files:-.}"
git commit -m "$commit_message"
git push
else
echo "${RED}${BOLD}There are changes on the remote branch. Please pull the latest changes first.${NC}"
fi
}
}
__alias__() {
__get_Packager__
alias please="sudo"
alias untar="tar -xf"
# ─< easier dir up >────────────────────────────────────────────────────────────────────────
alias ..="cd .."
# ─< weather >──────────────────────────────────────────────────────────────────────────────
alias www="curl wttr.in/Ulm"
# ─< colored ip >───────────────────────────────────────────────────────────────────
alias ip="ip --color=always"
# ─< check for rg >─────────────────────────────────────────────────────────────────────────
if command_exists rg; then
alias grep="rg --color=always"
alias hl="rg --passthrough"
else
alias grep="grep --color=always"
alias hl="grep --passthrough"
fi
# ─< define copy command >────────────────────────────────────────────────────────────────
if command_exists wl-copy; then
copy() {
if cat "$1"; then
command cat "$1" | wl-copy
else
"$1" | wl-copy
fi
}
elif command_exists xclip; then
copy() {
if cat "$1"; then
command cat "$1" | wl-copy
else
"$1" | xclip -selection clipboard
fi
}
else
echo_warning "No clipboard utility found. Please install wl-copy or xclip."
fi
# ─< linutil >────────────────────────────────────────────────────────────────────────────
alias linutil="curl -fsSL https://christitus.com/linux | sh"
alias "linutil-dev"="curl -fsSL https://christitus.com/linuxdev | sh"
# ─< telnet (starwars) >────────────────────────────────────────────────────────────────────
if command_exists telnet; then
alias starwars="telnet -a telehack.com"
fi
if command_exists hyprpanel; then
alias get_cpu='for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done'
fi
# ─< rsync >────────────────────────────────────────────────────────────────────────────────
if command_exists rsync; then
alias scp="rsync -avP"
alias cp="rsync -avP"
fi
[[ -f "$HOME/go/bin/lazygit" ]] &&
alias lazygit="$HOME/go/bin/lazygit" &&
alias lg="lazygit"
# ─< cli explorer >───────────────────────────────────────────────────────────────────────
if command_exists yazi; then
echo_info "yazi is the explorer of choice"
alias lf="yazi || ya pack -i"
# ─< yazi move when exit >────────────────────────────────────────────────────────────────
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
elif command_exists ranger; then
echo_info "ranger is the explorer of choice"
alias lf="ranger"
elif command_exists lf; then
echo_info "lf is the explorer of choice"
fi
# ─< colorized ls >─────────────────────────────────────────────────────────────────────────
if command_exists exa; then
alias ls="exa --icons -l --git"
alias l="exa --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias ll="exa --all --long --no-filesize --no-permissions --no-time --git --colour-scale --icons"
alias tree="exa --icons -l --tree"
elif command_exists lsd; then
alias ls="lsd -l -1 -h1 --almost-all --git"
alias l="lsd -1"
alias ll="lsd -1 --almost-all"
alias clearl="command clear && l"
alias tree="lsd --tree"
elif command_exists eza; then
alias ls="eza --icons --long --git"
alias l="eza --icons -l"
alias ll="eza --icons -laa"
alias tree="eza --icons -l --tree"
else
alias ls="ls --color=always -lAph"
alias l="ls --color=always -lph -w1"
alias ll="ls --color=always -lph"
fi
# ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
if command_exists trash; then
alias rm="trash $@"
alias t="trash"
elif command_exists trash-cli; then
alias rm="trash-cli $@"
alias t="trash-cli"
else
echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --"
fi
# ─< bat alias >────────────────────────────────────────────────────────────────────────────
if command_exists batcat; then
alias cat="batcat --color=always -p --paging=never"
alias less="batcat --paging always --color=always"
# alias gd="batcat --diff"
elif command_exists bat; then
alias cat="bat --color=always -p"
alias less="bat --paging always --color=always"
# alias gd="bat --diff"
fi
# ─< wireshark / termshark alias >────────────────────────────────────────────────────────
if command_exists termshark; then
alias ws="$_sudo termshark"
fi
# ─< fastfetch >────────────────────────────────────────────────────────────────────────────
if command_exists fastfetch; then
alias ff="fastfetch"
alias clearff="command clear & fastfetch"
alias clearf="command clear & fastfetch"
if fastfetch --config os >/dev/null 2>&1; then
alias f="fastfetch --config os"
else
git clone https://git.k4li.de/mirrors/fastfetch.git "$HOME/.local/share/fastfetch" >/dev/null 2>&1
exec "$SHELL"
fi
fi
# ─< d stands for docker >──────────────────────────────────────────────────────────────────
if command_exists docker; then
echo_warning "󰡨 Using docker!"
__docker__
elif command_exists podman-compose; then
echo_warning " Using podman!! "
__podman__
fi
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
if command_exists git; then
__git__
fi
# ─< install lazydocker >─────────────────────────────────────────────────────────────────
alias inst_lazydocker="curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash"
# ─< Function to determine which Neovim command to use >──────────────────────────────────
choose_nvim() {
if [ -n "$TMUX" ]; then
# If inside an active tmux session, use nvim
echo "command nvim"
return
elif [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ]; then
# If in a graphical environment, use Neovide
if command_exists neovide; then
echo "neovide --fork"
return
fi
fi
# Default to nvim
echo "command nvim"
}
# Set up Neovim aliases based on environment
if command_exists nvim; then
alias cnvim="command nvim"
alias nvim="$(choose_nvim)"
nv() {
NVIM_APPNAME="$1" command nvim "${@:2}"
}
if [ -d "$HOME/.config/nvdev" ]; then
alias nvdev='NVIM_APPNAME="nvdev" command nvim'
alias neodev='NVIM_APPNAME="nvdev" neovide --fork'
fi
fi
# Tmux session manager
if command_exists tmux; then
ta() {
if tmux list-sessions >/dev/null 2>&1; then
echo "-- tmux session active! | Connecting to active session --"
sleep 0.3
tmux attach
else
echo "-- No tmux session found! | Creating one --"
sleep 0.3
tmux
fi
}
alias ts="tmux source $HOME/.tmux.conf"
fi
# Zellij session manager
# if command_exists zellij; then
# za() {
# # local zsession='zellij list-sessions | tail -1 | grep -q EXITED'
# if ! zellij list-sessions >/dev/null 2>&1; then
# echo "-- Zellij session active! | Connecting to existing session --"
# sleep 0.3
# zellij attach
# elif ! zellij list-sessions | tail -1 | grep -q EXITED; then
# echo "-- Zellij session active! | Connecting to existing session --"
# sleep 0.3
# zellij attach
# else
# echo "-- No Zellij session active! | Creating one --"
# sleep 0.3
# zellij
# fi
# }
# alias ta="za"
#
# # alias zs="zellij setup --dump-config > $HOME/.config/zellij/config.yaml"
# fi
}
_coding_() {
# ─< h stands for HUGO >──────────────────────────────────────────────────────────────────
if command_exists hugo; then
alias h='hugo'
alias hs='hugo server -D --noHTTPCache --disableFastRender' # --bind "$(get_ip)"'
fi
# ─< VSCodium >─────────────────────────────────────────────────────────────────────────────
if command_exists codium; then
alias code="codium"
export EDITOR="codium"
fi
# Function to get the IP address
get_ip() {
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
}
# Check if php is available, then create the alias
if command_exists php; then
alias phprun="php artisan serve --host=$(get_ip) --port=8000"
fi
# Check if npm is available, then create the alias
if command_exists npm; then
npmrun() {
npmrun_help() {
echo "Usage: npmrun [environment] [optional:port]"
echo " environment: The npm environment you want to run (e.g. dev)"
echo " port: Port to use (default: 8000)"
return
}
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
npmrun_help
return
fi
local env="$1"
local port="${2:-8080}"
npm run "$env" -- --host="$(get_ip)" --port="$port"
}
fi
}
__sources__() { __sources__() {
# if [ -e "$HOME/.bash_aliases" ]; then
# echo_info "Loadet bash_aliases"
# . "$HOME/.bash_aliases"
# else
# if command_exists curl; then
# curl -fsSL https://git.k4li.de/dotfiles/bash/raw/branch/main/.bash_aliases -o "$HOME/.bash_aliases"
# echo_info "(Down)loadet bash_aliases"
# . "$HOME/.bash_aliases"
# else
# echo_warning "Couldn't setup aliases properly.."
# fi
# fi
local sourceDir="$HOME/.zsh" local sourceDir="$HOME/.zsh"
local sourceOptions=( local sourceOptions=(
# "defaults" # "defaults"
"plugins" "plugins"
"installs" "installs"
"aliases"
) )
for _s in "${sourceOptions[@]}"; do for i in "${sourceOptions[@]}"; do
local _source_="${sourceDir}/.${_s}.zsh" if [ -e "${sourceDir}/.$i.zsh" ]; then
if [ -e "$_source_" ]; then . "${sourceDir}/.$i.zsh"
. $_source_
fi fi
local _source_""
done done
} }