Skip to content

Commit

Permalink
reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
jpabbuehl committed Nov 19, 2023
1 parent f07291e commit 2f2ce69
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 170 deletions.
32 changes: 16 additions & 16 deletions .bash_aliases
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.'"
44 changes: 41 additions & 3 deletions .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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 -)"
Expand All @@ -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
89 changes: 40 additions & 49 deletions .bash_prompt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash


# Function to display Git repository status in prompt
prompt_git() {
local s='';
local branchName='';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
100 changes: 30 additions & 70 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -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' ;;
Expand All @@ -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"
Loading

0 comments on commit 2f2ce69

Please sign in to comment.