More stow refactoring; now actually including bashrc

This commit is contained in:
2025-06-18 14:36:56 +02:00
parent 4a425ec8f1
commit 45b952f37a
12 changed files with 2259 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
#
# eza aliases
#
alias ll='eza -l'
alias la='eza -la'
alias lll='eza -la -T -l --level=3'
alias lla='eza -laF'
alias la='eza -A'
alias l='eza -CF'
#
## Git aliases
#
alias g='git'
alias gs='git status'
alias ga='git add'
alias gaa='git add --all'
alias gc='git commit'
alias gcm='git commit -m'
alias gca='git commit --amend'
alias gco='git checkout'
alias gcb='git checkout -b'
alias gcp='git cherry-pick'
alias gcl='git clone'
alias gplr='git pull --rebase'
alias gpl='git pull'
alias gpo='git push origin'
alias gpf='git push --force'
# git log aliases
alias glog='git log --oneline --graph --decorate'
alias gloga='git log --oneline --graph --decorate --all'
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
#termbin
alias tb='nc termbin.com 9999'
# get error messages from journalctl
alias jerr='journalctl -p 3 -xb'
# get warning messages from journalctl
alias jwarn='journalctl -p 4 -xb'
# get critical messages from journalctl
alias jcrit='journalctl -p 2 -xb'
# get emergency messages from journalctl
alias jemerg='journalctl -p 0 -xb'
# get status of all services
alias jstat='systemctl list-units --type=service --state=running'
# get status with failed services
alias jstatf='systemctl list-units --type=service --state=failed'
# history
alias histg='history | grep'
# get my ip
alias myip='curl ifconfig.me'
#TODO: get my ipv4

View File

@@ -0,0 +1,200 @@
_poetry_f5ec5f92d1cfe4e4_complete()
{
local cur script coms opts com
COMPREPLY=()
_get_comp_words_by_ref -n : cur words
# for an alias, get the real script behind it
if [[ $(type -t ${words[0]}) == "alias" ]]; then
script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
else
script=${words[0]}
fi
# lookup for command
for word in ${words[@]:1}; do
if [[ $word != -* ]]; then
com=$word
break
fi
done
# completing for an option
if [[ ${cur} == --* ]] ; then
opts="--ansi --directory --help --no-ansi --no-cache --no-interaction --no-plugins --quiet --verbose --version"
case "$com" in
(about)
opts="${opts} "
;;
(add)
opts="${opts} --allow-prereleases --dev --dry-run --editable --extras --group --lock --optional --platform --python --source"
;;
(build)
opts="${opts} --format --output"
;;
('cache clear')
opts="${opts} --all"
;;
('cache list')
opts="${opts} "
;;
(check)
opts="${opts} --lock"
;;
(config)
opts="${opts} --list --local --unset"
;;
('debug info')
opts="${opts} "
;;
('debug resolve')
opts="${opts} --extras --install --python --tree"
;;
('env info')
opts="${opts} --executable --path"
;;
('env list')
opts="${opts} --full-path"
;;
('env remove')
opts="${opts} --all"
;;
('env use')
opts="${opts} "
;;
(export)
opts="${opts} --all-extras --dev --extras --format --only --output --with --with-credentials --without --without-hashes --without-urls"
;;
(help)
opts="${opts} "
;;
(init)
opts="${opts} --author --dependency --description --dev-dependency --license --name --python"
;;
(install)
opts="${opts} --all-extras --compile --dry-run --extras --no-dev --no-directory --no-root --only --only-root --remove-untracked --sync --with --without"
;;
(list)
opts="${opts} "
;;
(lock)
opts="${opts} --check --no-update"
;;
(new)
opts="${opts} --name --readme --src"
;;
(publish)
opts="${opts} --build --cert --client-cert --dist-dir --dry-run --password --repository --skip-existing --username"
;;
(remove)
opts="${opts} --dev --dry-run --group --lock"
;;
(run)
opts="${opts} "
;;
(search)
opts="${opts} "
;;
('self add')
opts="${opts} --allow-prereleases --dry-run --editable --extras --source"
;;
('self install')
opts="${opts} --dry-run --sync"
;;
('self lock')
opts="${opts} --check --no-update"
;;
('self remove')
opts="${opts} --dry-run"
;;
('self show')
opts="${opts} --addons --latest --outdated --tree"
;;
('self show plugins')
opts="${opts} "
;;
('self update')
opts="${opts} --dry-run --preview"
;;
(shell)
opts="${opts} "
;;
(show)
opts="${opts} --all --latest --no-dev --only --outdated --top-level --tree --why --with --without"
;;
('source add')
opts="${opts} --default --priority --secondary"
;;
('source remove')
opts="${opts} "
;;
('source show')
opts="${opts} "
;;
(update)
opts="${opts} --dry-run --lock --no-dev --only --sync --with --without"
;;
(version)
opts="${opts} --dry-run --next-phase --short"
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
__ltrim_colon_completions "$cur"
return 0;
fi
# completing for a command
if [[ $cur == $com ]]; then
coms="about add build 'cache clear' 'cache list' check config 'debug info' 'debug resolve' 'env info' 'env list' 'env remove' 'env use' export help init install list lock new publish remove run search 'self add' 'self install' 'self lock' 'self remove' 'self show' 'self show plugins' 'self update' shell show 'source add' 'source remove' 'source show' update version"
COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
__ltrim_colon_completions "$cur"
return 0
fi
}
complete -o default -F _poetry_f5ec5f92d1cfe4e4_complete poetry
complete -o default -F _poetry_f5ec5f92d1cfe4e4_complete /home/seb/.local/share/pypoetry/venv/bin/poetry

View File

@@ -0,0 +1,2 @@
export PATH="$HOME/scripts:$PATH"

View File

@@ -0,0 +1,142 @@
#!/usr/bin/env bash
### ARCHIVE EXTRACTION
# usage: ex <file>
function ex {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: ex <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
else
for n in "$@"; do
if [ -f "$n" ]; then
case "${n%,}" in
*.cbt | *.tar.bz2 | *.tar.gz | *.tar.xz | *.tbz2 | *.tgz | *.txz | *.tar)
tar xvf "$n"
;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.cbr | *.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.cbz | *.epub | *.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z | *.arj | *.cab | *.cb7 | *.chm | *.deb | *.dmg | *.iso | *.lzh | *.msi | *.pkg | *.rpm | *.udf | *.wim | *.xar)
7z x ./"$n"
;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*.cpio) cpio -id <./"$n" ;;
*.cba | *.ace) unace x ./"$n" ;;
*)
echo "ex: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
function ensure {
if [ -z "$1" ]; then
echo "Usage: ensure <command>"
else
if ! command -v $1 &>/dev/null; then
echo "$1 could not be found"
fi
fi
}
# Functions for quick base conversion in the terminal
function htd {
echo "$((0x$1))"
}
function b2d {
echo "obase=10; ibase=2; $1" | bc
}
function h2d {
echo "obase=10; ibase=16; $1" | bc
}
function b2h {
echo "obase=16; ibase=2; $1" | bc
}
function h2b {
echo "obase=2; ibase=16; $1" | bc
}
function d2h {
echo "obase=16; ibase=10; $1" | bc
}
function d2b {
echo "obase=2; ibase=10; $1" | bc
}
#The following functions provide utility for finding a file in a certain directory tree, and then cd'ing to the parent directory containing that file
# File $(search begins in users home directory
gotoh() {
cd -- "$(dirname "$(fd $1 $HOME | fzy)")"
}
# Search begins in /etc
gotoe() {
cd -- "$(dirname "$(fd $1 /etc | fzy)")"
}
# global search, but not in runtime and root dirs
#
goto() {
cd -- "$(dirname "$(fd $1 $HOME /bin /usr/local /usr /etc | fzy)")"
}
# Easier cd'ing (aliases here because they depend on dots() function being available)
# Alias for one level up
#alias ..="command cd .."
dots() {
# Extract the input argument
local input="$1"
# Ensure input consists only of dots
if [[ ! $input =~ ^\.+$ ]]; then
echo "Error: 'dots' function accepts only dots (.., ..., ...., etc.)"
return 1
fi
# Count the number of dots in the input
local depth=${#input}
# If depth is 1 (single dot), stay in the current directory
if [ "$depth" -eq 1 ]; then
return 0
fi
# Construct the relative path based on the number of dots
local path=""
for _ in $(seq 1 "$((depth - 1))"); do
path+="../"
done
# Change directory up the calculated number of levels
cd "$path" || return
}
# Aliases for multiple levels
alias ..='dots ..'
alias ...='dots ...'
alias ....='dots ....'
alias .....='dots .....'
alias ......='dots ......'