Last active
April 11, 2024 13:45
-
-
Save vshank77/abec717db7cd56b083324c9ccf5e4b83 to your computer and use it in GitHub Desktop.
ZSH Settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to your oh-my-zsh installation. | |
export ZSH="$HOME/.oh-my-zsh" | |
ZSH_THEME="shanks" | |
CASE_SENSITIVE="true" | |
DISABLE_UPDATE_PROMPT="true" | |
export UPDATE_ZSH_DAYS=13 | |
COMPLETION_WAITING_DOTS="true" | |
HIST_STAMPS="dd/mm/yyyy" | |
plugins=(git macos z) | |
source $ZSH/oh-my-zsh.sh | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
# User configuration | |
export LANG=en_GB.UTF-8 | |
export LDFLAGS="-L/opt/homebrew/opt/readline/lib" | |
export CPPFLAGS="-I/opt/homebrew/opt/readline/include" | |
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig" | |
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH" | |
# Nvm initialization | |
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 | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" | |
local nvmrc_path="$(nvm_find_nvmrc)" | |
if [ -n "$nvmrc_path" ]; then | |
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
if [ "$nvmrc_node_version" = "N/A" ]; then | |
nvm install | |
elif [ "$nvmrc_node_version" != "$node_version" ]; then | |
nvm use | |
fi | |
elif [ "$node_version" != "$(nvm version default)" ]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc | |
# >>> conda initialize >>> | |
# !! Contents within this block are managed by 'conda init' !! | |
__conda_setup="$('/Users/svasudevan/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)" | |
if [ $? -eq 0 ]; then | |
eval "$__conda_setup" | |
else | |
if [ -f "/Users/svasudevan/miniconda3/etc/profile.d/conda.sh" ]; then | |
. "/Users/svasudevan/miniconda3/etc/profile.d/conda.sh" | |
else | |
export PATH="/Users/svasudevan/miniconda3/bin:$PATH" | |
fi | |
fi | |
unset __conda_setup | |
# <<< conda initialize <<< | |
export PATH="$HOME/.bin:$HOME/.local/bin:$PATH" | |
# User Functions | |
awsprof() { | |
if [ $# -gt 0 ]; then | |
export AWS_PROFILE=$1 | |
fi | |
echo AWS_PROFILE=$AWS_PROFILE | |
} | |
deltag() { | |
if [ -z "$1" ]; then | |
echo "Usage: $0 [tag name]" | |
exit 1 | |
fi | |
git tag -d $1 | |
git push origin :refs/tags/$1 | |
} | |
getLocalIp() { | |
ping -c 1 `hostname`.local | grep "64 bytes" | awk '{print $4}' | rev | cut -c 2- | rev | |
} | |
dellog() { | |
LOG_GROUP_NAME=${1:?log group name is not set} | |
aws logs describe-log-streams --log-group-name $LOG_GROUP_NAME --query 'logStreams[*].logStreamName' --output table | awk '{print $2}' | grep -v ^$ | grep -v DescribeLogStreams | while read x; do echo $x && aws logs delete-log-stream --log-group-name $LOG_GROUP_NAME --log-stream-name $x; done | |
} | |
awscredsloc() { | |
if [ -z "$AWS_PROFILE" ]; then | |
echo "AWS_PROFILE not defined" | |
return 1 | |
fi | |
../bin/creds.sh $AWS_PROFILE && source ./local.sh | |
} | |
tfinit() { | |
CUR_FOLDER=${PWD##*/} | |
if [[ "$CUR_FOLDER" != "terraform" ]]; then | |
echo "Not executing within terraform folder" | |
return 1 | |
fi | |
if [ -z "$1" ]; then | |
echo "Usage: $0 [backend]" | |
return 2 | |
fi | |
awscredsloc | |
cred_status=$? | |
if [ ${cred_status} -ne 0 ]; then | |
return 3 | |
fi | |
terraform init -reconfigure -backend-config=backend/$1.tfvars | |
} | |
dbuild() { | |
if [[ -z $1 ]] || [[ -z $2 ]]; then | |
echo -e "* [ERROR] Usage: $0 [location] [tag]" | |
return 1 | |
fi | |
loc=$1 | |
if [[ $1 == "cb" ]]; then | |
loc='.codebuild/Dockerfile' | |
fi | |
docker build -f $loc --tag $2 . | |
} | |
envport() { | |
if [ -z "$1" ]; then | |
echo "Usage: $0 [environment]" | |
return 1 | |
fi | |
export $(grep -v '^#' ${1}.env | xargs) | |
} | |
# User Aliases | |
alias att='atom .' | |
alias awscreds='echo -e "AWS_PROFILE=$AWS_PROFILE\nAWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID\nAWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY\nAWS_SESSION_TOKEN=$AWS_SESSION_TOKEN\nAWS_PROXY=$AWS_PROXY"' | |
alias asl='aws sso login' | |
alias dev='export AWS_PROFILE=develop && echo AWS_PROFILE=$AWS_PROFILE' | |
alias prod='export AWS_PROFILE=prod && echo AWS_PROFILE=$AWS_PROFILE' | |
alias corp='export AWS_PROFILE=corp && echo AWS_PROFILE=$AWS_PROFILE' | |
alias sbox='export AWS_PROFILE=sandbox && echo AWS_PROFILE=$AWS_PROFILE' | |
alias smark='export AWS_PROFILE=spikemark && echo AWS_PROFILE=$AWS_PROFILE' | |
alias s3='aws s3 ls' | |
alias sshi='ssh -o StrictHostKeyChecking=no -i' | |
alias vizsh='vi ~/.zshrc' | |
alias viaws='vi ~/.aws/config' | |
alias epoch='gdate +%s%3N' | |
alias ga='git add -A' | |
alias gpa='git add -A && pre-commit' | |
alias gs='git status' | |
alias gc='git commit -a -m' | |
alias gac='git add -A && git commit -a -m' | |
alias gce='git commit --amend' | |
alias gds='git diff --staged' | |
alias gpb='git push --set-upstream origin $(current_branch)' | |
alias gog='git log' | |
alias gls='git ls-files . --ignored --exclude-standard --others' | |
alias gt='git for-each-ref --sort=creatordate --format "%(creatordate:short) %(refname:short)" refs/tags' | |
alias rmpy='rm -rf .cache .coverage build dist htmlcov *.egg-info test-report.html docker/Dockerfile docker/*.gz' | |
alias venv='if [[ ! -d venv ]] then echo "venv create"; python3 -m venv venv; fi; source venv/bin/activate' | |
alias pipix='pip install -r requirements-test.txt --no-cache-dir --upgrade' | |
alias pipi='cat requirements.txt | xargs -n 1 pip install --no-cache-dir' | |
alias pipio='pip install -r test-requirements.txt --no-cache-dir --upgrade' | |
alias src='source activate ${PWD##*/}' | |
alias cdc='conda create --name ${PWD##*/} python=3.9' | |
alias cda='conda activate ${PWD##*/}' | |
alias cdd='conda deactivate' | |
alias reqs='poetry export -f requirements.txt --output requirements.txt --without-hashes' | |
alias dlog='docker logs -f' | |
alias dps='docker ps -a' | |
alias dqf='docker images -qf "dangling=true"' | |
alias ddqf='docker rmi -f $(docker images -qf "dangling=true")' | |
alias ddrmi='docker rmi -f $(docker images | grep -e "latest" -e "SNAPSHOT" | awk '"'"'{print $3}'"'"')' | |
alias dimg='docker images' | |
alias drmi='docker rmi -f' | |
alias drm='docker rm -f' | |
alias ddrm='docker rm $(docker ps --filter '"'"'status=exited'"'"' | awk '"'"'{if (NR>1) {print $1}}'"'"')' | |
alias dclean='docker volume rm $(docker volume ls -qf dangling=true)' | |
alias dprune='docker builder prune -f' | |
alias ecr='aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin $(aws sts get-caller-identity | jq -r .Account).dkr.ecr.eu-west-1.amazonaws.com' | |
alias ecrpub='aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws' | |
alias preflight='curl -H "Origin: http://www.example.com" -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: X-Requested-With" -X OPTIONS -v h' | |
alias build='.codebuild/build.sh' | |
alias dcstart='docker-compose -f .codebuild/dev-compose.yml up -d' | |
alias dcstop='docker-compose -f .codebuild/dev-compose.yml down' | |
alias dclck='docker run -d --name clickhouse --ulimit nofile=262144:262144 -p 8123:8123 -p 9000:9000 yandex/clickhouse-server:21-alpine' | |
alias delastic='docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.17.4' | |
alias mivcreds='export AWS_PROFILE=mivolve && cd ~/github/mivolve/mivolve-infra && bin/creds && . ./local.sh && cd -' | |
alias tws='terraform workspace select ' | |
alias twl='terraform workspace list' | |
alias twn='terraform workspace new' | |
alias twc='terraform workspace list | grep "*" | awk '"'"'{print $2}'"'"'' | |
alias tplan='terraform plan -var-file=env/`twsc`.tfvars' | |
alias tapply='terraform apply -var-file=env/`twsc`.tfvars' | |
alias timport='terraform import -var-file=env/`twsc`.tfvars' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install hdf5 | |
brew install openblas | |
brew install telnet | |
brew install coreutils | |
brew install mkcert nss | |
brew install xz | |
brew install ghostscript tcl-tk | |
brew install git pyenv jq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROMPT=$'\n%{$fg[yellow]%}%n@%m %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(git_prompt_info)\ | |
%{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%} ' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment