init
This commit is contained in:
111
.bash_aliases
Normal file
111
.bash_aliases
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
# ~/.bash_aliases: Custom command aliases
|
||||||
|
|
||||||
|
# Development aliases
|
||||||
|
alias srvenv="source .venv/bin/activate"
|
||||||
|
alias ..srvenv="source ../.venv/bin/activate"
|
||||||
|
alias pm="uv run manage.py"
|
||||||
|
alias bbr="bun --bun run"
|
||||||
|
alias mkgidf="git add . --intent-to-add . && git diff > git-diff.txt"
|
||||||
|
alias snano='sudo nano'
|
||||||
|
alias zed='MANGOHUD=0 /home/garand_plg/.local/bin/zed'
|
||||||
|
|
||||||
|
# System aliases
|
||||||
|
alias flush_codium="sudo killall codium && sudo rm -rf ~/.config/VSCodium/Cache && sudo rm -rf ~/.config/VSCodium/CachedData"
|
||||||
|
alias kys="shutdown now"
|
||||||
|
alias ookla="speedtest"
|
||||||
|
alias upd="sudo nala update"
|
||||||
|
alias upg="sudo nala full-upgrade"
|
||||||
|
alias snala="sudo nala"
|
||||||
|
alias btrfscheck="sudo btrfs filesystem usage / && echo && df -h /"
|
||||||
|
|
||||||
|
# Navigation aliases
|
||||||
|
alias ~='cd ~'
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
alias ....='cd ../../..'
|
||||||
|
alias .....='cd ../../../..'
|
||||||
|
|
||||||
|
# Modifies commands
|
||||||
|
alias nalaf="apt list 2>/dev/null | grep -v WARNING | cut -d'/' -f1 | fzf --multi --preview 'apt show {1} 2>/dev/null' --preview-window=down:75% | xargs -ro sudo nala install"
|
||||||
|
alias cat="batcat"
|
||||||
|
alias cp='cp -i'
|
||||||
|
alias mv='mv -i'
|
||||||
|
alias rm='trash -v'
|
||||||
|
alias mkdir='mkdir -p'
|
||||||
|
alias ps='ps auxf'
|
||||||
|
alias ping='ping -c 10'
|
||||||
|
alias less='less -R'
|
||||||
|
alias cls='clear'
|
||||||
|
alias apt-get='sudo apt-get'
|
||||||
|
alias multitail='multitail --no-repeat -c'
|
||||||
|
alias freshclam='sudo freshclam'
|
||||||
|
|
||||||
|
# Alias's for multiple directory listing commands
|
||||||
|
alias la='eza -alh --icons' # show hidden files
|
||||||
|
alias ls='eza -aF --icons --color=always' # add colors and file type extensions
|
||||||
|
alias lx='eza -lh --icons --sort=extension' # sort by extension
|
||||||
|
alias lk='eza -lh --icons --sort=size --reverse' # sort by size
|
||||||
|
alias lc='eza -lh --icons --sort=changed' # sort by change time
|
||||||
|
alias lu='eza -lh --icons --sort=accessed' # sort by access time
|
||||||
|
alias lr='eza -lh --icons --recurse' # recursive ls
|
||||||
|
alias lt='eza -lh --icons --sort=modified' # sort by date
|
||||||
|
alias lm='eza -alh --icons | more' # pipe through 'more'
|
||||||
|
alias lw='eza -xh --icons' # wide listing format
|
||||||
|
alias ll='eza -lh --icons' # long listing format
|
||||||
|
alias labc='eza -lah --icons --sort=name' # alphabetical sort
|
||||||
|
alias lf="eza -lh --icons | grep -v '^d'" # files only (przybliżenie)
|
||||||
|
alias ldir="eza -lh --icons --only-dirs" # directories only
|
||||||
|
alias lla='eza -alh --icons' # List and Hidden Files
|
||||||
|
alias las='eza -a --icons' # Hidden Files
|
||||||
|
alias lls='eza -lh --icons' # List
|
||||||
|
|
||||||
|
# alias chmod commands
|
||||||
|
alias mx='chmod a+x'
|
||||||
|
alias 000='chmod -R 000'
|
||||||
|
alias 644='chmod -R 644'
|
||||||
|
alias 666='chmod -R 666'
|
||||||
|
alias 755='chmod -R 755'
|
||||||
|
alias 777='chmod -R 777'
|
||||||
|
|
||||||
|
# Search command line history
|
||||||
|
alias h="history | grep "
|
||||||
|
|
||||||
|
# Search running processes
|
||||||
|
alias p="ps aux | grep "
|
||||||
|
alias topcpu="/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10"
|
||||||
|
|
||||||
|
# Search files in the current folder
|
||||||
|
alias f="find . | grep "
|
||||||
|
|
||||||
|
# Count all files (recursively) in the current folder
|
||||||
|
alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null"
|
||||||
|
|
||||||
|
# Alias's to show disk space and space used in a folder
|
||||||
|
alias diskspace="du -S | sort -n -r |more"
|
||||||
|
alias folders='du -h --max-depth=1'
|
||||||
|
alias folderssort='find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn'
|
||||||
|
alias tree='tree -CAhF --dirsfirst'
|
||||||
|
alias treed='tree -CAFd'
|
||||||
|
alias mountedinfo='df -hT'
|
||||||
|
|
||||||
|
# Show all logs in /var/log
|
||||||
|
alias logs="sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"
|
||||||
|
|
||||||
|
alias kssh="kitty +kitten ssh"
|
||||||
|
|
||||||
|
|
||||||
|
alias docker-clean=' \
|
||||||
|
docker container prune -f ; \
|
||||||
|
docker image prune -f ; \
|
||||||
|
docker network prune -f ; \
|
||||||
|
docker volume prune -f '
|
||||||
|
|
||||||
|
# Remove a directory and all files
|
||||||
|
alias rmd='/bin/rm --recursive --force --verbose '
|
||||||
|
|
||||||
|
# Fun aliases
|
||||||
|
alias pasjans="ttysolitaire -p 10 --no-background-color"
|
||||||
|
alias fc="fortune | cowsay"
|
||||||
|
|
||||||
|
# Network aliases
|
||||||
|
alias ssh-server="kssh garand_plg@192.168.1.156 -i ~/.ssh/hp-t640-homeserver"
|
||||||
142
.bash_functions
Normal file
142
.bash_functions
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# ~/.bash_functions: Custom bash functions
|
||||||
|
|
||||||
|
# Quick directory creation and navigation
|
||||||
|
mkcd() {
|
||||||
|
mkdir -p "$1" && cd "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract various archive formats
|
||||||
|
extract() {
|
||||||
|
for archive in "$@"; do
|
||||||
|
if [ -f "$archive" ]; then
|
||||||
|
case "$archive" in
|
||||||
|
*.tar.bz2) tar xvjf "$archive" ;;
|
||||||
|
*.tar.gz) tar xvzf "$archive" ;;
|
||||||
|
*.bz2) bunzip2 "$archive" ;;
|
||||||
|
*.rar) unrar x "$archive" ;;
|
||||||
|
*.gz) gunzip "$archive" ;;
|
||||||
|
*.tar) tar xvf "$archive" ;;
|
||||||
|
*.tbz2) tar xvjf "$archive" ;;
|
||||||
|
*.tgz) tar xvzf "$archive" ;;
|
||||||
|
*.zip) unzip "$archive" ;;
|
||||||
|
*.Z) uncompress "$archive" ;;
|
||||||
|
*.7z) 7z x "$archive" ;;
|
||||||
|
*) echo "don't know how to extract '$archive'..." ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "'$archive' is not a valid file!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find files quickly
|
||||||
|
ff() {
|
||||||
|
find . -name "*$1*" -type f
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find directories quickly
|
||||||
|
fd() {
|
||||||
|
find . -name "*$1*" -type d
|
||||||
|
}
|
||||||
|
|
||||||
|
# IP address lookup
|
||||||
|
alias whatismyip="whatsmyip"
|
||||||
|
function whatsmyip () {
|
||||||
|
# Internal IP Lookup.
|
||||||
|
if command -v ip &> /dev/null; then
|
||||||
|
echo -n "Internal IP: "
|
||||||
|
ip addr show wlan0 | grep "inet " | awk '{print $2}' | cut -d/ -f1
|
||||||
|
else
|
||||||
|
echo -n "Internal IP: "
|
||||||
|
ifconfig wlan0 | grep "inet " | awk '{print $2}'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# External IP Lookup
|
||||||
|
echo -n "External IP: "
|
||||||
|
curl -4 ifconfig.me
|
||||||
|
}
|
||||||
|
|
||||||
|
# Searches for text in all files in the current folder
|
||||||
|
ftext() {
|
||||||
|
# -i case-insensitive
|
||||||
|
# -I ignore binary files
|
||||||
|
# -H causes filename to be printed
|
||||||
|
# -r recursive search
|
||||||
|
# -n causes line number to be printed
|
||||||
|
# optional: -F treat search term as a literal, not a regular expression
|
||||||
|
# optional: -l only print filenames and not the matching lines ex. grep -irl "$1" *
|
||||||
|
grep -iIHrn --color=always "$1" . | less -r
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy file with a progress bar
|
||||||
|
cpp() {
|
||||||
|
set -e
|
||||||
|
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 |
|
||||||
|
awk '{
|
||||||
|
count += $NF
|
||||||
|
if (count % 10 == 0) {
|
||||||
|
percent = count / total_size * 100
|
||||||
|
printf "%3d%% [", percent
|
||||||
|
for (i=0;i<=percent;i++)
|
||||||
|
printf "="
|
||||||
|
printf ">"
|
||||||
|
for (i=percent;i<100;i++)
|
||||||
|
printf " "
|
||||||
|
printf "]\r"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END { print "" }' total_size="$(stat -c '%s' "${1}")" count=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy and go to the directory
|
||||||
|
cpg() {
|
||||||
|
if [ -d "$2" ]; then
|
||||||
|
cp "$1" "$2" && cd "$2"
|
||||||
|
else
|
||||||
|
cp "$1" "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Move and go to the directory
|
||||||
|
mvg() {
|
||||||
|
if [ -d "$2" ]; then
|
||||||
|
mv "$1" "$2" && cd "$2"
|
||||||
|
else
|
||||||
|
mv "$1" "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create and go to the directory
|
||||||
|
mkdirg() {
|
||||||
|
mkdir -p "$1"
|
||||||
|
cd "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Goes up a specified number of directories (i.e. up 4)
|
||||||
|
up() {
|
||||||
|
local d=""
|
||||||
|
limit=$1
|
||||||
|
for ((i = 1; i <= limit; i++)); do
|
||||||
|
d=$d/..
|
||||||
|
done
|
||||||
|
d=$(echo $d | sed 's/^\///')
|
||||||
|
if [ -z "$d" ]; then
|
||||||
|
d=..
|
||||||
|
fi
|
||||||
|
cd $d
|
||||||
|
}
|
||||||
|
|
||||||
|
# Automatically do an ls after each cd, z, or zoxide
|
||||||
|
cd ()
|
||||||
|
{
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
builtin cd "$@" && ls
|
||||||
|
else
|
||||||
|
builtin cd ~ && ls
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Returns the last 2 fields of the working directory
|
||||||
|
pwdtail() {
|
||||||
|
pwd | awk -F/ '{nlast = NF -1;print $nlast"/"$NF}'
|
||||||
|
}
|
||||||
2026
.bash_history
Normal file
2026
.bash_history
Normal file
File diff suppressed because it is too large
Load Diff
7
.bash_logout
Normal file
7
.bash_logout
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# ~/.bash_logout: executed by bash(1) when login shell exits.
|
||||||
|
|
||||||
|
# when leaving the console clear the screen to increase privacy
|
||||||
|
|
||||||
|
if [ "$SHLVL" = 1 ]; then
|
||||||
|
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
|
||||||
|
fi
|
||||||
3
.bash_profile
Normal file
3
.bash_profile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# ~/.bash_profile: executed by bash for login shells.
|
||||||
|
# Source .profile to avoid duplication
|
||||||
|
[ -f ~/.profile ] && . ~/.profile
|
||||||
94
.bashrc
Normal file
94
.bashrc
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||||
|
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
case $- in
|
||||||
|
*i*) ;;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# History configuration
|
||||||
|
HISTCONTROL=erasedups:ignoredups:ignorespace
|
||||||
|
HISTSIZE=1000
|
||||||
|
HISTFILESIZE=2000
|
||||||
|
export HISTTIMEFORMAT="%F %T"
|
||||||
|
PROMPT_COMMAND='history -a'
|
||||||
|
shopt -s histappend
|
||||||
|
|
||||||
|
# Shell options
|
||||||
|
shopt -s checkwinsize
|
||||||
|
# Uncomment to enable globstar (bash 4.0+)
|
||||||
|
# shopt -s globstar
|
||||||
|
|
||||||
|
# XDG Base Directory Specification
|
||||||
|
export XDG_DATA_HOME="$HOME/.local/share"
|
||||||
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
export XDG_STATE_HOME="$HOME/.local/state"
|
||||||
|
export XDG_CACHE_HOME="$HOME/.cache"
|
||||||
|
|
||||||
|
export EDITOR=nano
|
||||||
|
export VISUAL=codium
|
||||||
|
|
||||||
|
# Chroot detection for prompt
|
||||||
|
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
||||||
|
debian_chroot=$(cat /etc/debian_chroot)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Colored prompt configuration
|
||||||
|
case "$TERM" in
|
||||||
|
xterm-color|*-256color) color_prompt=yes;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Set prompt
|
||||||
|
if [ "$color_prompt" = yes ]; then
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
|
else
|
||||||
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||||
|
fi
|
||||||
|
unset color_prompt
|
||||||
|
|
||||||
|
# Set terminal title for xterm-compatible terminals
|
||||||
|
case "$TERM" in
|
||||||
|
xterm*|rxvt*)
|
||||||
|
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Enable color support for ls and grep
|
||||||
|
if [ -x /usr/bin/dircolors ]; then
|
||||||
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
|
# Basic ls color alias (will be overridden by eza if available)
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load custom aliases
|
||||||
|
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
|
||||||
|
|
||||||
|
# Enable bash completion
|
||||||
|
if ! shopt -oq posix; then
|
||||||
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||||
|
. /usr/share/bash-completion/bash_completion
|
||||||
|
elif [ -f /etc/bash_completion ]; then
|
||||||
|
. /etc/bash_completion
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add sbin to $PATH
|
||||||
|
export PATH=$PATH:/sbin
|
||||||
|
|
||||||
|
# Exercism completion
|
||||||
|
[ -f ~/.config/exercism/exercism_completion.bash ] && . ~/.config/exercism/exercism_completion.bash
|
||||||
|
|
||||||
|
# Show welcome info only for interactive login shells
|
||||||
|
if shopt -q login_shell && [ -t 0 ]; then
|
||||||
|
# Check if commands exist before running
|
||||||
|
command -v fastfetch >/dev/null 2>&1 && fastfetch
|
||||||
|
command -v fortune >/dev/null 2>&1 && command -v cowsay >/dev/null 2>&1 && fortune | cowsay
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -f ~/.bash_functions ] && . ~/.bash_functions
|
||||||
|
|
||||||
|
eval "$(starship init bash)"
|
||||||
|
|
||||||
42
.profile
Normal file
42
.profile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# ~/.profile: executed by the command interpreter for login shells.
|
||||||
|
|
||||||
|
# Function to safely add directories to PATH
|
||||||
|
add_to_path() {
|
||||||
|
case ":$PATH:" in
|
||||||
|
*":$1:"*) ;;
|
||||||
|
*) PATH="$1:$PATH" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add user directories to PATH
|
||||||
|
[ -d "$HOME/.local/bin" ] && add_to_path "$HOME/.local/bin"
|
||||||
|
|
||||||
|
# Cargo (Rust)
|
||||||
|
if [ -f "$HOME/.cargo/env" ]; then
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
|
add_to_path "$HOME/.cargo/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Bun
|
||||||
|
if [ -d "$HOME/.bun" ]; then
|
||||||
|
export BUN_INSTALL="$HOME/.bun"
|
||||||
|
add_to_path "$BUN_INSTALL/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Custom local environment
|
||||||
|
[ -f "$HOME/.local/bin/env" ] && . "$HOME/.local/bin/env"
|
||||||
|
|
||||||
|
# Rust library path
|
||||||
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"
|
||||||
|
|
||||||
|
# Wayland configuration
|
||||||
|
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||||
|
systemctl --user import-environment DISPLAY WAYLAND_DISPLAY
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load bashrc for bash shells
|
||||||
|
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then
|
||||||
|
. "$HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH
|
||||||
Reference in New Issue
Block a user