addet base config

This commit is contained in:
pika 2024-08-20 21:35:06 +02:00
parent 19facff384
commit d3d9338abd

117
.zshrc
View file

@ -8,7 +8,6 @@ command_exists() {
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
} }
# Check if the user is root and set sudo variable if necessary # Check if the user is root and set sudo variable if necessary
check_root() { check_root() {
if [[ "${EUID}" -ne 0 ]]; then if [[ "${EUID}" -ne 0 ]]; then
@ -24,6 +23,7 @@ check_root() {
_sudo="" _sudo=""
fi fi
} }
# Load completions # Load completions
autoload -Uz compinit && compinit autoload -Uz compinit && compinit
@ -159,7 +159,109 @@ _alias(){
else else
echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --" echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --"
fi 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
# ─< 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
command clear &
fastfetch
fi
# ─< d stands for docker >──────────────────────────────────────────────────────────────────
if command_exists docker; then
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"
alias dc="docker compose"
alias appupdate="docker compose pull && docker compose up -d --force-recreate"
fi
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
if command_exists git; then
alias g="git"
alias gs="git status"
alias gm='git checkout main && git merge'
alias gc="git clone --recurse-submodule"
gcl() {
git clone --depth=1 "https://github.com/$*"
}
alias ga="git add"
alias gp="git pull --recurse-submodule"
alias gms='git maintenance start'
alias gsu="git submodule foreach git pull && git add . && git commit -m ' updated 📌submodules' && echo '-- Committed changes, pushing now..' && sleep 1 && git push"
alias gcm="git commit -m"
alias gpu="git push --recurse-submodule=on-demand"
if command_exists lazygit; then
alias lg="lazygit"
fi
fi
} }
_coding_() {
# ─< h stands for HUGO >──────────────────────────────────────────────────────────────────
if command_exists hugo; then
alias h='hugo'
alias hs='hugo server -D --noHTTPCache --disableFastRender'
fi
# ─< c stands for bin/cake >──────────────────────────────────────────────────────────────
alias cake='bin/cake'
alias c='cake'
alias cs='c server -p 1313'
# ─< VSCodium >─────────────────────────────────────────────────────────────────────────────
if command_exists codium; then
alias code="codium"
export EDITOR="codium"
fi
# ─< neovide, the best frontend for any neovim-config >───────────────────────────────────
if [ -d "$HOME/.local/share/neovide/" ]; then
if command_exists neovide; then
alias nvim='neovide --fork'
else
neovide_path=$(find "$HOME/" -name "*neovide*.appimage" 2>/dev/null)
if [ -n "$neovide_path" ]; then
alias nvim="$neovide_path --fork"
fi
fi
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 -v php >/dev/null 2>&1; then
alias phprun="php artisan serve --host=$(get_ip) --port=8000"
fi
# Check if npm is available, then create the alias
if command -v npm >/dev/null 2>&1; then
alias npmrun="npm run dev -- --host=$(get_ip) --port=8001"
fi
}
# ─< rsync >──────────────────────────────────────────────────────────────────────────────── # ─< rsync >────────────────────────────────────────────────────────────────────────────────
_rsync_() { _rsync_() {
_rrsync() { _rrsync() {
@ -253,10 +355,23 @@ get_packager() {
esac esac
} }
_tools_(){
if ! command_exists has; then
$(git clone https://github.com/kdabir/has.git /tmp/has && cd /tmp/has && sudo make install)
else
tools() {
local pkgs="bash fish git curl make cmake gcc g++ rg docker composer node npm php jre python3 go cargo"
has $pkgs
}
fi
}
main(){ main(){
get_packager get_packager
_init _init
_alias _alias
_coding_
_rsync_ _rsync_
} }
if check_root; then if check_root; then