diff --git a/.bash_aliases b/.bash_aliases index caa1ade..086eb85 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,8 +1,5 @@ #!/bin/bash -echo 'bash_aliases' - - # improve ls hash gls >/dev/null 2>&1 || alias gls="ls" if gls --color > /dev/null 2>&1; then colorflag="--color"; else colorflag="-G"; fi; @@ -28,29 +25,32 @@ alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' alias cs='config status' # Kubernetes -# alias kubectl='microk8s kubectl' # better bash autocompletion # sudo snap alias microk8s.kubectl mk # source <(mk completion bash | sed "s/kubectl/mk/g") -alias awslocal='aws --endpoint-url http://localhost:4566 --profile test --region eu-central-1' # k3s -export KUBECONFIG=~/.kube/config alias k=kubectl alias kn='kubectl config set-context --current --namespace' -export CR_PAT=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 complete -F __start_kubectl k -alias awslocal='aws --endpoint-url=http://localhost:4566' -alias t='todo.sh' alias dcl='docker container ls' -alias yank='yank-cli' -export DOMAIN='homelab.com' -k_ns_clean () { - kubectl get namespace $1 -o json \ - | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \ - | kubectl replace --raw /api/v1/namespaces/$1/finalize -f - -} +alias g='git' + +# Enable tab completion for `g` by marking it as an alias for `git` +if type __git_complete &> /dev/null; then + __git_complete g __git_main +fi; + +alias pnpx="pnpm dlx" + + + +# Pipe my public key to my clipboard. +alias pubkey="more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'" + +# Pipe my private key to my clipboard. +alias prikey="more ~/.ssh/id_ed25519 | xclip -selection clipboard | echo '=> Private key copied to pasteboard.'" diff --git a/.bash_profile b/.bash_profile index eefbed8..eca5085 100644 --- a/.bash_profile +++ b/.bash_profile @@ -2,8 +2,12 @@ echo 'bash_profile' -# include .bashrc if it exists -[ -f "$HOME/.bashrc" ] && . "$HOME/.bashrc" +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi alias g='git' @@ -29,7 +33,6 @@ if [ -f $HOME/linuxbrew/.linuxbrew/bin/brew ]; then eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) fi -export PATH="$HOME/.poetry/bin:$PATH" if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init --path)" eval "$(pyenv init -)" @@ -38,3 +41,38 @@ fi if [ -f $HOME/.cargo/env ]; then . "$HOME/.cargo/env" fi + +#!/bin/bash + + +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + + +export PATH="$HOME/.poetry/bin:$PATH" +z \ No newline at end of file diff --git a/.bash_prompt b/.bash_prompt index 4c27f45..00691fd 100644 --- a/.bash_prompt +++ b/.bash_prompt @@ -1,6 +1,6 @@ #!/bin/bash - +# Function to display Git repository status in prompt prompt_git() { local s=''; local branchName=''; @@ -52,11 +52,14 @@ prompt_git() { fi; } +# Detect if running in a cloud environment cloud="" if [[ -f /proc/cpuinfo ]] && grep -q "^flags.* hypervisor" /proc/cpuinfo && [[ ! -d "/mnt/c/Windows/" ]]; then cloud="☁️ " fi +# Terminal color setup +# Check if terminal supports colors, then set color variables if tput setaf 1 &> /dev/null; then tput sgr0; # reset colors bold=$(tput bold); @@ -90,57 +93,45 @@ white="\\e[1;37m"; yellow="\\e[1;33m"; fi; -# Highlight the user name when logged in as root. -if [[ "${USER}" == "root" ]]; then -userStyle="${red}"; -else -userStyle="${blue}"; -fi; +# User and Host styling for prompt +# Red for root user, blue for others +[[ "${USER}" == "root" ]] && userStyle="${red}" || userStyle="${blue}" -# Highlight the hostname when connected via SSH. -if [[ "${SSH_TTY}" ]]; then -hostStyle="${bold}${cyan}"; -else -hostStyle="${cyan}"; -fi; +# Cyan for SSH sessions, regular otherwise +[[ "${SSH_TTY}" ]] && hostStyle="${bold}${cyan}" || hostStyle="${cyan}" + +# PS1: Main prompt string setup +PS1="\\[\\033]0;\\w\\007\\]" # Set terminal title to current directory +PS1+="\\[${bold}\\]\\n" # Newline +PS1+="\\[${userStyle}\\]\\u" # Username +PS1+="\\[${white}\\] at " +PS1+="\\[${hostStyle}\\]${cloud}\\h" # Hostname +PS1+="\\[${white}\\] in " +PS1+="\\[${green}\\]\\w" # Working directory +PS1+="\$(prompt_git \"${white} on ${violet}\")" # Git details +PS1+="\\n" +PS1+="\\[${white}\\]\$ \\[${reset}\\]" # `$` prompt and reset color +export PS1 + +# PS2: Secondary prompt string setup +PS2="\\[${yellow}\\]→ \\[${reset}\\]" +export PS2 -# Set the terminal title to the current working directory. -PS1="\\[\\033]0;\\w\\007\\]"; -PS1+="\\[${bold}\\]\\n"; # newline -PS1+="\\[${userStyle}\\]\\u"; # username -PS1+="\\[${white}\\] at "; -PS1+="\\[${hostStyle}\\]${cloud}\\h"; # host -PS1+="\\[${white}\\] in "; -PS1+="\\[${green}\\]\\w"; # working directory -PS1+="\$(prompt_git \"${white} on ${violet}\")"; # Git repository details -PS1+="\\n"; -PS1+="\\[${white}\\]\$ \\[${reset}\\]"; # `$` (and reset color) -export PS1; - -PS2="\\[${yellow}\\]→ \\[${reset}\\]"; -export PS2; -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in -xterm-color|*-256color) -color_prompt=yes -;; -*) -;; -esac -# If this is an xterm set the title to user@host:dir +# Terminal color support check for xterm case "$TERM" in -xterm*|rxvt*) -PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" -;; -*) -;; + xterm-color|*-256color) + color_prompt=yes + ;; + *) + ;; esac -# Powerline configuration -if [ -f $HOME/.local/lib/python3.8/site-packages/powerline/bindings/bash/powerline.sh ]; then -$HOME/.local/bin/powerline-daemon -q -POWERLINE_BASH_CONTINUATION=1 -POWERLINE_BASH_SELECT=1 -source $HOME/.local/lib/python3.8/site-packages/powerline/bindings/bash/powerline.sh -fi +# Terminal title configuration for xterm and rxvt +case "$TERM" in + xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; + *) + ;; +esac \ No newline at end of file diff --git a/.bashrc b/.bashrc index 727756a..bfe663b 100644 --- a/.bashrc +++ b/.bashrc @@ -1,12 +1,12 @@ #!/bin/bash -# If not running interactively, don't do anything +# Ensure script runs only in interactive mode case $- in *i*) ;; - *) return;; + *) return;; esac -# Detect os +# OS Detection export OS_NAME="" case "$OSTYPE" in linux*) OS_NAME='linux' ;; @@ -17,108 +17,68 @@ case "$OSTYPE" in *) echo "unknown OS: $OSTYPE" ;; esac +# Shell Options +shopt -s histappend # Append to history file, don't overwrite +shopt -s checkwinsize # Update LINES and COLUMNS +shopt -s globstar # Match files and directories with '**' +shopt -s nocaseglob # Case-insensitive globbing +shopt -s cdspell # Autocorrect typos in path names +shopt -s cmdhist # Save multi-line commands as single history entry +shopt -s dirspell 2> /dev/null # Attempt spelling correction on directory names -# append to the history file, don't overwrite it -shopt -s histappend -# update the values of LINES and COLUMNS. -shopt -s checkwinsize -# match all files and zero or more directories and subdirectories. -shopt -s globstar -# Case-insensitive globbing (used in pathname expansion) -shopt -s nocaseglob -# Autocorrect typos in path names when using `cd` -shopt -s cdspell -# Bash save all lines of a multipe-line command in the same history entry -shopt -s cmdhist -# If set, Bash attempts spelling correction on directory names -# during word completion if the directory name initially supplied does not exist. -shopt -s dirspell 2> /dev/null -# If set, the pattern ‘**’ used in a filename expansion context will match a files -# and zero or more directories and subdirectories. If the pattern is followed by a ‘/’, only directories and subdirectories match. -shopt -s globstar 2> /dev/null - -# if $(type fzf > /dev/null); then -type shopt &> /dev/null && shopt -s histappend # append to history, don't overwrite it - -# enable programmable completion features +# Programmable 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 + [ -f /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion + [ -f /etc/bash_completion ] && . /etc/bash_completion fi -# make less more friendly for non-text input files, see lesspipe(1) +# Set up less for non-text input files [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" -# set variable identifying the chroot you work in (used in the prompt below) +# Configure chroot environment variable if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi -# Enable autocomplete in SSH config -[[ -e "$HOME/.ssh/config" ]] && complete -o "default" \ - -o "nospace" \ - -W "$(grep "^Host" ~/.ssh/config | \ - grep -v "[?*]" | cut -d " " -f2 | \ - tr ' ' '\n')" scp sftp ssh +# SSH Config Autocomplete +[[ -e "$HOME/.ssh/config" ]] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh +# Source external files [ -f "$HOME/.bash_prompt" ] && . "$HOME/.bash_prompt" [ -f "$HOME/.path" ] && . "$HOME/.path" [ -f "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases" [ -f "$HOME/.functions" ] && . "$HOME/.functions" -[ -f "$HOME/.path" ] && . "$HOME/.path" [ -f "$HOME/.dockerfunc" ] && . "$HOME/.dockerfunc" [ -f "$HOME/.exports" ] && . "$HOME/.exports" [ -f "$HOME/.extra" ] && . "$HOME/.extra" -export HISTCONTROL=ignoredups:erasedups -shopt -s histappend +# History Configuration export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" - -# Test if MacSO -which brew > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - [ ! -f `brew --prefix`/etc/bash_completion ] || . `brew --prefix`/etc/bash_completion +# MacOS-specific configuration +if type brew &>/dev/null; then + [ -f `brew --prefix`/etc/bash_completion ] && . `brew --prefix`/etc/bash_completion fi -unset PROMPT_COMMAND - -complete -C /usr/local/bin/bit bit +# Kubectl completion source <(kubectl completion bash) -export PATH="~/anaconda3/bin":$PATH + +# Rust Environment if [ -f $HOME/.cargo/env ]; then . "$HOME/.cargo/env" fi -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 -export LANGUAGE=en_US.UTF-8 - -# powerline -if [ -f `which powerline-daemon` ]; then +# Powerline Configuration +if type powerline-daemon &>/dev/null; then powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 -fi -if [ -f /home/jp/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh ]; then - source /home/jp/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh + [ -f /home/jp/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh ] && source /home/jp/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh fi -reset_nordvpn() { - sudo iptables -F INPUT - sudo iptables -F OUTPUT - sudo iptables -P OUTPUT ACCEPT -} - -# pnpm -export PNPM_HOME="/home/jp/.local/share/pnpm" +# PNPM Configuration case ":$PATH:" in *":$PNPM_HOME:"*) ;; *) export PATH="$PNPM_HOME:$PATH" ;; esac -# pnpm end - alias pnpx="pnpm dlx" diff --git a/.exports b/.exports index eb528e9..a4a3371 100644 --- a/.exports +++ b/.exports @@ -1,17 +1,22 @@ #!/bin/bash -# don't put duplicate lines or lines starting with space in the history. -export HISTCONTROL=ignoreboth +# Bash history settings +export HISTCONTROL=ignoredups:erasedups +export HISTSIZE=1000 # Number of commands to remember in history +export HISTFILESIZE=2000 # Maximum size of the history file +export HISTTIMEFORMAT='%F %T ' # Timestamp format for history entries +export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear" # Patterns to ignore in history -export HISTSIZE=1000 -export HISTFILESIZE=2000 -export HISTTIMEFORMAT='%F %T ' -export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear" - - -export EDITOR=vim -export LC_ALL=en_US.UTF-8 -export VISUAL=vim -export LANG=en_US.UTF-8 +# System environment settings +export EDITOR=vim # Default text editor +export VISUAL=vim # Default editor for visually-oriented programs +export LC_ALL=en_US.UTF-8 # Character encoding settings +export LANG=en_US.UTF-8 # Language/region setting (US English) +export LANGUAGE=en_US.UTF-8 +export PNPM_HOME="/home/jp/.local/share/pnpm" +export DOMAIN='homelab.com' +export KUBECONFIG=~/.kube/config +export PYENV_ROOT="$HOME/.pyenv" +export PYENV_ROOT="$HOME/.pyenv" diff --git a/.extra b/.extra index ed4d75c..419c94f 100644 --- a/.extra +++ b/.extra @@ -1,7 +1,5 @@ #!/bin/bash -echo 'extra' - if [ hash foo 2>/dev/null ]; then eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" @@ -11,6 +9,8 @@ fi [ -f ${HOME}/.bash.d/cht.sh ] && . ${HOME}/.bash.d/cht.sh [ -f ~/.fzf.bash ] && source ~/.fzf.bash -hash setxkbmap 2>/dev/null && setxkbmap -option caps:swapescape || echo "not esc remapping" - -export LOCALAI=http://10.42.0.111:8080 +reset_nordvpn() { + sudo iptables -F INPUT + sudo iptables -F OUTPUT + sudo iptables -P OUTPUT ACCEPT +} diff --git a/.functions b/.functions index 492916f..a0997b6 100644 --- a/.functions +++ b/.functions @@ -27,12 +27,6 @@ cp2() { rsync -WavP --human-readable --progress $1 $2 } -# Pipe my public key to my clipboard. -alias pubkey="more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'" - -# Pipe my private key to my clipboard. -alias prikey="more ~/.ssh/id_ed25519 | xclip -selection clipboard | echo '=> Private key copied to pasteboard.'" - # Use Git’s colored diff when available if hash git &>/dev/null ; then diff() { @@ -51,3 +45,10 @@ gitio() { md5sum_folder(){ find -s $1 -type f -exec md5sum {} \; | md5sum } + + +k_ns_clean () { + kubectl get namespace $1 -o json \ + | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \ + | kubectl replace --raw /api/v1/namespaces/$1/finalize -f - +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5052291 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.cfg +Downloads/ +snap/ +.bash_completion +.bash_history +.npm/ +.vscode/ +Desktop/ +Documents/ +Pictures/ +dev/ +nas +.cache/ +.python_history \ No newline at end of file diff --git a/.path b/.path index 305e9f8..7d658f2 100644 --- a/.path +++ b/.path @@ -1,9 +1,38 @@ #!/bin/bash +# Configure PATH environment variable for both Ubuntu and macOS -# add to path if exist -[[ -d /snap/bin ]] && export PATH=$PATH:/snap/bin -[[ -d $HOME/.pyenv/shims ]] && export PATH=$PATH:$HOME/.pyenv/shims -[[ -d $HOME/.pyenv/bin ]] && export PATH=$PATH:$HOME/.pyenv/bin -[[ -d $HOME/.local/bin ]] && export PATH=$PATH:$HOME/.local/bin +# Determine Operating System +OS_NAME=$(uname) -export PATH=$PATH:$HOME/.arkade/bin/ +# Add Snap binaries for Ubuntu +if [[ "$OS_NAME" == "Linux" ]] && [[ -d /snap/bin ]]; then + export PATH=$PATH:/snap/bin +fi + +# Add Python environment paths if present +[[ -d $HOME/.pyenv/shims ]] && export PATH=${PATH/$HOME/.pyenv/shims:}:$HOME/.pyenv/shims +[[ -d $HOME/.pyenv/bin ]] && export PATH=${PATH/$HOME/.pyenv/bin:}:$HOME/.pyenv/bin + +# Include local binaries +[[ -d $HOME/.local/bin ]] && export PATH=${PATH/$HOME/.local/bin:}:$HOME/.local/bin + +# Add Arkade binaries +export PATH=${PATH/$HOME/.arkade/bin:}:$HOME/.arkade/bin + + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + + +export PATH="$HOME/.poetry/bin:$PATH" +export PATH="$PYENV_ROOT/bin:$PATH" +export PATH="$HOME/.poetry/bin:$PATH" + +export PATH="$PYENV_ROOT/bin:$PATH" \ No newline at end of file diff --git a/.profile b/.profile index d346c97..21fffa9 100644 --- a/.profile +++ b/.profile @@ -1,8 +1,5 @@ #!/bin/bash -export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" - # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. diff --git a/.xprofile b/.xprofile new file mode 100644 index 0000000..8d168e4 --- /dev/null +++ b/.xprofile @@ -0,0 +1 @@ +hash setxkbmap 2>/dev/null && setxkbmap -option caps:swapescape || echo "not esc remapping"