diff --git a/.bash/.aliases.sh b/.bash/.aliases.sh new file mode 100644 index 0000000..69d96f3 --- /dev/null +++ b/.bash/.aliases.sh @@ -0,0 +1,336 @@ +__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 diff --git a/.bash/.defaults.sh b/.bash/.defaults.sh new file mode 100644 index 0000000..1d13e3d --- /dev/null +++ b/.bash/.defaults.sh @@ -0,0 +1,133 @@ +# ╭─────────────────────╮ +# │ set keybinding mode │ +# ╰─────────────────────╯ +# set -o emacs +set -o bash +# set -o vim + +# ╭───────────────────────────────────────────────────╮ +# │ Sensible Bash - An attempt at saner Bash defaults │ +# │ Maintainer: mrzool │ +# │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 !! 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 diff --git a/.bash/.plugins.sh b/.bash/.plugins.sh new file mode 100644 index 0000000..fe0ea0d --- /dev/null +++ b/.bash/.plugins.sh @@ -0,0 +1,26 @@ +_plugins() { + local bash_dir="$HOME/.bash/plugins" + if [ -d "$bash_dir" ]; then + echo_info "Plugins will be loadet.." + + # ─< plugins to configure (usually just the filename in the plugins list) >─────────────── + local plugAutopairs="autopairs.sh" + local sshCompletion="ssh" + + # ─< active plugins >───────────────────────────────────────────────────────────────────── + plugins=( + "$plugAutopairs" + "$sshCompletion" + ) + + # ─< loop through and source the plugins >──────────────────────────────────────────────── + for plugin in "${plugins[@]}"; do + if [ -f "${bash_dir}/${plugin}" ]; then + echo_plugin "${bash_dir}/${plugin}" + . "${bash_dir}/${plugin}" + fi + done + fi +} + +_plugins diff --git a/.bashrc b/.bashrc index 22f7321..5443c39 100644 --- a/.bashrc +++ b/.bashrc @@ -60,130 +60,24 @@ check_root() { fi } -_sensible.bash_() { - # Sensible Bash - An attempt at saner Bash defaults - # Maintainer: mrzool - # Repository: https://github.com/mrzool/bash-sensible - # Version: 0.2.2 +_sources() { + local sourceDir="$HOME/.bash" + local sourceOptions=( + "aliases" + "defaults" + "installs" + ) - # 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 !! 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" + for _s in "${sourceOptions[@]}"; do + local _sourceFile="${sourceDir}/.${_s}.sh" + if [ -e "$_sourceFile" ]; then + . $_sourceFile + fi + local _source_"" + done } _init() { - # 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 - # ─< zoxide >───────────────────────────────────────────────────────────────────────────── if command_exists zoxide; then eval "$(zoxide init bash)" @@ -202,221 +96,6 @@ _init() { curl -s https://ohmyposh.dev/install.sh | $_sudo bash -s -- -d /usr/bin/ fi fi - - if [ -e "$HOME/.bash/.installs.sh" ]; then - echo_info "Git installs activated by '_install '" - . "$HOME/.bash/.installs.sh" - fi - - local bash_dir="$HOME/.bash/plugins" - if [ -d "$bash_dir" ]; then - echo_info "Plugins will be loadet.." - - # ─< plugins to configure (usually just the filename in the plugins list) >─────────────── - local plugAutopairs="autopairs.sh" - local sshCompletion="ssh" - - # ─< active plugins >───────────────────────────────────────────────────────────────────── - plugins=( - "$plugAutopairs" - "$sshCompletion" - ) - - # ─< loop through and source the plugins >──────────────────────────────────────────────── - for plugin in "${plugins[@]}"; do - if [ -f "$bash_dir/$plugin" ]; then - echo_plugin "$bash_dir/$plugin" - . "$bash_dir/$plugin" - fi - done - fi -} - -_alias() { - # ─< set keybinding mode >──────────────────────────────────────────────────────────────── - # set -o emacs - set -o bash - # set -o vim - - # If set, the pattern "**" used in a pathname expansion context will - # match all files and zero or more directories and subdirectories. - #shopt -s globstar - - 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 - - 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 - - # ─< g stands for GIT >───────────────────────────────────────────────────────────────────── - if command_exists git; then - alias g="git" - alias gs="git status -sb" - alias gc="git clone --recurse-submodule --depth=1" - 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 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 - - # ─< 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 } # ─< ble.sh -- https://github.com/akinomyoga/ble.sh >─────────────────────────────────────