diff --git a/.github/workflows/lint-format-checker.yml b/.github/workflows/lint-format-checker.yml index add737c..8f7b699 100644 --- a/.github/workflows/lint-format-checker.yml +++ b/.github/workflows/lint-format-checker.yml @@ -1,5 +1,5 @@ name: Bash Lint & Format Check - +run-name: ${{ github.actor }} is running ${{ github.workflow }} on: push: branches: [main] diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..b11d014 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,4 @@ +# .shellcheckrc +disable=SC1091 +disable=SC1090 +disable=SC2034 \ No newline at end of file diff --git a/bash/bashrc b/bash/bashrc index 32cda0a..ce9d73e 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -6,8 +6,8 @@ # If not running interactively, don't do anything case $- in - *i*) ;; - *) return;; + *i*) ;; + *) return ;; esac # don't put duplicate lines or lines starting with space in the history. @@ -34,12 +34,12 @@ shopt -s checkwinsize # set variable identifying the chroot you work in (used in the prompt below) if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) + debian_chroot=$(cat /etc/debian_chroot) fi # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in - xterm-color) color_prompt=yes;; + xterm-color) color_prompt=yes ;; esac # uncomment for a colored prompt, if the terminal has the capability; turned @@ -48,42 +48,46 @@ esac 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 [ -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 fi if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + 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\$ ' + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset color_prompt force_color_prompt # If this is an xterm set the title to user@host:dir case "$TERM" in -xterm*|rxvt*) + xterm* | rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; -*) - ;; + *) ;; esac # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' + if [ -r ~/.dircolors ]; then + eval "$(dircolors -b ~/.dircolors)" | + else + eval "$(dircolors -b)" + fi + + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' fi # colored GCC warnings and errors @@ -104,7 +108,7 @@ alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases + source ~/.bash_aliases fi # enable programmable completion features (you don't need to enable @@ -112,8 +116,8 @@ fi # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion + source /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion + source /etc/bash_completion fi fi diff --git a/bash/profile b/bash/profile index c86e7d8..5aefc2e 100644 --- a/bash/profile +++ b/bash/profile @@ -9,44 +9,44 @@ #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then - # include .bashrc if it exists - if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" - fi + # 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" +if [ -d "$HOME/bin" ]; then + PATH="$HOME/bin:$PATH" fi # set PATH so it includes user's private .local bin if it exists -if [ -d "$HOME/.local/bin" ] ; then - PATH="$HOME/.local/bin:$PATH" +if [ -d "$HOME/.local/bin" ]; then + PATH="$HOME/.local/bin:$PATH" fi # load Work profile -if [ -d "/mnt/c/Users" ] ; then - echo 'I am at work' - source "$HOME/.work-profile" +if [ -d "/mnt/c/Users" ]; then + echo 'I am at work' + source "$HOME/.work-profile" else - echo 'I am not at work!' + echo 'I am not at work!' fi # Make cat == batcat (pretty cat) # relies on batcat being installed (Ubuntu) # Save the original system `cat` under `rcat` -alias rcat="$(which cat)" +alias rcat='$(which cat)' # For Ubuntu and Debian-based `bat` packages # the `bat` program is named `batcat` on these systems -alias cat="$(which batcat)" +alias cat='$(which batcat)' export MANPAGER="sh -c 'col -bx | batcat -l man -p'" export MANROFFOPT="-c" # alias for fd alias fd=fdfind -alias mk="$(which minikube)" +alias mk='$(which minikube)' # Docker alias alias docker-stop='docker stop "$(docker ps -q)"' @@ -63,4 +63,4 @@ export GIT_EDITOR=vim export GREP_OPTIONS='--color=auto' GREP_COLOR='mt=1;32' # set up eza aliases -source ~/dotfiles/eza/eza-config \ No newline at end of file +source ~/dotfiles/eza/eza-config diff --git a/bash/work-profile b/bash/work-profile index b755785..777c66b 100644 --- a/bash/work-profile +++ b/bash/work-profile @@ -1,4 +1,3 @@ - #!/bin/bash # Java related bits @@ -7,7 +6,6 @@ export JAVA_11=/usr/lib/jvm/java-11-openjdk-amd64 export JAVA_17=/usr/lib/jvm/java-17-openjdk-amd64 export JAVA_21=/usr/lib/jvm/java-21-openjdk-amd64 - export JAVA_HOME=$JAVA_21 export STUDIO_JDK=$JAVA_21 export JDK_HOME=$JAVA_21 @@ -44,12 +42,12 @@ alias fbs='cd $FBS' # Docker clean dangling images : # from https://projectatomic.io/blog/2015/07/what-are-docker-none-none-images/ function docker-clean() { - docker rmi $(docker images -f "dangling=true" -q) + docker rmi "$(docker images -f "dangling=true" -q)" } # Stop all running containers function docker-stop-all() { - docker stop $(docker ps -q) + docker stop "$(docker ps -q)" } alias dsa='docker-stop-all' @@ -74,15 +72,15 @@ export KUBECONFIG_INFRA="$HOME/.kubecfg/infra/infra-v2.kubeconfig" export KUBECONFIG=$KUBECONFIG_DEV function switch-k8s() { - if [ $1 = 'd' ] ; then - export KUBECONFIG=$KUBECONFIG_DEV - echo "Switch to k8s dev: $KUBECONFIG" - elif [ $1 = 'p' ] ; then - export KUBECONFIG=$KUBECONFIG_PROD - echo "Switch to k8s prod: $KUBECONFIG" - else - echo "Didn't understand chose, k8s is still $KUBECONFIG" - fi + if [ "$1" = 'd' ]; then + export KUBECONFIG=$KUBECONFIG_DEV + echo "Switch to k8s dev: $KUBECONFIG" + elif [ "$1" = 'p' ]; then + export KUBECONFIG=$KUBECONFIG_PROD + echo "Switch to k8s prod: $KUBECONFIG" + else + echo "Didn't understand chose, k8s is still $KUBECONFIG" + fi } alias sk='switch-k8s' @@ -91,15 +89,16 @@ alias fbs='cd $FBS' # Just checking echo "Loaded shodders work profile" -echo "Using kubeconf: $KUBECONFIG \n\n" - +echo "Using kubeconf: $KUBECONFIG" # Set some envs to use with docker (bypassing fba-compose) export FBA_COMPOSE_DIR=${FBA_COMPOSE_DIR:-/mnt/c/programming/docker-orchestration} -export WINDOWS_HOST=$(ip route show | grep -i default | awk '{ print $3 }') +win_host="$(ip route show | grep -i default | awk '{ print $3 }')" +export WINDOWS_HOST="$win_host" export REPOS_ROOT_DIR=${REPOS_ROOT_DIR:-~/repos} export WIN_REPOS_ROOT_DIR=${WIN_REPOS_ROOT_DIR:-/mnt/c/programming} -export WIN_USER_DIR=$(wslpath "$(cmd.exe /c "echo %USERPROFILE%" 2>/dev/null | tr -d '\r')") +win_home_dir="$(wslpath "$(cmd.exe /c "echo %USERPROFILE%" 2>/dev/null | tr -d '\r')")" +export WIN_USER_DIR="$win_home_dir" # shortcut for running docker compose with correct compose/env files alias lc='docker compose -f $FBA_COMPOSE_DIR/docker-compose.yml --env-file $FBA_COMPOSE_DIR/.env' @@ -107,5 +106,5 @@ alias lc='docker compose -f $FBA_COMPOSE_DIR/docker-compose.yml --env-file $FBA_ # If using NVM for node version management # Follow this: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04 export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/bash/zshenv b/bash/zshenv index fdf345e..5a600f5 100644 --- a/bash/zshenv +++ b/bash/zshenv @@ -1,2 +1,2 @@ # for ZIM framework to stop loading auto complete twice - see https://github.com/zimfw/zimfw/wiki/Troubleshooting#completion-is-not-working -skip_global_compinit=1 \ No newline at end of file +skip_global_compinit=1 diff --git a/bash/zshrc b/bash/zshrc index c919ed2..8fd812d 100644 --- a/bash/zshrc +++ b/bash/zshrc @@ -21,7 +21,7 @@ bindkey -e #SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' # Remove path separator from WORDCHARS. -WORDCHARS=${WORDCHARS//[\/]} +WORDCHARS=${WORDCHARS//[\/]/} # -------------------- # Module configuration @@ -64,33 +64,32 @@ ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) # Initialize modules # ------------------ -ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim +ZIM_HOME="${ZDOTDIR:-${HOME}}/.zim" # Download zimfw plugin manager if missing. -if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then - if (( ${+commands[curl]} )); then - curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \ - https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh +if [[ ! -e "${ZIM_HOME}/zimfw.zsh" ]]; then + if command -v curl &>/dev/null; then + curl -fsSL --create-dirs -o "${ZIM_HOME}/zimfw.zsh" \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh else - mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \ - https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + mkdir -p "${ZIM_HOME}" && wget -nv -O "${ZIM_HOME}/zimfw.zsh" \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh fi fi # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated. -if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then - source ${ZIM_HOME}/zimfw.zsh init +if [[ ! "${ZIM_HOME}/init.zsh" -nt "${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc}" ]]; then + source "${ZIM_HOME}/zimfw.zsh init" fi # Initialize modules. -source ${ZIM_HOME}/init.zsh +source "${ZIM_HOME}/init.zsh" # }}} End configuration added by Zim Framework install - ## Load my standard profile ## Needs to be symlinked `ln -s ~/dotfiles/sh/profile ~/.profile` -source $HOME/.profile +source "$HOME/.profile" # start Starship eval "$(starship init zsh)" # current Startship prompt is: https://starship.rs/presets/gruvbox-rainbow # Start Zoxide -eval "$(zoxide init zsh)" \ No newline at end of file +eval "$(zoxide init zsh)" diff --git a/eza/eza-config b/eza/eza-config index e7f9568..6dce78e 100644 --- a/eza/eza-config +++ b/eza/eza-config @@ -41,4 +41,4 @@ alias tt='eza --tree -L 4 --icons --group-directories-first --header ' alias eld='eza --icons --group-directories-first --only-dirs --header ' alias elf='eza --icons --group-directories-first --only-files --header ' -####### EZA CONFIG END ####### \ No newline at end of file +####### EZA CONFIG END ####### diff --git a/init.sh b/init.sh index e3205a6..12ddeb0 100644 --- a/init.sh +++ b/init.sh @@ -8,123 +8,120 @@ POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case $1 in - -i|--install) + -i | --install) #echo "Install" install=true shift # past argument - # shift # past value if you want to + # shift # past value if you want to ;; - -s|--symlink) + -s | --symlink) #echo "Symlinks only" symlinks=true shift # past argument - # shift # past value if you want to + # shift # past value if you want to ;; - -*|--*) + -*) echo "Unknown option $1" exit 1 ;; -# *) -# POSITIONAL_ARGS+=("$1") # save positional arg -# shift # past argument -# ;; + # *) + # POSITIONAL_ARGS+=("$1") # save positional arg + # shift # past argument + # ;; esac done set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters - -if [ $install = false ] ; then - echo "Not installing..." +if [ $install = false ]; then + echo "Not installing..." fi -if [ $symlinks = false ] ; then - echo "Not setting up symlinks/config..." +if [ $symlinks = false ]; then + echo "Not setting up symlinks/config..." fi # Install the things if needed -if [ $install = true ] ; then - cd ~ - # Install Zsh for all (not local user) - echo "Installing Zsh..." - sudo apt install zsh - - # Set Zsh as default shell. - echo "Setting zsh as default shell..." - chsh -s /usr/bin/zsh - - # Install ZIM https://zimfw.sh/docs/ - echo "Installing ZIM..." - curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh - # use my own zimrc - rm $HOME/.zimrv - ln -s $HOME/dotfiles/bash/zimrc $HOME/.zimrc - - echo "Installing Starship..." - curl -sS https://starship.rs/install.sh | sh - - - # Install some standard bits - echo "Intalling tools..." - sudo apt install bat - sudo apt install btop - sudo apt install fd-find - sudo apt install ripgrep - - echo "Installing Lazygit..." - LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | \grep -Po '"tag_name": *"v\K[^"]*') - curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" - tar xf lazygit.tar.gz lazygit - sudo install lazygit -D -t /usr/local/bin/ - rm lazygit* - - # Install zoxide https://github.com/ajeetdsouza/zoxide - curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh - - # install eza - sudo mkdir -p /etc/apt/keyrings - wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg - echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list - sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list - sudo apt update - sudo apt install -y eza - - # Git will need to have been installed already - sudo apt install git-delta - git config --global core.pager delta - git config --global interactive.diffFilter 'delta --color-only' - git config --global delta.navigate true - git config --global delta.side-by-side true - git config --global merge.conflictStyle zdiff3 - - # install Dust - curl -sSfL https://raw.githubusercontent.com/bootandy/dust/refs/heads/master/install.sh | sh +if [ $install = true ]; then + cd ~ || exit + # Install Zsh for all (not local user) + echo "Installing Zsh..." + sudo apt install zsh + + # Set Zsh as default shell. + echo "Setting zsh as default shell..." + chsh -s /usr/bin/zsh + + # Install ZIM https://zimfw.sh/docs/ + echo "Installing ZIM..." + curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh + # use my own zimrc + rm "$HOME/.zimrv" + ln -s "$HOME/dotfiles/bash/zimrc" "$HOME/.zimrc" + + echo "Installing Starship..." + curl -sS https://starship.rs/install.sh | sh + + # Install some standard bits + echo "Intalling tools..." + sudo apt install bat + sudo apt install btop + sudo apt install fd-find + sudo apt install ripgrep + + echo "Installing Lazygit..." + LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | \grep -Po '"tag_name": *"v\K[^"]*') + curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" + tar xf lazygit.tar.gz lazygit + sudo install lazygit -D -t /usr/local/bin/ + rm lazygit* + + # Install zoxide https://github.com/ajeetdsouza/zoxide + curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh + + # install eza + sudo mkdir -p /etc/apt/keyrings + wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg + echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list + sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list + sudo apt update + sudo apt install -y eza + + # Git will need to have been installed already + sudo apt install git-delta + git config --global core.pager delta + git config --global interactive.diffFilter 'delta --color-only' + git config --global delta.navigate true + git config --global delta.side-by-side true + git config --global merge.conflictStyle zdiff3 + + # install Dust + curl -sSfL https://raw.githubusercontent.com/bootandy/dust/refs/heads/master/install.sh | sh fi # Setup the symlinks things if needed -if [ $symlinks = true ] ; then - - # Starship config - echo "Setting up Starship config..." - rm $HOME/.config/starship.toml - ln -s $HOME/dotfiles/starship/starship.toml $HOME/.config/starship.toml - - # Set up my bash things and use zsh as my bash shell (backup/work shell) - # clear out any symlinks/files to be replaced by my own - rm $HOME/.bashrc - rm $HOME/.profile - rm $HOME/.work-profile - # Create symlinks - ln -s $HOME/dotfiles/bash/bashrc $HOME/.bashrc - ln -s $HOME/dotfiles/bash/profile $HOME/.profile - ln -s $HOME/dotfiles/bash/work-profile $HOME/.work-profile - - rm $HOME/.zshrc - ln -s $HOME/dotfiles/bash/zshrc $HOME/.zshrc - - rm $HOME/.zshenv - ln -s $HOME/dotfiles/bash/zshenv $HOME/.zshenv +if [ $symlinks = true ]; then -fi + # Starship config + echo "Setting up Starship config..." + rm "$HOME/.config/starship.toml" + ln -s "$HOME/dotfiles/starship/starship.toml" "$HOME/.config/starship.toml" + + # Set up my bash things and use zsh as my bash shell (backup/work shell) + # clear out any symlinks/files to be replaced by my own + rm "$HOME/.bashrc" + rm "$HOME/.profile" + rm "$HOME/.work-profile" + # Create symlinks + ln -s "$HOME/dotfiles/bash/bashrc" "$HOME/.bashrc" + ln -s "$HOME/dotfiles/bash/profile" "$HOME/.profile" + ln -s "$HOME/dotfiles/bash/work-profile" "$HOME/.work-profile" + rm "$HOME/.zshrc" + ln -s "$HOME/dotfiles/bash/zshrc" "$HOME/.zshrc" + + rm "$HOME/.zshenv" + ln -s "$HOME/dotfiles/bash/zshenv" "$HOME/.zshenv" + +fi