From 1de687b22b0e9dbd524cb94a5d2d8aa471a071f0 Mon Sep 17 00:00:00 2001 From: Errol Sancaktar Date: Wed, 16 Apr 2025 16:58:29 +0000 Subject: [PATCH] Cleanup and Add google --- bash/.bash_completion.d/fuzzy_bash_completion | 1 - .../gcloud/completion.bash.inc | 0 .../gcloud/path.bash.inc | 0 bash/{.bash_profile => bash_profile} | 0 bash/{.bashrc => bashrc} | 45 ++++----- config.yaml | 40 ++++++-- .../git/gitconfig.personal | 0 git/{.config => config}/git/gitconfig.work | 0 git/{.config => config}/git/gitignore | 0 git/{.config => config}/git/gitmodules | 0 git/{.gitconfig => gitconfig} | 0 google/gcommands | 18 ++++ google/google_rc | 82 ++++++++++++++++ home/.aliasrc | 98 ------------------- path | 1 + shell/{.aliasrc => aliasrc} | 0 tmux/.tmux/plugins/tmux-better-mouse-mode | 1 - tmux/.tmux/plugins/tmux-browser | 1 - tmux/.tmux/plugins/tmux-fzf | 1 - tmux/.tmux/plugins/tmux-notify | 1 - tmux/.tmux/plugins/tmux-open | 1 - tmux/.tmux/plugins/tmux-spotify | 1 - tmux/.tmux/plugins/tmux-which-key | 1 - tmux/.tmux/plugins/tmux-yank | 1 - tmux/.tmux/plugins/tpm | 1 - tmux/{.tmux.conf => tmux.conf} | 0 tmux/{.tmux => tmux}/0 | 0 tmux/{.tmux => tmux}/spotify-tmux.sh | 0 zsh/{.zprofile => zprofile} | 0 zsh/{.zsh_helpers => zsh_helpers}/nixos.sh | 0 zsh/{.zshrc => zshrc} | 0 31 files changed, 154 insertions(+), 140 deletions(-) delete mode 160000 bash/.bash_completion.d/fuzzy_bash_completion rename bash/{.bash_completion.d => bash_completion.d}/gcloud/completion.bash.inc (100%) rename bash/{.bash_completion.d => bash_completion.d}/gcloud/path.bash.inc (100%) rename bash/{.bash_profile => bash_profile} (100%) rename bash/{.bashrc => bashrc} (77%) rename git/{.config => config}/git/gitconfig.personal (100%) rename git/{.config => config}/git/gitconfig.work (100%) rename git/{.config => config}/git/gitignore (100%) rename git/{.config => config}/git/gitmodules (100%) rename git/{.gitconfig => gitconfig} (100%) create mode 100644 google/gcommands create mode 100644 google/google_rc delete mode 100644 home/.aliasrc create mode 120000 path rename shell/{.aliasrc => aliasrc} (100%) delete mode 160000 tmux/.tmux/plugins/tmux-better-mouse-mode delete mode 160000 tmux/.tmux/plugins/tmux-browser delete mode 160000 tmux/.tmux/plugins/tmux-fzf delete mode 160000 tmux/.tmux/plugins/tmux-notify delete mode 160000 tmux/.tmux/plugins/tmux-open delete mode 160000 tmux/.tmux/plugins/tmux-spotify delete mode 160000 tmux/.tmux/plugins/tmux-which-key delete mode 160000 tmux/.tmux/plugins/tmux-yank delete mode 160000 tmux/.tmux/plugins/tpm rename tmux/{.tmux.conf => tmux.conf} (100%) rename tmux/{.tmux => tmux}/0 (100%) rename tmux/{.tmux => tmux}/spotify-tmux.sh (100%) rename zsh/{.zprofile => zprofile} (100%) rename zsh/{.zsh_helpers => zsh_helpers}/nixos.sh (100%) rename zsh/{.zshrc => zshrc} (100%) diff --git a/bash/.bash_completion.d/fuzzy_bash_completion b/bash/.bash_completion.d/fuzzy_bash_completion deleted file mode 160000 index b8a285f0..00000000 --- a/bash/.bash_completion.d/fuzzy_bash_completion +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b8a285f0f1a86cfef4adb04dc9ea7bb689c4d6cc diff --git a/bash/.bash_completion.d/gcloud/completion.bash.inc b/bash/bash_completion.d/gcloud/completion.bash.inc similarity index 100% rename from bash/.bash_completion.d/gcloud/completion.bash.inc rename to bash/bash_completion.d/gcloud/completion.bash.inc diff --git a/bash/.bash_completion.d/gcloud/path.bash.inc b/bash/bash_completion.d/gcloud/path.bash.inc similarity index 100% rename from bash/.bash_completion.d/gcloud/path.bash.inc rename to bash/bash_completion.d/gcloud/path.bash.inc diff --git a/bash/.bash_profile b/bash/bash_profile similarity index 100% rename from bash/.bash_profile rename to bash/bash_profile diff --git a/bash/.bashrc b/bash/bashrc similarity index 77% rename from bash/.bashrc rename to bash/bashrc index 68a0fa12..b4640ee7 100644 --- a/bash/.bashrc +++ b/bash/bashrc @@ -3,6 +3,21 @@ ## errol@sancaktar.net ## +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +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 + # HomeBrew ## Check for HomeBrew @@ -60,25 +75,6 @@ brew_packages=( "spotify_player" ) -function alacritty_config_setup { - if [[ -f $HOME/.config/alacritty/alacritty-base.toml ]]; then - # echo $(pwd) - toml_files=("$HOME/.config/alacritty/alacritty-base.toml" "$HOME/.config/alacritty/alacritty-$1.toml") - combined_file="$HOME/.config/alacritty/alacritty.toml" - echo -n >"$combined_file" - for file in "${toml_files[@]}"; do - # Check if the file exists - if [ -f "$file" ]; then - # Append content of the current TOML file to the combined file - cat "$file" >>"$combined_file" - # Add a newline to separate TOML sections (optional) - echo >>"$combined_file" - else - echo "File '$file' not found. Skipping." - fi - done - fi -} function shell_start_disp { echo -n "$(hostname) - " if [[ -f /sbin/ifconfig ]]; then @@ -96,9 +92,6 @@ if [[ $(uname) == "Linux" ]]; then # The next line enables shell command completion for gcloud. # if [ -f '/home/errol/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/errol/google-cloud-sdk/completion.zsh.inc'; fi export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" - - # Alacritty Crap - alacritty_config_setup linux fi ## IF MacOS @@ -107,9 +100,11 @@ if [[ $(uname) == "Darwin" ]]; then if [ -d /opt/homebrew/bin ]; do export PATH="/opt/homebrew/bin:$PATH" fi +fi - # Alacritty Crap - alacritty_config_setup osx +# Google Stuff +if [[ -r ~/.googlerc ]]; then + . ~/.googlerc fi shell_start_disp @@ -146,7 +141,7 @@ function h() { if which starship &>/dev/null; then eval "$(starship init zsh)" else - curl -sS https://starship.rs/install.sh | sh + echo "Starship not Installed, Install with: curl -sS https://starship.rs/install.sh | sh" fi export PATH="$PATH:/Users/errol/.local/bin" diff --git a/config.yaml b/config.yaml index 039d64ac..a6beb3d1 100644 --- a/config.yaml +++ b/config.yaml @@ -5,25 +5,51 @@ - clean: ['~'] - link: - ~/.config/alacritty/alacritty.toml: + ~/.config/alacritty/alacritty.toml: path: alacritty/alacritty.toml - ~/.config/alacritty/alacritty.toml: + ~/.config/alacritty/alacritty.toml: if: '[ `hostname` = esancakt-mac.roam.internal ]' path: alacritty/alacritty.gmac.toml - ~/.config/alacritty/themes: + ~/.config/alacritty/themes: path: alacritty/themes - ~/.zshrc: zsh/.zshrc - ~/.zprofile: zsh/.zprofile +## Shell Stuff + ~/.tmux.conf: + if: '`command -v tmux >/dev/null 2>&1`' + path: tmux/tmux.conf - ~/.tmux.conf: tmux/.tmux.conf + ~/.aliasrc: + path: shell/aliasrc - ~/.aliasrc: shell/.aliasrc + ## Bash + ~/.bashrc: + if: '[ $SHELL == "/bin/bash" ]' + path: bash/bashrc + + ~/.bash_profile: + if: '[ $SHELL == "/bin/bash" ]' + path: bash/bash_profile + + ~/.bash_completion.d: + if: '[ $SHELL == "/bin/bash" ]' + path: bash/bash_completion.d + ## Zsh + ~/.zshrc: + if: '[ $SHELL == "/bin/zsh" ]' + path: zsh/zshrc + ~/.zprofile: + if: '[ $SHELL == "/bin/zsh" ]' + path: zsh/zprofile + + ## Git + ~/.git: + if: '`command -v git >/dev/null 2>&1`' + path: git # - create: # - ~/downloads diff --git a/git/.config/git/gitconfig.personal b/git/config/git/gitconfig.personal similarity index 100% rename from git/.config/git/gitconfig.personal rename to git/config/git/gitconfig.personal diff --git a/git/.config/git/gitconfig.work b/git/config/git/gitconfig.work similarity index 100% rename from git/.config/git/gitconfig.work rename to git/config/git/gitconfig.work diff --git a/git/.config/git/gitignore b/git/config/git/gitignore similarity index 100% rename from git/.config/git/gitignore rename to git/config/git/gitignore diff --git a/git/.config/git/gitmodules b/git/config/git/gitmodules similarity index 100% rename from git/.config/git/gitmodules rename to git/config/git/gitmodules diff --git a/git/.gitconfig b/git/gitconfig similarity index 100% rename from git/.gitconfig rename to git/gitconfig diff --git a/google/gcommands b/google/gcommands new file mode 100644 index 00000000..b5af73a1 --- /dev/null +++ b/google/gcommands @@ -0,0 +1,18 @@ +check_envs(var) { + local command="$2" + + if [[ -z "${!env_var}" ]]; then + read -rp "Enter value for $env_var: " "${env_var}" + export "$env_var=${!env_var}" #Export the variable to be accessible by child processes + fi + + if [[ -n "${!env_var}" ]]; then + eval "$command" + else + echo "Environment variable $env_var is not set. Command not executed." + fi +} + +# Example usage: +# run_with_env MY_API_KEY "curl -H \"Authorization: Bearer $MY_API_KEY\" https://api.example.com" +# run_with_env DATABASE_URL "psql $DATABASE_URL -c 'SELECT * FROM users;'" diff --git a/google/google_rc b/google/google_rc new file mode 100644 index 00000000..9f28276e --- /dev/null +++ b/google/google_rc @@ -0,0 +1,82 @@ +_display_bug_machine_info() { + local output="" + local separator=" | " # Define the separator + + # Check if BUG is set and non-empty + if [ -n "$BUG" ]; then + # Format BUG value (Cyan) - REMOVED "BUG: " label + printf -v output "\e[0;36mB:%s\e[0m" "$BUG" + fi + + # Check if MACHINE is set and non-empty + if [ -n "$MACHINE" ]; then + local machine_part="" + # Format MACHINE value (Magenta) - REMOVED "MACHINE: " label + printf -v machine_part "\e[0;35mM:%s\e[0m" "$MACHINE" + + # If BUG was also set (output is not empty), add separator first + if [ -n "$output" ]; then + output+="$separator$machine_part" + else + # Otherwise, MACHINE is the first/only part + output="$machine_part" + fi + fi + + # If the combined output string is not empty, print it + if [ -n "$output" ]; then + echo "$output" # echo adds the needed newline after the combined string + fi + return 0 +} + + +if [[ ! "$PROMPT_COMMAND" =~ _display_bug_machine_info_bash ]]; then + # Prepend the function call + PROMPT_COMMAND="_display_bug_machine_info${PROMPT_COMMAND:+;}${PROMPT_COMMAND}" +fi + + +## Aliases ## + +alias batool'=/google/data/ro/projects/bandaid/batool' +alias pancetta='/google/bin/releases/bandaid-team/pancetta_par/pancetta.par' +alias safergcp='/google/bin/releases/safer-gcp/tools/safergcp' +alias clients='g4 clients -u $USER|awk -F: '\''{print $2}'\''' +alias g3='cd experimental/users/${USER}/' +alias health_check='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc health_check --justification=$BUG gmec-$MACHINE' + +alias admin_batool='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool' + +alias connectivity='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc check connectivity gmec-$MACHINE' + +alias machine_enable='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- /google/data/ro/projects/bandaid/batool gdc machine enable --env=prod --justification=$BUG --disable_claim=$BUG gmec-$MACHINE' + +alias con='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- ssh gmec-$MACHINE' + +alias admin='admin_session --reason=$BUG --tonic_policy=common-loas-transact-dat --transact --delegates=mdbuser/bandaid-batool-server,mdbuser/cloud-control2-gdchardware-frontend -- ' + +alias gdcgrants='grants add --reason=$BUG cloud-gmec-batool-prod-rw-acl:20h cloud-kubernetes-edge-producer-api-admin-prod:20h gdchardwaremanagement-internal-admin-prod:20h cloud-gmec-bandaid-prod-riker-acl:20h' + +alias gcsec='gcert -m=cloud-gmec-offnet --s --reason=$BUG --use_secondary_key --ua_ca_instance=prod --noloas2 --nocorpssh' + + +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +#batool() { /google/data/ro/projects/bandaid/batool "$@"; } +#pancetta() { bash /google/bin/releases/bandaid-team/pancetta_par/pancetta.par "$0"; } +riker() { /google/data/ro/projects/bandaid/riker "$0"; } +# Function to display BUG and MACHINE info above the Bash prompt + + +gdc() { + for arg in "$@"; do + if [[ "$arg" =~ ^(b\/[0-9]+|shax\/[0-9]+|irm\/i_[0-9a-Z]+) ]]; then + BUG="$arg" + elif [[ "$arg" =~ ^gmec- ]]; then + MACHINE="$arg" + fi +done +} diff --git a/home/.aliasrc b/home/.aliasrc deleted file mode 100644 index 7726d75d..00000000 --- a/home/.aliasrc +++ /dev/null @@ -1,98 +0,0 @@ -declare -A alias_list=( - -# ZSH -[ll]='ls -alF' -[ls]='ls -lah --color' -[grep]='grep --color=auto' -[vi]='nvim' -[lpg]='cd ~/git/lucidpoint' -[ppg]='cd ~/git/personal' -[downloads]='cd ~/Downloads' -[desktop]='cd ~/Desktop' -[docs]='cd ~/Documents' -[pip]='pip3' -[python]='python3' - -# PYTHON -[act]='source venv/bin/activate' -[p]='ipython' -[dea]='deactivate' - -# GIT -[gaa]='git add --all' -[gcm]='git commit --all --message' -[glo]='git log --oneline --decorate --graph --all' -[gl]='git pull' -[gp]='git push' -[gpd]='git push --dry-run' -[gpv]='git push --verbose' -[grb]='git rebase' -[grv]='git remote --verbose' -[gs]='git show --pretty=short' -[gst]='git status --short' -[gss]='git status --long --show-stash' -[gd]='git diff' -[gdca]='git diff --cached' -[gdcw]='git diff --cached --word-diff' -[gds]='git diff --staged' -[gdw]='git diff --word-diff' - -# SSH -[ed]='ssh errol@edesktop.sancaktar.net' -[fs]='ssh errol@fs1.sancaktar.net' - -# KUBERNETES -[k]='kubectl' -[kgc]='kubectl config get-contexts' -[kuc]='kubectl config use-context' - - -# TERRAFORM -[t]='tofu' - -# GCLOUD -[gcl]='gcloud config configurations list' -[gca]='gcloud config configurations activate' - - -# SPOTIFY -[spo]='spotify_player' - -) - - -# Alias Functions - -gc() { - git add --all - if [ -n "$1" ] - then - git commit --all --message "$1" - else - git commit -m update - fi - git push --verbose -} - - - - -# Alias Loop -if [[ -d '/proc' ]]; then - current_shell=`cat /proc/$$/comm` -else - current_shell=`echo $SHELL | cut -d/ -f3` -fi - -#Bash -if [[ "$current_shell" == 'bash' ]]; then - for alias_def in "${!alias_list[@]}"; do - alias $alias_def="${alias_list[$alias_def]}" - done -fi -if [[ "$current_shell" == 'zsh' ]]; then -#Zsh - for alias_def in "${(k@)alias_list[@]}"; do - alias $alias_def="${alias_list[$alias_def]}" - done -fi diff --git a/path b/path new file mode 120000 index 00000000..0c28bf44 --- /dev/null +++ b/path @@ -0,0 +1 @@ +/usr/local/google/home/esancakt/dotfiles/bash/bash_completion.d \ No newline at end of file diff --git a/shell/.aliasrc b/shell/aliasrc similarity index 100% rename from shell/.aliasrc rename to shell/aliasrc diff --git a/tmux/.tmux/plugins/tmux-better-mouse-mode b/tmux/.tmux/plugins/tmux-better-mouse-mode deleted file mode 160000 index aa59077c..00000000 --- a/tmux/.tmux/plugins/tmux-better-mouse-mode +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa59077c635ab21b251bd8cb4dc24c415e64a58e diff --git a/tmux/.tmux/plugins/tmux-browser b/tmux/.tmux/plugins/tmux-browser deleted file mode 160000 index 243704b0..00000000 --- a/tmux/.tmux/plugins/tmux-browser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 243704b048668fa0dcf34ebd4857fe8e9500e88a diff --git a/tmux/.tmux/plugins/tmux-fzf b/tmux/.tmux/plugins/tmux-fzf deleted file mode 160000 index 1547f180..00000000 --- a/tmux/.tmux/plugins/tmux-fzf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1547f18083ead1b235680aa5f98427ccaf5beb21 diff --git a/tmux/.tmux/plugins/tmux-notify b/tmux/.tmux/plugins/tmux-notify deleted file mode 160000 index 4e37358b..00000000 --- a/tmux/.tmux/plugins/tmux-notify +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4e37358be51b22078e9361fd6ad0ae199cf03587 diff --git a/tmux/.tmux/plugins/tmux-open b/tmux/.tmux/plugins/tmux-open deleted file mode 160000 index 763d0a85..00000000 --- a/tmux/.tmux/plugins/tmux-open +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 763d0a852e6703ce0f5090a508330012a7e6788e diff --git a/tmux/.tmux/plugins/tmux-spotify b/tmux/.tmux/plugins/tmux-spotify deleted file mode 160000 index 071a9774..00000000 --- a/tmux/.tmux/plugins/tmux-spotify +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 071a9774861a61fc86b687b06cb208e0f2d3ac2b diff --git a/tmux/.tmux/plugins/tmux-which-key b/tmux/.tmux/plugins/tmux-which-key deleted file mode 160000 index 1f419775..00000000 --- a/tmux/.tmux/plugins/tmux-which-key +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1f419775caf136a60aac8e3a269b51ad10b51eb6 diff --git a/tmux/.tmux/plugins/tmux-yank b/tmux/.tmux/plugins/tmux-yank deleted file mode 160000 index acfd36e4..00000000 --- a/tmux/.tmux/plugins/tmux-yank +++ /dev/null @@ -1 +0,0 @@ -Subproject commit acfd36e4fcba99f8310a7dfb432111c242fe7392 diff --git a/tmux/.tmux/plugins/tpm b/tmux/.tmux/plugins/tpm deleted file mode 160000 index 99469c4a..00000000 --- a/tmux/.tmux/plugins/tpm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 99469c4a9b1ccf77fade25842dc7bafbc8ce9946 diff --git a/tmux/.tmux.conf b/tmux/tmux.conf similarity index 100% rename from tmux/.tmux.conf rename to tmux/tmux.conf diff --git a/tmux/.tmux/0 b/tmux/tmux/0 similarity index 100% rename from tmux/.tmux/0 rename to tmux/tmux/0 diff --git a/tmux/.tmux/spotify-tmux.sh b/tmux/tmux/spotify-tmux.sh similarity index 100% rename from tmux/.tmux/spotify-tmux.sh rename to tmux/tmux/spotify-tmux.sh diff --git a/zsh/.zprofile b/zsh/zprofile similarity index 100% rename from zsh/.zprofile rename to zsh/zprofile diff --git a/zsh/.zsh_helpers/nixos.sh b/zsh/zsh_helpers/nixos.sh similarity index 100% rename from zsh/.zsh_helpers/nixos.sh rename to zsh/zsh_helpers/nixos.sh diff --git a/zsh/.zshrc b/zsh/zshrc similarity index 100% rename from zsh/.zshrc rename to zsh/zshrc