changed some things quite a bit
This commit is contained in:
parent
ae986bd4a5
commit
9c487ce6d2
8 changed files with 817 additions and 946 deletions
|
@ -1,336 +0,0 @@
|
|||
__autopackager__() {
|
||||
. /etc/os-release
|
||||
case "$ID" in
|
||||
# Debian-based
|
||||
ubuntu | debian | pop | kali | zorin | rhinoh | raspbian)
|
||||
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-based
|
||||
arch | manjaro | endevouros | garuda)
|
||||
if command_exists paru; then
|
||||
alias search="paru -Ss"
|
||||
alias install="paru -S --noconfirm"
|
||||
alias update="paru -Syu"
|
||||
alias remove="paru -R"
|
||||
elif command_exists yay; then
|
||||
alias search="yay -Ss"
|
||||
alias install="yay -S --noconfirm"
|
||||
alias update="yay -Syu"
|
||||
alias remove="yay -R"
|
||||
else
|
||||
alias search="\$_sudo pacman -Ss"
|
||||
alias install="\$_sudo pacman -S --noconfirm"
|
||||
alias update="\$_sudo pacman -Syu"
|
||||
alias remove="\$_sudo pacman -R"
|
||||
fi
|
||||
;;
|
||||
|
||||
# RHEL-based
|
||||
fedora | centos)
|
||||
alias search="dnf search"
|
||||
alias install="\$_sudo dnf install"
|
||||
alias update="\$_sudo dnf update"
|
||||
alias remove="\$_sudo dnf remove"
|
||||
;;
|
||||
|
||||
# openSUSE
|
||||
opensuse-*)
|
||||
alias search="zypper search"
|
||||
alias install="\$_sudo zypper install --no-confirm"
|
||||
alias update="\$_sudo zypper update"
|
||||
alias remove="\$_sudo zypper remove"
|
||||
;;
|
||||
|
||||
# Alpine
|
||||
alpine)
|
||||
alias install="\$_sudo apk add"
|
||||
alias update="\$_sudo apk update && \$_sudo apk upgrade"
|
||||
alias remove="\$_sudo apk del"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_alias() {
|
||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||
|
||||
# ─< colored everything >───────────────────────────────────────────────────────────────────
|
||||
alias ip="ip --color=always"
|
||||
|
||||
# ─< easier dir up >────────────────────────────────────────────────────────────────────────
|
||||
alias ..="cd .."
|
||||
|
||||
# ─< weather >──────────────────────────────────────────────────────────────────────────────
|
||||
alias www="curl wttr.in/Ulm"
|
||||
|
||||
# ─< check for rg >─────────────────────────────────────────────────────────────────────────
|
||||
if command_exists rg; then
|
||||
alias grep="rg --color=always"
|
||||
else
|
||||
alias grep="grep --color=always"
|
||||
fi
|
||||
|
||||
# ─< linutil >────────────────────────────────────────────────────────────────────────────
|
||||
alias linutil="curl -fsSL https://christitus.com/linux | sh"
|
||||
|
||||
# ─< telnet (starwars) >────────────────────────────────────────────────────────────────────
|
||||
if command_exists telnet; then
|
||||
alias starwars="telnet -a telehack.com"
|
||||
fi
|
||||
|
||||
# ─< neovim >─────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists nvim; then
|
||||
alias cnvim="command nvim"
|
||||
if [ -d "$HOME/.config/nvchad" ]; then
|
||||
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
|
||||
fi
|
||||
fi
|
||||
|
||||
# ─< cli explorer >───────────────────────────────────────────────────────────────────────
|
||||
if command_exists yazi; then
|
||||
echo_info "yazi is the explorer of choise"
|
||||
alias lf="yazi || ya pack -i"
|
||||
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 choise"
|
||||
alias lf="ranger"
|
||||
elif command_exists lf; then
|
||||
echo_info "lf is the explorer of choise"
|
||||
fi
|
||||
|
||||
# ─< rsync >────────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists rsync; then
|
||||
alias scp="rsync -avP"
|
||||
alias cp="scp"
|
||||
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
|
||||
|
||||
# ─< t stands for trash(-cli) >───────────────────────────────────────────────────────────────
|
||||
if command_exists trash; then
|
||||
alias rm="trash"
|
||||
alias t="trash"
|
||||
alias tlist="trash -list"
|
||||
elif command_exists trash-cli; then
|
||||
alias rm="trash-cli"
|
||||
alias t="trash-cli"
|
||||
alias tlist="trash-list"
|
||||
else
|
||||
echo_error "-- You do not have trash or trash-cli installed! Your 'rm' will be permanent! --"
|
||||
fi
|
||||
|
||||
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
|
||||
if command_exists git; then
|
||||
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"
|
||||
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
|
||||
}
|
||||
alias gd="git diff"
|
||||
alias grs="git restore --staged"
|
||||
ga() {
|
||||
git diff "$@" &&
|
||||
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
|
||||
|
||||
# ─< 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
|
||||
|
||||
# ─< 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 tmux >────────────────────────────────────────────────────────────────────
|
||||
if command_exists tmux; then
|
||||
local tmux_y="$(echo '-- tmux-session active! | connecting to active session --')"
|
||||
local tmux_n="$(echo '-- no tmux-session found! | creating one --')"
|
||||
ta() {
|
||||
# command tmux list-sessions >/dev/null 2>&1
|
||||
if command tmux list-sessions >/dev/null 2>&1; then
|
||||
if command_exists notify-send; then
|
||||
notify-send "TMUX" "${tmux_y}"
|
||||
sleep 0.5
|
||||
tmux attach
|
||||
else
|
||||
echo_info "${tmux_y}"
|
||||
sleep 0.5
|
||||
tmux attach
|
||||
fi
|
||||
else
|
||||
if command_exists notify-send; then
|
||||
notify-send "TMUX" "${tmux_n}"
|
||||
sleep 0.5
|
||||
tmux
|
||||
else
|
||||
echo_info "$tmux_n"
|
||||
sleep 0.5
|
||||
tmux
|
||||
fi
|
||||
fi
|
||||
}
|
||||
alias ts="tmux source ~/.tmux.conf"
|
||||
fi
|
||||
|
||||
# ─< wireshark / termshark alias >────────────────────────────────────────────────────────
|
||||
if command_exists termshark; then
|
||||
alias ws="\$_sudo termshark"
|
||||
fi
|
||||
}
|
||||
|
||||
_coding_() {
|
||||
# ─< h stands for HUGO >──────────────────────────────────────────────────────────────────
|
||||
if command_exists hugo; then
|
||||
alias h='hugo'
|
||||
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 >─────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists codium; then
|
||||
alias code="codium"
|
||||
export EDITOR="codium"
|
||||
fi
|
||||
|
||||
# ─< neovide, the best frontend for any neovim-config >───────────────────────────────────
|
||||
if command_exists nvim; then
|
||||
alias cnvim="command nvim"
|
||||
if command_exists neovide; then
|
||||
alias nvim="neovide --fork"
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.config/nvchad" ]; then
|
||||
alias nvchad='NVIM_APPNAME="nvchad" command nvim'
|
||||
alias neochad='NVIM_APPNAME="nvchad" neovide --fork'
|
||||
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 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
|
||||
|
||||
if command_exists bc; then
|
||||
math() {
|
||||
echo "$*" | bc -l
|
||||
}
|
||||
else
|
||||
echo_error "No bc, so no math will work"
|
||||
fi
|
||||
}
|
||||
|
||||
_games() {
|
||||
if command_exists curl; then
|
||||
echo_info "Games available. Try 'alias | grep g'"
|
||||
alias g2048='bash --norc -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/games/2048.sh)"'
|
||||
alias gwordle='bash --norc -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/games/wordle.sh)"'
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
__autopackager__
|
||||
_alias "$@"
|
||||
# _coding_
|
||||
_games
|
||||
}
|
||||
|
||||
main
|
|
@ -1,133 +0,0 @@
|
|||
# ╭─────────────────────╮
|
||||
# │ set keybinding mode │
|
||||
# ╰─────────────────────╯
|
||||
# set -o emacs
|
||||
set -o bash
|
||||
# set -o vim
|
||||
|
||||
# ╭───────────────────────────────────────────────────╮
|
||||
# │ Sensible Bash - An attempt at saner Bash defaults │
|
||||
# │ Maintainer: mrzool <http://mrzool.cc> │
|
||||
# │Repository: https://github.com/mrzool/bash-sensible│
|
||||
# │ Version: 0.2.2 │
|
||||
# ╰───────────────────────────────────────────────────╯
|
||||
|
||||
# Unique Bash version check
|
||||
if ((BASH_VERSINFO[0] < 4)); then
|
||||
echo "sensible.bash: Looks like you're running an older version of Bash."
|
||||
echo "sensible.bash: You need at least bash-4.0 or some options will not work correctly."
|
||||
echo "sensible.bash: Keep your software up-to-date!"
|
||||
fi
|
||||
|
||||
## GENERAL OPTIONS ##
|
||||
|
||||
# Prevent file overwrite on stdout redirection
|
||||
# Use `>|` to force redirection to an existing file
|
||||
set -o noclobber
|
||||
|
||||
# Update window size after every command
|
||||
shopt -s checkwinsize
|
||||
|
||||
# Automatically trim long paths in the prompt (requires Bash 4.x)
|
||||
PROMPT_DIRTRIM=2
|
||||
|
||||
# Enable history expansion with space
|
||||
# E.g. typing !!<space> will replace the !! with your last command
|
||||
bind Space:magic-space
|
||||
|
||||
# Turn on recursive globbing (enables ** to recurse all directories)
|
||||
shopt -s globstar 2>/dev/null
|
||||
|
||||
# Case-insensitive globbing (used in pathname expansion)
|
||||
shopt -s nocaseglob
|
||||
|
||||
## SMARTER TAB-COMPLETION (Readline bindings) ##
|
||||
|
||||
# Perform file completion in a case insensitive fashion
|
||||
bind "set completion-ignore-case on"
|
||||
|
||||
# Treat hyphens and underscores as equivalent
|
||||
bind "set completion-map-case on"
|
||||
|
||||
# Display matches for ambiguous patterns at first tab press
|
||||
bind "set show-all-if-ambiguous on"
|
||||
|
||||
# Immediately add a trailing slash when autocompleting symlinks to directories
|
||||
bind "set mark-symlinked-directories on"
|
||||
|
||||
## SANE HISTORY DEFAULTS ##
|
||||
|
||||
# Append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# Save multi-line commands as one command
|
||||
shopt -s cmdhist
|
||||
|
||||
# Record each line as it gets issued
|
||||
PROMPT_COMMAND='history -a'
|
||||
|
||||
# Huge history. Doesn't appear to slow things down, so why not?
|
||||
HISTSIZE=500000
|
||||
HISTFILESIZE=100000
|
||||
|
||||
# Avoid duplicate entries
|
||||
HISTCONTROL="erasedups:ignoreboth"
|
||||
|
||||
# Don't record some commands
|
||||
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
|
||||
|
||||
# Use standard ISO 8601 timestamp
|
||||
# %F equivalent to %Y-%m-%d
|
||||
# %T equivalent to %H:%M:%S (24-hours format)
|
||||
HISTTIMEFORMAT='%F %T '
|
||||
|
||||
# Enable incremental history search with up/down arrows (also Readline goodness)
|
||||
# Learn more about this here: http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/
|
||||
bind '"\e[A": history-search-backward'
|
||||
bind '"\e[B": history-search-forward'
|
||||
bind '"\e[C": forward-char'
|
||||
bind '"\e[D": backward-char'
|
||||
|
||||
## BETTER DIRECTORY NAVIGATION ##
|
||||
|
||||
# Prepend cd to directory names automatically
|
||||
shopt -s autocd 2>/dev/null
|
||||
# Correct spelling errors during tab-completion
|
||||
shopt -s dirspell 2>/dev/null
|
||||
# Correct spelling errors in arguments supplied to cd
|
||||
shopt -s cdspell 2>/dev/null
|
||||
|
||||
# This defines where cd looks for targets
|
||||
# Add the directories you want to have fast access to, separated by colon
|
||||
# Ex: CDPATH=".:~:~/projects" will look for targets in the current working directory, in home and in the ~/projects folder
|
||||
CDPATH=".:~"
|
||||
|
||||
# This allows you to bookmark your favorite places across the file system
|
||||
# Define a variable containing a path and you will be able to cd into it regardless of the directory you're in
|
||||
shopt -s cdable_vars
|
||||
|
||||
# Examples:
|
||||
# export dotfiles="$HOME/dotfiles"
|
||||
# export projects="$HOME/projects"
|
||||
# export documents="$HOME/Documents"
|
||||
# export dropbox="$HOME/Dropbox"
|
||||
|
||||
# ╭───────────────╮
|
||||
# │ other configs │
|
||||
# ╰───────────────╯
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# set variable identifying the chroot you work in (used in the prompt below)
|
||||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm* | rxvt*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
|
@ -1,63 +0,0 @@
|
|||
#!/bin/bash
|
||||
# ─< Helper functions >─────────────────────────────────────────────────────────────────
|
||||
declare -a echo_messages
|
||||
|
||||
function echo_error() {
|
||||
local message="\033[0;1;31m❌ ERROR:\033[0;31m\t${*}\033[0m"
|
||||
echo -e "$message"
|
||||
echo_messages+=("$message")
|
||||
}
|
||||
|
||||
# Function to print all stored messages
|
||||
function print_echo_messages() {
|
||||
echo -e "\033[38;5;196mL\033[38;5;202mo\033[38;5;208mg\033[38;5;214m \033[38;5;220mo\033[38;5;226mu\033[38;5;118mt\033[38;5;46mp\033[38;5;48mu\033[38;5;51mt\033[38;5;45m:"
|
||||
for msg in "${echo_messages[@]}"; do
|
||||
echo -e "$msg"
|
||||
done
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
packages=(
|
||||
"brave"
|
||||
"docker"
|
||||
"neovide"
|
||||
"neovim"
|
||||
"xmrig"
|
||||
"yazi"
|
||||
"ytgo"
|
||||
)
|
||||
|
||||
_help() {
|
||||
echo "Just use _install 'packagename' to install some packages"
|
||||
echo "Available packages are:"
|
||||
echo "${packages[@]}"
|
||||
}
|
||||
|
||||
_install_func() {
|
||||
curl -fsSL "https://git.k4li.de/pika/scripts/raw/branch/main/bash/installs/${1}.sh" | sh
|
||||
}
|
||||
|
||||
_check() {
|
||||
if ! command_exists curl; then
|
||||
echo_error "curl was not found on this system!"
|
||||
echo_error "exiting now!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
_install() {
|
||||
case "$1" in
|
||||
--help | -h)
|
||||
_help
|
||||
;;
|
||||
*)
|
||||
if _check; then
|
||||
_install_func "$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
_ssh()
|
||||
{
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-)
|
||||
|
||||
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
complete -F _ssh ssh
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 5cf9b70cb0ba348a5b62792533a01f27034ebcb4
|
922
.bash_aliases
922
.bash_aliases
|
@ -1,51 +1,546 @@
|
|||
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
alias sudo="sudo -E"
|
||||
alias please="sudo"
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
# ─< easier dir up >────────────────────────────────────────────────────────────────────────
|
||||
alias ..="cd .."
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
# ─< colored ip >───────────────────────────────────────────────────────────────────
|
||||
alias ip="ip --color=always"
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
if command_exists curl; then
|
||||
# ─< linutil >────────────────────────────────────────────────────────────────────────────
|
||||
alias linutil="curl -fsSL https://christitus.com/linux | sh"
|
||||
alias "linutil-dev"="curl -fsSL https://christitus.com/linuxdev | sh"
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
# ─< weather >──────────────────────────────────────────────────────────────────────────────
|
||||
alias www="curl wttr.in/Ulm"
|
||||
else
|
||||
echo_missing "curl"
|
||||
fi
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
# ─< check for rg >─────────────────────────────────────────────────────────────────────────
|
||||
if command_exists rg; then
|
||||
alias grep="rg --color=always"
|
||||
alias hl="rg --passthrough"
|
||||
else
|
||||
echo_missing "ripgrep"
|
||||
alias grep="grep --color=always"
|
||||
alias hl="grep --passthrough"
|
||||
fi
|
||||
|
||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
# ─< define copy command >────────────────────────────────────────────────────────────────
|
||||
if command_exists wl-copy; then
|
||||
copy() {
|
||||
if cat "$1"; then
|
||||
command cat "$1" | wl-copy
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
"$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_missing "wl-clipboard | xclip"
|
||||
fi
|
||||
|
||||
# ─< 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"
|
||||
else
|
||||
echo_missing "rsync"
|
||||
fi
|
||||
|
||||
# ─< 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
|
||||
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() {
|
||||
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"
|
||||
}
|
||||
|
||||
alias lf="y || ya pack -i"
|
||||
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"
|
||||
else
|
||||
echo_missing "yazi"
|
||||
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
|
||||
echo_missing "exa | eza | lsd"
|
||||
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_missing "trash-cli"
|
||||
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"
|
||||
else
|
||||
echo_missing "bat"
|
||||
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
|
||||
else
|
||||
echo_missing "fastfetch"
|
||||
fi
|
||||
|
||||
# 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 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
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
# ─< run the function to get $_sudo >─────────────────────────────────────────────────────
|
||||
check_root
|
||||
|
||||
getPackager() {
|
||||
# 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
|
||||
|
||||
# ─< 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 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"
|
||||
|
||||
# ╭──────────────────────────────────────╮
|
||||
# │ git add with commit like.. │
|
||||
# │ `git add "<file>" "<commitmessage>"` │
|
||||
# │ .. or like `git add "<file>"` │
|
||||
# ╰──────────────────────────────────────╯
|
||||
ga() {
|
||||
if [ -n "$2" ]; then
|
||||
git diff ${1:-.}
|
||||
git add ${1:-.}
|
||||
git commit -m "$2"
|
||||
else
|
||||
git diff ${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
|
||||
}
|
||||
|
||||
[[ -f "$HOME/go/bin/lazygit" ]] &&
|
||||
alias lazygit="$HOME/go/bin/lazygit" &&
|
||||
alias lg="lazygit"
|
||||
}
|
||||
|
||||
# ─< wireshark / termshark alias >────────────────────────────────────────────────────────
|
||||
if command_exists termshark; then
|
||||
alias ws="$_sudo termshark"
|
||||
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"
|
||||
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
|
||||
|
||||
__get_Packager__() {
|
||||
# Load OS release information
|
||||
[ -f /etc/os-release ] && . /etc/os-release || return 1
|
||||
|
||||
|
@ -53,36 +548,54 @@ getPackager() {
|
|||
|
||||
case "$DISTRO" in
|
||||
*debian*)
|
||||
pkg_install() {
|
||||
if command_exists nala; then
|
||||
$_sudo nala install --assume-yes "$@"
|
||||
else
|
||||
$_sudo apt install --assume-yes "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
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"
|
||||
alias update="$_sudo apt update && $_sudo apt upgrade"
|
||||
alias remove="$_sudo apt purge"
|
||||
fi
|
||||
|
||||
alias unbreak="$_sudo dpkg --configure -a"
|
||||
alias install="pkg_install"
|
||||
;;
|
||||
*arch*)
|
||||
pkg_install() {
|
||||
if command_exists paru; then
|
||||
paru -S --color always --noconfirm --needed "$@"
|
||||
elif command_exists yay; then
|
||||
yay -S --color always --noconfirm --needed "$@"
|
||||
else
|
||||
$_sudo pacman -S --color always --noconfirm --needed "$@"
|
||||
fi
|
||||
}
|
||||
if command_exists paru; then
|
||||
alias search="paru -Ss"
|
||||
alias install="paru -S --noconfirm"
|
||||
alias update="paru -Syu"
|
||||
alias remove="paru -R"
|
||||
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"
|
||||
alias install="yay -S --noconfirm"
|
||||
alias update="yay -Syu"
|
||||
alias remove="yay -R"
|
||||
alias search="yay -Ss --color always"
|
||||
# alias install="yay -S --noconfirm --color always"
|
||||
alias update="yay -Syu --color always"
|
||||
alias remove="yay -R --color always"
|
||||
else
|
||||
alias search="$_sudo pacman -Ss"
|
||||
alias install="$_sudo pacman -S --noconfirm"
|
||||
alias update="$_sudo pacman -Syu"
|
||||
alias remove="$_sudo pacman -R"
|
||||
alias search="$_sudo pacman -Ss --color always"
|
||||
# alias install="$_sudo pacman -S --noconfirm --color always"
|
||||
alias update="$_sudo pacman -Syu --color always"
|
||||
alias remove="$_sudo pacman -R --color always"
|
||||
fi
|
||||
alias install="pkg_install"
|
||||
;;
|
||||
*rhel* | *fedora*)
|
||||
alias search="dnf search"
|
||||
|
@ -101,295 +614,38 @@ getPackager() {
|
|||
alias update="$_sudo apk update && $_sudo apk upgrade"
|
||||
alias remove="$_sudo apk del"
|
||||
;;
|
||||
*nixos*)
|
||||
echo_info "Using NIX!!"
|
||||
alias update="$_sudo nixos-rebuild switch"
|
||||
# alias install="$_sudo nix-env -iA nixos."
|
||||
install() {
|
||||
"$_sudo nix-end -iA nixos.$@"
|
||||
}
|
||||
alias edit="$_sudo -E $EDITOR /etc/nixos/configuration.nix"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported distro: $ID"
|
||||
return 1
|
||||
echo_error "Unsupported distro: $ID"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_alias_() {
|
||||
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"
|
||||
main() {
|
||||
__get_Packager__
|
||||
# ─< g stands for GIT >─────────────────────────────────────────────────────────────────────
|
||||
if command_exists git; then
|
||||
__git__
|
||||
else
|
||||
alias grep="grep --color=always"
|
||||
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
|
||||
|
||||
# ─< 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"
|
||||
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
|
||||
|
||||
# ─< 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"
|
||||
}
|
||||
|
||||
# ─< 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
|
||||
echo_missing "git"
|
||||
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 --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"
|
||||
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 -sb"
|
||||
alias gsl="git status"
|
||||
alias gm='git checkout main && git merge'
|
||||
alias gc="git clone --recurse-submodule"
|
||||
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
|
||||
}
|
||||
alias gd="git diff"
|
||||
alias ga="gd $1 && 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
|
||||
|
||||
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)"
|
||||
|
||||
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"
|
||||
__docker__
|
||||
elif command_exists podman-compose; then
|
||||
__podman__
|
||||
else
|
||||
echo_missing "docker | podman"
|
||||
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
|
||||
# ─< 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
|
||||
|
||||
cursor_exe="/mnt/c/Users/piecka/AppData/Local/Programs/cursor/Cursor.exe"
|
||||
if [ -e "$cursor_exe" ]; then
|
||||
alias code="$cursor_exe"
|
||||
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
|
||||
}
|
||||
|
||||
if command_exists composer; then
|
||||
alias laravel_new="composer create-project laravel/laravel"
|
||||
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
|
||||
}
|
||||
|
||||
getPackager
|
||||
_alias_
|
||||
_coding_
|
||||
main
|
||||
|
|
196
.bashrc
196
.bashrc
|
@ -1,36 +1,62 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# ─< Helper functions >─────────────────────────────────────────────────────────────────
|
||||
declare -a echo_messages
|
||||
# ───────────────────────────────────< Message storage >─────────────────────────────────
|
||||
declare -A _MESSAGES
|
||||
_MESSAGES=(
|
||||
[missing]=""
|
||||
[error]=""
|
||||
[warn]=""
|
||||
[info]=""
|
||||
)
|
||||
|
||||
function echo_error() {
|
||||
local message="\033[0;1;31m❌ ERROR:\033[0;31m\t${*}\033[0m"
|
||||
echo -e "$message"
|
||||
echo_messages+=("$message")
|
||||
# Define color variables
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
CYAN='\033[0;36m'
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m' # No Color
|
||||
BOLD='\033[1m'
|
||||
|
||||
# Functions to store messages
|
||||
echo_error() {
|
||||
_MESSAGES[error]+="${RED}❌ $@${NC}\n"
|
||||
}
|
||||
|
||||
function echo_warning() {
|
||||
local message="\033[0;1;33m⚠️ WARNING:\033[0;33m\t${*}\033[0m"
|
||||
echo -e "$message"
|
||||
echo_messages+=("$message")
|
||||
echo_missing() {
|
||||
_MESSAGES[missing]+="${YELLOW} $@${NC}\n"
|
||||
}
|
||||
|
||||
function echo_info() {
|
||||
local message="\033[0;1;34mℹ️ INFO:\033[0;34m\t${*}\033[0m"
|
||||
echo -e "$message"
|
||||
echo_messages+=("$message")
|
||||
echo_warning() {
|
||||
_MESSAGES[warn]+="${YELLOW}⚠️ $@${NC}\n"
|
||||
}
|
||||
|
||||
function echo_plugin() {
|
||||
local message="\033[0;1;35m🔥 Pluginmgmt:\033[0;35m\t${*} loaded\033[0m"
|
||||
echo -e "$message"
|
||||
echo_messages+=("$message")
|
||||
echo_info() {
|
||||
_MESSAGES[info]+="${CYAN}ℹ️ $@${NC}\n"
|
||||
}
|
||||
|
||||
# Function to print all stored messages
|
||||
function print_echo_messages() {
|
||||
echo -e "\033[38;5;196mL\033[38;5;202mo\033[38;5;208mg\033[38;5;214m \033[38;5;220mo\033[38;5;226mu\033[38;5;118mt\033[38;5;46mp\033[38;5;48mu\033[38;5;51mt\033[38;5;45m:"
|
||||
for msg in "${echo_messages[@]}"; do
|
||||
echo -e "$msg"
|
||||
# Display stored messages
|
||||
error_log() {
|
||||
[[ -z "${_MESSAGES[error]}${_MESSAGES[warn]}${_MESSAGES[info]}${_MESSAGES[missing]}" ]] && return 0
|
||||
|
||||
typeset -A headers colors
|
||||
headers=(
|
||||
missing "⚠️ MISSING ESSENTIALS ⚠️"
|
||||
error "❌ Errors"
|
||||
warn "⚠️ Warnings"
|
||||
info "ℹ️ Info"
|
||||
)
|
||||
colors=(
|
||||
missing "$YELLOW"
|
||||
error "$RED"
|
||||
warn "$YELLOW"
|
||||
info "$CYAN"
|
||||
)
|
||||
|
||||
for type in error warn info missing; do
|
||||
[[ -n "${_MESSAGES[$type]}" ]] && {
|
||||
printf "\n${BOLD}${colors[$type]}=== ${headers[$type]} ===${NC}\n"
|
||||
printf "${_MESSAGES[$type]}"
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -49,7 +75,7 @@ check_root() {
|
|||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_warning "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
_sudo="sudo -E"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
|
@ -81,19 +107,17 @@ _sources() {
|
|||
}
|
||||
|
||||
_init() {
|
||||
# ─< zoxide >─────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists zoxide; then
|
||||
eval "$(zoxide init bash)"
|
||||
fi
|
||||
|
||||
# ─< fzf >────────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists fzf; then
|
||||
eval "$(fzf --bash)"
|
||||
else
|
||||
echo_missing fzf
|
||||
fi
|
||||
|
||||
# ─< oh-my-posh initialization >────────────────────────────────────────────────────────────
|
||||
if command_exists oh-my-posh; then
|
||||
eval "$(oh-my-posh init bash --config "$HOME/.bash/themes/zen.toml")"
|
||||
eval "$(oh-my-posh init bash --config "$HOME/.omp.toml")"
|
||||
# eval "$(curl -fsSL https://git.k4li.de/dotfiles/oh-my-posh/raw/branch/main/zen.toml)"
|
||||
else
|
||||
if command_exists curl; then
|
||||
curl -s https://ohmyposh.dev/install.sh | $_sudo bash -s -- -d /usr/bin/
|
||||
|
@ -124,45 +148,74 @@ _init() {
|
|||
}
|
||||
|
||||
# ─< ble.sh -- https://github.com/akinomyoga/ble.sh >─────────────────────────────────────
|
||||
d_blesh() {
|
||||
for deeps in git make gawk; do
|
||||
if ! command_exists $deeps; then
|
||||
echo_error "$deeps was missing from the system, cannot setup shell properly! (blesh setup)"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
# d_blesh() {
|
||||
# for deeps in git make gawk; do
|
||||
# if ! command_exists $deeps; then
|
||||
# echo_error "$deeps was missing from the system, cannot setup shell properly! (blesh setup)"
|
||||
# exit 1
|
||||
# fi
|
||||
# done
|
||||
# }
|
||||
|
||||
i_blesh() {
|
||||
local tmp_dir="$(mktemp -d)"
|
||||
# i_blesh() {
|
||||
# local tmp_dir="$(mktemp -d)"
|
||||
#
|
||||
# cd "$tmp_dir" || echo_error "$tmp_dir is not valid!"
|
||||
# git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git
|
||||
# make -C ble.sh install PREFIX=~/.local
|
||||
# . "$HOME/.local/share/blesh/ble.sh"
|
||||
# # bash
|
||||
# # cd "$HOME" || return 0
|
||||
# }
|
||||
|
||||
cd "$tmp_dir" || echo_error "$tmp_dir is not valid!"
|
||||
git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git
|
||||
make -C ble.sh install PREFIX=~/.local
|
||||
. "$HOME/.local/share/blesh/ble.sh"
|
||||
# bash
|
||||
# cd "$HOME" || return 0
|
||||
}
|
||||
|
||||
_blesh() {
|
||||
if [ ! -f $HOME/.local/share/blesh/ble.sh ]; then
|
||||
d_blesh # Dependency check for blesh
|
||||
echo_info "Installing blesh.. Depending on your internet connection and the performance of the client, this could take a minute or two.."
|
||||
i_blesh # installing blesh silently
|
||||
else
|
||||
# . "$HOME/.local/share/blesh/ble.sh" --attach=none
|
||||
. "$HOME/.local/share/blesh/ble.sh"
|
||||
fi
|
||||
}
|
||||
# _blesh() {
|
||||
# if [ ! -f $HOME/.local/share/blesh/ble.sh ]; then
|
||||
# d_blesh # Dependency check for blesh
|
||||
# echo_info "Installing blesh.. Depending on your internet connection and the performance of the client, this could take a minute or two.."
|
||||
# i_blesh # installing blesh silently
|
||||
# else
|
||||
# # . "$HOME/.local/share/blesh/ble.sh" --attach=none
|
||||
# . "$HOME/.local/share/blesh/ble.sh"
|
||||
# fi
|
||||
# }
|
||||
|
||||
_env() {
|
||||
if command_exists nvim; then
|
||||
export EDITOR="$(which nvim)"
|
||||
elif command_exists vim; then
|
||||
export EDITOR="$(which vim)"
|
||||
elif command_exists vi; then
|
||||
export EDITOR="$(which vi)"
|
||||
fi
|
||||
local essentials=(
|
||||
neovim
|
||||
git
|
||||
docker
|
||||
zoxide
|
||||
yazi
|
||||
curl
|
||||
tmux
|
||||
)
|
||||
|
||||
for pkg in "${essentials[@]}"; do
|
||||
case $pkg in
|
||||
neovim)
|
||||
if ! command_exists nvim; then
|
||||
echo_missing "$pkg"
|
||||
else
|
||||
EDITOR=nvim
|
||||
fi
|
||||
|
||||
if [[ -z $EDITOR ]]; then
|
||||
if command_exists vim; then
|
||||
EDITOR=vim
|
||||
elif command_exists vi; then
|
||||
EDITOR=vi
|
||||
else
|
||||
echo_missing "vim & vi"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if ! command_exists $pkg; then
|
||||
echo_missing "$pkg"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
_color_prompt_() {
|
||||
|
@ -217,15 +270,22 @@ _end() {
|
|||
cowsay -f tux "$(uptime --pretty)"
|
||||
fi
|
||||
|
||||
print_echo_messages
|
||||
# ─< zoxide >─────────────────────────────────────────────────────────────────────────────
|
||||
if command_exists zoxide; then
|
||||
eval "$(zoxide init bash)"
|
||||
fi
|
||||
|
||||
error_log
|
||||
}
|
||||
|
||||
main() {
|
||||
_env
|
||||
_sources
|
||||
# _sources
|
||||
# _blesh
|
||||
_init
|
||||
[[ -e "$HOME/.bash_aliases" ]] &&
|
||||
. "$HOME/.bash_aliases"
|
||||
_color_prompt_
|
||||
_env
|
||||
check_root
|
||||
_end
|
||||
}
|
||||
|
|
100
.omp.toml
Normal file
100
.omp.toml
Normal file
|
@ -0,0 +1,100 @@
|
|||
"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
|
||||
final_space = true
|
||||
version = 3
|
||||
|
||||
[[blocks]]
|
||||
alignment = "left"
|
||||
newline = true
|
||||
type = "prompt"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#E5C07B"
|
||||
style = "plain"
|
||||
template = "[{{ .CurrentDate | date .Format }}]"
|
||||
type = "time"
|
||||
|
||||
[blocks.segments.properties]
|
||||
time_format = "15:04"
|
||||
|
||||
[[blocks.segments]]
|
||||
type = "shell"
|
||||
style = "plain"
|
||||
foreground = "#E06C75"
|
||||
template = " {{ .Name }}"
|
||||
|
||||
[blocks.segments.properties.mapped_shell_names]
|
||||
pwsh = "Shell"
|
||||
powershell = "Shell"
|
||||
cmd = "Cmd"
|
||||
bash = "Bash"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#F3C267"
|
||||
foreground_templates = [
|
||||
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
|
||||
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
|
||||
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
|
||||
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
|
||||
]
|
||||
style = "plain"
|
||||
template = " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} {{ .StashCount }}{{ end }} "
|
||||
type = "git"
|
||||
|
||||
[blocks.segments.properties]
|
||||
branch_template = "{{ trunc 25 .Branch }}"
|
||||
fetch_stash_count = true
|
||||
fetch_status = true
|
||||
fetch_upstream_icon = true
|
||||
|
||||
[[blocks]]
|
||||
alignment = "right"
|
||||
type = "prompt"
|
||||
|
||||
[[blocks.segments]]
|
||||
type = "status"
|
||||
style = "plain"
|
||||
foreground = "#b8ff75"
|
||||
foreground_templates = [ "{{ if gt .Code 0 }}#E06C75{{ end }}" ]
|
||||
template = " x{{ reason .Code }}"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#b8ff75"
|
||||
foreground_templates = [ "{{ if gt .Code 0 }}#E06C75{{ end }}" ]
|
||||
style = "diamond"
|
||||
template = " {{ .FormattedMs }} "
|
||||
type = "executiontime"
|
||||
|
||||
[blocks.segments.properties]
|
||||
style = "roundrock"
|
||||
always_enabled = true
|
||||
|
||||
[[blocks]]
|
||||
alignment = "left"
|
||||
newline = true
|
||||
type = "prompt"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#61AFEF"
|
||||
style = "plain"
|
||||
template = " {{ .Path }}"
|
||||
type = "path"
|
||||
|
||||
[blocks.segments.properties]
|
||||
style = "full"
|
||||
|
||||
[[blocks]]
|
||||
alignment = "left"
|
||||
newline = true
|
||||
type = "prompt"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#E06C75"
|
||||
style = "plain"
|
||||
template = "!"
|
||||
type = "root"
|
||||
|
||||
[[blocks.segments]]
|
||||
foreground = "#E06C75"
|
||||
style = "plain"
|
||||
template = "❯"
|
||||
type = "text"
|
Loading…
Add table
Add a link
Reference in a new issue