Created
June 10, 2020 18:05
-
-
Save AnthonyWC/217296dbbda844dc3ef41b6e90c480c4 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/zsh | |
################### | |
# Mac version | |
################### | |
CUR_DIR=$(pwd) | |
# If you come from bash you might have to change your $PATH. | |
# Path to your oh-my-zsh installation. | |
export HISTFILE=$HOME/zsh_history | |
export EDITOR=code | |
# <ESC> delay | |
export KEYTIMEOUT=1 | |
export OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]') | |
# Ctrl-D x num to exit | |
export IGNOREEOF=3 | |
export ZSH=$HOME/.oh-my-zsh | |
echo "Existing PATH: $PATH" | |
export PATH="$HOME/dotfiles/bin:/usr/local/bin:/usr/local/sbin:$HOME/bin:/usr/local/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH" | |
# replace with coreutil & findutils | |
export PATH="/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/findutils/libexec/gnubin:$PATH" | |
# check for internet access | |
echo "Checking Internet connection.." | |
dig +time=1 google.ca > /dev/null | |
if [ $? -ne 0 ]; then | |
ping -c 2 -t 0.4 8.8.8.8 > /dev/null | |
if [ $? -ne 0 ]; then | |
echo "Internet appears down; restart network?" | |
local INTERNET_STATUS="DOWN" | |
fi | |
fi | |
# Update OMZ | |
if [ "$INTERNET_STATUS" != "DOWN" ]; then | |
printf "\n\n** Update oh-my-zsh **\n\n" | |
cd $HOME/.oh-my-zsh | |
git stash && git pull || printf "\n\n** Update Failed! **\n\n" | |
git stash pop | |
fi | |
if [[ "$OS_TYPE" == 'darwin' ]]; then | |
export SLACK_PATH='/Applications/Slack.app/Contents/Resources' | |
alias browser="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | |
elif [[ "$OS_TYPE" == 'linux' ]]; then | |
export SLACK_PATH='/usr/lib/slack/resources' | |
alias browser=chromium-browser | |
fi | |
open_general () { | |
if [[ "$OS_TYPE" == 'darwin' ]]; then | |
open "$1" | |
elif [[ "$OS_TYPE" == 'linux' ]]; then | |
xdg-open "$1" | |
fi | |
} | |
# API key | |
# source ~/.ssh/datadog | |
# maximum events stored | |
HISTSIZE=30000 | |
# maximum history events to save in history file | |
SAVEHIST=200000 | |
HISTIGNORE="gita" | |
HISTIGNORE="gitp" | |
HISTIGNORE="gitr" | |
HISTIGNORE="gits" | |
HISTIGNORE="git add*" | |
HISTIGNORE="git comment" | |
HISTIGNORE="git push" | |
HISTIGNORE="git rebase --continue" | |
HISTIGNORE="ls" | |
HISTIGNORE="pwd" | |
HISTIGNORE="wc *" | |
# THIS ENABLES POWERLEVEL9K as part of oh-my-zsh | |
ZSH_THEME="powerlevel9k/powerlevel9k" | |
#ZSH_THEME="philips" | |
POWERLEVEL9K_MODE='nerdfont-complete' | |
POWERLEVEL9K_PROMPT_ON_NEWLINE=true | |
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true | |
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true | |
POWERLEVEL9K_CUSTOM_AWS_REGION="echo \$(aws configure get region)" | |
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir aws custom_aws_region virtualenv anaconda date time newline vcs node_version load background_jobs status vi_mode) | |
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(gcp_project kubecontext) | |
#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status vi_mode gcp_user kubecontext node_version load background_jobs) | |
POWERLEVEL9K_SHORTEN_DIR_LENGTH=7 | |
POWERLEVEL9K_SHORTEN_DELIMITER="" | |
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" | |
setopt ALIASES # expand alias (in scripts) | |
setopt CORRECT # spellcheck | |
setopt INC_APPEND_HISTORY # Append immediately | |
setopt SHARE_HISTORY # Share between session | |
setopt HIST_IGNORE_ALL_DUPS # ignore saving duplicate | |
setopt inc_append_history # save command before execution | |
setopt share_history | |
zmodload -i zsh/complist | |
#plugins=(aws colored-man-pages colorize docker go-zsh-completions jira sublime vi-mode zsh-autosuggestions zsh-syntax-highlighting web-search) | |
# Oh My Zsh plugins https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins | |
plugins=(aws colored-man-pages colorize docker gcloud go-zsh-completions jira sublime vi-mode web-search) | |
if [ -z "$_zsh_custom_scripts_loaded" ]; then | |
_zsh_custom_scripts_loaded=1 | |
#plugins+=(zsh-syntax-highlighting) | |
plugins+=(zsh-syntax-highlighting zsh-autosuggestions) | |
fi | |
##################################################################### | |
source $HOME/git/script/bash/antigen.zsh | |
# Load the oh-my-zsh's library. | |
antigen use oh-my-zsh | |
# Bundles from the default repo (robbyrussell's oh-my-zsh). | |
antigen bundle git | |
antigen bundle pip | |
antigen bundle lein | |
antigen bundle command-not-found | |
#antigen bundle zdharma/fast-syntax-highlighting | |
#antigen bundle zsh-users/zsh-autosuggestions | |
antigen apply | |
# Use plugins instead | |
#source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh | |
################################################################### | |
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" | |
################################################## | |
#source $HOME/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
#export JIRA_URL="https://intersection-kb.atlassian.net" | |
source $ZSH/oh-my-zsh.sh | |
#################################################################### | |
local TERMINAL=$(ps -p$PPID | sed '1d' | awk '{print $NF}' | awk -F '/' '{print $NF}') | |
# Check if running inside INTELLIJ terminal | |
if [[ $TERMINAL != "webstorm" ]]; then | |
source_all | |
# func_selector "Check install apps? ..\n" "source" "/home/antho/dotfiles/check_install_app" | |
# func_selector "Check git repo? ..\n" "/home/antho/git/script/sysadmin/git_check_startup.sh" | |
else | |
echo "Terminal is $TERMINAL type" | |
source_intellij | |
# git_token_check | |
fi | |
#################################################################### | |
# Edit LESS | |
export LESS='--quit-if-one-screen --ignore-case --status-column --LONG-PROMPT --RAW-CONTROL-CHARS --HILITE-UNREAD --tabs=4 --no-init --window=-4' | |
# short version | |
# export LESS='-F -i -J -M -R -W -x4 -X -z-4' | |
# Set colors https://wiki.archlinux.org/index.php/Color_output_in_console#less | |
export LESS_TERMCAP_mb=$'\E[1;31m' # begin bold | |
export LESS_TERMCAP_md=$'\E[1;36m' # begin blink | |
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink | |
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video | |
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video | |
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline | |
export LESS_TERMCAP_ue=$'\E[0m' # reset underline | |
# ************************** | |
$HOME/git/script/bash/xcol.sh | |
cp $HOME/.zsh_history $HOME/git/sysopt/zsh_history_mac | |
cd $CUR_DIR | |
# Required for direnv | |
eval "$(direnv hook zsh)" | |
# Created by `userpath` on 2020-03-13 13:47:02 | |
export PATH="$PATH:/Users/awcheng/.local/bin" | |
mac_dns_flush () { | |
cat <<EOF | |
dscacheutil -flushcache | |
sudo killall -HUP mDNSResponder | |
# sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache | |
EOF | |
} | |
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment