diff --git a/.bashrc b/.bashrc index 098ed06..21e262f 100644 --- a/.bashrc +++ b/.bashrc @@ -4,116 +4,115 @@ function echo_error() { echo -e "\033[0;1;31merror:\033[0;31m\t${*}\033[0m"; } function echo_binfo() { echo -e "\033[0;1;34mInfo:\033[0;34m\t${*}\033[0m"; } function echo_info() { echo -e "\033[0;35m${*}\033[0m"; } -_sensible.bash_(){ -# Sensible Bash - An attempt at saner Bash defaults -# Maintainer: mrzool -# Repository: https://github.com/mrzool/bash-sensible -# Version: 0.2.2 +_sensible.bash_() { + # 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 + # 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 ## + ## GENERAL OPTIONS ## -# Prevent file overwrite on stdout redirection -# Use `>|` to force redirection to an existing file -set -o noclobber + # 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 + # Update window size after every command + shopt -s checkwinsize -# Automatically trim long paths in the prompt (requires Bash 4.x) -PROMPT_DIRTRIM=2 + # 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 + # 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 + # 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; + # Case-insensitive globbing (used in pathname expansion) + shopt -s nocaseglob -## SMARTER TAB-COMPLETION (Readline bindings) ## + ## SMARTER TAB-COMPLETION (Readline bindings) ## -# Perform file completion in a case insensitive fashion -bind "set completion-ignore-case on" + # 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" + # 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" + # 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" + # Immediately add a trailing slash when autocompleting symlinks to directories + bind "set mark-symlinked-directories on" -## SANE HISTORY DEFAULTS ## + ## SANE HISTORY DEFAULTS ## -# Append to the history file, don't overwrite it -shopt -s histappend + # Append to the history file, don't overwrite it + shopt -s histappend -# Save multi-line commands as one command -shopt -s cmdhist + # Save multi-line commands as one command + shopt -s cmdhist -# Record each line as it gets issued -PROMPT_COMMAND='history -a' + # 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 + # Huge history. Doesn't appear to slow things down, so why not? + HISTSIZE=500000 + HISTFILESIZE=100000 -# Avoid duplicate entries -HISTCONTROL="erasedups:ignoreboth" + # Avoid duplicate entries + HISTCONTROL="erasedups:ignoreboth" -# Don't record some commands -export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear" + # 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 ' + # 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' + # 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 ## + ## 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 + # 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 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 + # 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" + # Examples: + # export dotfiles="$HOME/dotfiles" + # export projects="$HOME/projects" + # export documents="$HOME/Documents" + # export dropbox="$HOME/Dropbox" } _defaults_() { -# ─< set keybinding mode >──────────────────────────────────────────────────────────────── + # ─< set keybinding mode >──────────────────────────────────────────────────────────────── set -o emacs # set -o vim @@ -143,43 +142,42 @@ _defaults_() { fi } -plugins(){ +plugins() { if ! command_exists has; then $(git clone https://github.com/kdabir/has.git /tmp/has && cd /tmp/has && sudo make install) else - tools(){ + tools() { local pkgs="bash fish git curl make cmake gcc g++ rg docker composer node npm php jre python3 go cargo" has $pkgs } fi -# ─< ble.sh -- https://github.com/akinomyoga/ble.sh >───────────────────────────────────── + # ─< ble.sh -- https://github.com/akinomyoga/ble.sh >───────────────────────────────────── [[ -f $HOME/.local/share/blesh/ble.sh ]] && . $HOME/.local/share/blesh/ble.sh [[ ${BLE_VERSION-} ]] && ble-attach -# ─< qfc -- https://github.com/pindexis/qfc >───────────────────────────────────────────── + # ─< qfc -- https://github.com/pindexis/qfc >───────────────────────────────────────────── [[ -s "$HOME/.qfc/bin/qfc.sh" ]] && source "$HOME/.qfc/bin/qfc.sh" } _color_prompt_() { # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in - xterm-color | *-256color) color_prompt=yes ;; + xterm-color | *-256color) color_prompt=yes ;; esac - # uncomment for a colored prompt, if the terminal has the capability; turned - # off by default to not distract the user: the focus in a terminal window - # should be on the output of commands, not on the prompt - # force_color_prompt=yes + # uncomment for a colored prompt, if the terminal has the capability; turned + # off by default to not distract the user: the focus in a terminal window + # should be on the output of commands, not on the prompt + # force_color_prompt=yes - if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi + if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= fi if [ "$color_prompt" = yes ]; then @@ -188,12 +186,13 @@ _color_prompt_() { PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt - } + fi +} - # ─< check if command exists >──────────────────────────────────────────────────────────── - command_exists() { - command -v "$1" >/dev/null 2>&1 - } +# ─< check if command exists >──────────────────────────────────────────────────────────── +command_exists() { + command -v "$1" >/dev/null 2>&1 +} # ─< Silent execution >───────────────────────────────────────────────────────────────── silentexec() { @@ -313,6 +312,11 @@ _cli_qol_() { } +_games() { + alias g2048='bash -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/games/2048.sh)"' + alias gwordle='bash -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/games/wordle.sh)"' +} + # ─< t stands for trash(-cli) >─────────────────────────────────────────────────────────────── _trash() { if command_exists trash; then @@ -374,7 +378,8 @@ _fetches_() { git clone https://git.k4li.de/mirrors/fastfetch.git $HOME/.local/share/fastfetch >/dev/null 2>&1 exec $SHELL fi - command clear & fastfetch + command clear & + fastfetch fi } @@ -561,6 +566,7 @@ get_alias() { _fancy_ls_ _coding_ _fetches_ + _games } main() {