summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/zsh/.antigenrc14
-rwxr-xr-xpublic/zsh/.usr/local/bin/awk2
-rwxr-xr-xpublic/zsh/.usr/local/bin/aws-console36
-rwxr-xr-xpublic/zsh/.usr/local/bin/find2
-rwxr-xr-xpublic/zsh/.usr/local/bin/sed2
-rw-r--r--public/zsh/.zprofile20
-rw-r--r--public/zsh/.zshenv74
-rw-r--r--public/zsh/.zshrc137
8 files changed, 287 insertions, 0 deletions
diff --git a/public/zsh/.antigenrc b/public/zsh/.antigenrc
new file mode 100644
index 0000000..0206a26
--- /dev/null
+++ b/public/zsh/.antigenrc
@@ -0,0 +1,14 @@
+antigen use oh-my-zsh
+
+antigen bundle macos
+antigen bundle git
+antigen bundle fzf
+antigen bundle vi-mode
+antigen bundle zsh-users/zsh-autosuggestions
+antigen bundle zsh-users/zsh-completions
+antigen bundle zsh-users/zsh-syntax-highlighting
+antigen bundle superbrothers/zsh-kubectl-prompt
+
+antigen theme robbyrussell
+
+antigen apply
diff --git a/public/zsh/.usr/local/bin/awk b/public/zsh/.usr/local/bin/awk
new file mode 100755
index 0000000..da814c3
--- /dev/null
+++ b/public/zsh/.usr/local/bin/awk
@@ -0,0 +1,2 @@
+#!/bin/bash
+gawk "$@"
diff --git a/public/zsh/.usr/local/bin/aws-console b/public/zsh/.usr/local/bin/aws-console
new file mode 100755
index 0000000..77c2320
--- /dev/null
+++ b/public/zsh/.usr/local/bin/aws-console
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -eufo pipefail
+export SHELLOPTS
+IFS=$'\t\n'
+
+if [[ -z "${AWS_ACCESS_KEY_ID:-}" ]] ||
+ [[ -z "${AWS_SECRET_ACCESS_KEY:-}" ]] ||
+ [[ -z "${AWS_SESSION_TOKEN:-}" ]]; then
+ echo "AWS_ required variables not set"
+ exit 1
+fi
+
+command -v curl >/dev/null 2>&1 || { echo "curl is not installed!"; exit 1; }
+command -v jq >/dev/null 2>&1 || { echo "jq is not installed!"; exit 1; }
+
+credentials='{"sessionId":"'"${AWS_ACCESS_KEY_ID}"'","sessionKey":"'"${AWS_SECRET_ACCESS_KEY}"'","sessionToken":"'"${AWS_SESSION_TOKEN}"'"}'
+
+uc="${credentials//'%'/%25}"; uc="${uc//'"'/%22}"; uc="${uc//','/%2C}"
+uc="${uc//'/'/%2F}"; uc="${uc//':'/%3A}"; uc="${uc//'='/%3D}"
+uc="${uc//'{'/%7B}"; uc="${uc//'}'/%7D}"; uc="${uc//'+'/%2B}"
+
+federation_url="https://signin.aws.amazon.com/federation"
+federation_url="${federation_url}?Action=getSigninToken"
+federation_url="${federation_url}&SessionDuration=3600"
+federation_url="${federation_url}&Session=$(printf %s "$uc")"
+
+token=$(curl -s "${federation_url}" | jq -r '.SigninToken' 2>/dev/null) ||
+ { echo "invalid or expired credentials"; exit 1; }
+
+console_url="https://signin.aws.amazon.com/federation"
+console_url="${console_url}?Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F"
+console_url="${console_url}&SigninToken=${token}"
+console_url="${console_url}&Issuer=https%3A%2F%2Fexample.com"
+console_url="${console_url}&Action=login"
+
+open "${console_url}"
diff --git a/public/zsh/.usr/local/bin/find b/public/zsh/.usr/local/bin/find
new file mode 100755
index 0000000..0df7b89
--- /dev/null
+++ b/public/zsh/.usr/local/bin/find
@@ -0,0 +1,2 @@
+#!/bin/bash
+gfind "$@"
diff --git a/public/zsh/.usr/local/bin/sed b/public/zsh/.usr/local/bin/sed
new file mode 100755
index 0000000..1077e99
--- /dev/null
+++ b/public/zsh/.usr/local/bin/sed
@@ -0,0 +1,2 @@
+#!/bin/bash
+gsed "$@"
diff --git a/public/zsh/.zprofile b/public/zsh/.zprofile
new file mode 100644
index 0000000..2882524
--- /dev/null
+++ b/public/zsh/.zprofile
@@ -0,0 +1,20 @@
+# Mac specific hack to prepend to $PATH
+# This is shit because it runs zshenv twice :/
+# https://stackoverflow.com/questions/59131915/zsh-path-variable-entries-are-backwards-on-os-x-catalina
+if [ "$(uname -s)" = "Darwin" ]; then
+ [[ -f $HOME/.zshenv ]] && source $HOME/.zshenv
+ typeset -U PATH
+fi
+
+function vim_wrap() {
+ [ -z "$VIMRUNTIME" ] && nvim "$@" || echo "no inception shit"
+}
+
+function awsume() {
+ unset AWS_PROFILE
+ unset AWS_ACCESS_KEY_ID
+ unset AWS_SECRET_ACCESS_KEY
+ unset AWS_SESSION_TOKEN
+ source <(aws session-env --profile "$@")
+ export AWS_PROFILE=$1
+}
diff --git a/public/zsh/.zshenv b/public/zsh/.zshenv
new file mode 100644
index 0000000..aa7b60e
--- /dev/null
+++ b/public/zsh/.zshenv
@@ -0,0 +1,74 @@
+alias kontext="source kontext"
+alias vim=vim_wrap
+alias docker=podman
+
+# fucking hate brew, mac and all these fucking
+# hacks and stupid workarounds
+BREW_BIN="/opt/homebrew/bin/brew"
+eval "$(${BREW_BIN} shellenv)"
+
+export PATH="${HOMEBREW_PREFIX}/opt/gnu-getopt/bin:${PATH}"
+export MANPATH="${HOMEBREW_PREFIX}/opt/gnu-getopt/share/man:${MANPATH}"
+
+export PATH="${HOMEBREW_PREFIX}/opt/libpq/bin:${PATH}"
+
+# other standard utilities like awk or sed
+# have their own wrapper in ~/.usr/local/bin
+
+# Brew
+export HOMEBREW_BUNDLE_FILE="${HOME}/.brewfile"
+export HOMEBREW_NO_AUTO_UPDATE=1
+export HOMEBREW_NO_ANALYTICS=1
+export HOMEBREW_TEMP="/tmp"
+export HOMEBREW_NO_INSTALL_FROM_API=1
+
+# Krew
+export PATH="${HOME}/.krew/bin:${PATH}"
+
+# Rust
+export PATH="${HOME}/.cargo/bin:${PATH}"
+
+# Ruby
+export GEM_HOME="$HOME/.gems"
+export PATH="${GEM_HOME}/bin:${PATH}"
+
+# NPM
+export NPM_PACKAGES="${HOME}/.npm-packages"
+export PATH="${NPM_PACKAGES}/bin:${PATH}"
+export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
+
+# Go
+export GO111MODULE=on
+export GOBIN="${HOME}/.go/bin"
+export PATH="${GOBIN}:${PATH}"
+
+# perlbrew
+export PERLBREW_ROOT="${HOME}/perl5/perlbrew"
+if [ -f ${PERLBREW_ROOT}/etc/bashrc ]; then
+ # cpan App::perlbrew && perlbrew init && \
+ # perlbrew install-patchperl && perlbrew install perl-5.34.0 && \
+ # perlbrew switch perl-5.34.0 && perlbrew install-cpanm
+ source ${PERLBREW_ROOT}/etc/bashrc
+fi
+
+# My local shit
+export PATH="${HOME}/.local/bin:${PATH}"
+export PATH="${HOME}/.usr/local/bin:${PATH}"
+
+# Makes perl's Config aware of homebrew headers and libraries
+# for stuff like ImageMagick. You can test that Config has this
+# entries using something like this:
+#
+# use Config;
+# print("usrinc: " . $Config{usrinc} . "\n");
+# print("ldflags: " . $Config{ldflags} . "\n");
+# print("lddflags: " . $Config{lddlflags} . "\n");
+export PERLBREW_CONFIGURE_FLAGS="-Dusrinc=/opt/homebrew/include -Dldflags=-L/opt/homebrew/lib -de"
+
+# Otherwise I get weird GPG errors when signing commits
+#export GPG_TTY=$(tty)
+
+# https://docs.brew.sh/Shell-Completion
+FPATH="${HOMEBREW_PREFIX}/share/zsh/site-functions:${FPATH}"
+
+source "${HOME}/.zshenv_cabify"
diff --git a/public/zsh/.zshrc b/public/zsh/.zshrc
new file mode 100644
index 0000000..2d023b4
--- /dev/null
+++ b/public/zsh/.zshrc
@@ -0,0 +1,137 @@
+# ft=shell
+#zmodload zsh/zprof
+
+source $HOMEBREW_PREFIX/share/antigen/antigen.zsh
+antigen init $HOME/.antigenrc
+
+autoload -U compinit promptinit
+compinit
+
+if [ "$(uname -s)" = "Linux" ] && [ -f "/etc/gentoo-release" ]; then
+ # Gentoo specific auto-completion
+ promptinit; prompt gentoo
+fi
+
+HISTFILE="${HOME}/.zsh_history"
+HISTSIZE=1000
+SAVEHIST=1000
+setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
+setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
+setopt SHARE_HISTORY # Share history between all sessions.
+setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
+setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
+setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
+setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
+setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
+setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
+setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
+setopt HIST_VERIFY # Don't execute immediately upon history expansion.
+
+CASE_SENSITIVE="true"
+
+DISABLE_UPDATE_PROMPT="true"
+export UPDATE_ZSH_DAYS=7
+
+# Uncomment the following line if pasting URLs and other text is messed up.
+# DISABLE_MAGIC_FUNCTIONS="true"
+
+# Uncomment the following line to disable colors in ls.
+# DISABLE_LS_COLORS="true"
+
+# Uncomment the following line to disable auto-setting terminal title.
+# DISABLE_AUTO_TITLE="true"
+
+# Uncomment the following line to enable command auto-correction.
+ENABLE_CORRECTION="true"
+
+# Uncomment the following line to display red dots whilst waiting for completion.
+COMPLETION_WAITING_DOTS="true"
+
+# Uncomment the following line if you want to disable marking untracked files
+# under VCS as dirty. This makes repository status check for large repositories
+# much, much faster.
+# DISABLE_UNTRACKED_FILES_DIRTY="true"
+plugins=(git fzf zsh-autosuggestions zsh-kubectl-prompt vi-mode)
+
+# neovim
+export EDITOR="nvim"
+
+# kube prompt
+zstyle ':zsh-kubectl-prompt:' namespace true # show namespace
+function kube_prompt_info() {
+ if ! [[ "$ZSH_KUBECTL_PROMPT" == *"current-context is not set"* ]]; then
+ # remove all the aws junk
+ cluster_ns=$(echo ${ZSH_KUBECTL_PROMPT} | sed 's/^arn.*:cluster\///')
+ echo -n "%{$fg[cyan]%}(⎈ ${cluster_ns})%{$reset_color%}"
+ fi
+}
+KUBE_RPROMPT="\$(kube_prompt_info)"
+
+# aws prompt
+function aws_prompt_info() {
+ if ! [ -z "$AWS_PROFILE" ]; then
+ echo -n "%{$fg[yellow]%}(☁️ ${AWS_PROFILE})%{$reset_color%}"
+ fi
+}
+AWS_RPROMPT="\$(aws_prompt_info)"
+
+# vi mode
+# only if not in vim
+if ! [ -n "$VIMRUNTIME" ]; then
+ bindkey -v
+ VI_MODE_SET_CURSOR=true
+ VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
+ VI_MODE_RPROMPT="\$(vi_mode_prompt_info)"
+ # map jk to escape
+ bindkey jk vi-cmd-mode
+ MODE_INDICATOR="%F{red}(V)%f"
+else
+ VI_MODE_RPROMPT=""
+fi
+
+# Set RPROMPT with my plugins and stuff
+RPROMPT="${AWS_RPROMPT}${KUBE_RPROMPT}${VI_MODE_RPROMPT}"
+
+# User configuration
+ZSH_AUTOSUGGEST_USE_ASYNC=true
+
+ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8"
+
+# Disable bracketed-paste-magic among other things
+# https://github.com/ohmyzsh/ohmyzsh/issues/5569
+DISABLE_MAGIC_FUNCTIONS=true
+
+# FZF
+source "${HOMEBREW_PREFIX}/opt/fzf/shell/completion.zsh"
+source "${HOMEBREW_PREFIX}/opt/fzf/shell/key-bindings.zsh"
+export FZF_TMUX_OPTS='-d 40%'
+bindkey "ç" fzf-cd-widget
+
+
+# gcloud completion
+if [ -f "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc" ]; then
+ source "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc"
+fi
+if [ -f "${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc" ]; then
+ source "${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc"
+fi
+
+# Hack to prevent tmux starting on some terminal emulators
+# NO_TMUX is a hash of value=variable pairs, when the variable matches the value,
+# tmux will not be started.
+#typeset -A NO_TMUX
+#NO_TMUX[JetBrains-JediTerm]="TERMINAL_EMULATOR" # Intellij
+#NO_TMUX[com.apple.Terminal]="__CFBundleIdentifier"
+#NO_TMUX[screen]="TERM"
+
+#TMUX_DEFAULT_SESSION=main
+#RUN_TMUX=true
+#for k v in ${(@kv)NO_TMUX}; do
+ #if [ "${(P)v}" = "${k}" ]; then
+ #RUN_TMUX=false
+ #fi
+#done
+
+#if [ "$RUN_TMUX" = true ]; then
+ #[ -z "$TMUX" ] && tmux new-session -As ${TMUX_DEFAULT_SESSION}
+#fi