Add kubectl/dev env stuff
This commit is contained in:
parent
204c91becf
commit
feacf83360
2 changed files with 106 additions and 19 deletions
75
.zsh/aliases
75
.zsh/aliases
|
|
@ -261,14 +261,16 @@ gs -- git status
|
|||
gst -- git stash
|
||||
gstp -- git stash pop
|
||||
gu -- git pull'"
|
||||
alias git="hub"
|
||||
#alias git="hub"
|
||||
alias gs="git status"
|
||||
alias gl="git lg"
|
||||
alias gla="git lg --all"
|
||||
alias ge="git checkout"
|
||||
alias gesp="git checkout --patch"
|
||||
alias geb="git checkout -b"
|
||||
alias gb="git branch"
|
||||
alias ga="git add"
|
||||
alias gasp="git add --patch"
|
||||
alias gd="git diff"
|
||||
alias gdc="git diff --cached"
|
||||
alias gc="git commit"
|
||||
|
|
@ -284,6 +286,73 @@ alias gk="gitk --all&"
|
|||
alias gx="gitx --all"
|
||||
alias grs="git restore --staged "
|
||||
|
||||
alias dvh="echo 'dvt <lang> -- create a local dev template
|
||||
dva <lang> -- add a dev template
|
||||
dvr <lang> -- remove a dev template
|
||||
dvl -- list dev templates'"
|
||||
function dvt() {
|
||||
[ -z $1 ] && echo 'usage: dvt <lang>' && return 1
|
||||
[ -f ".envrc" ] && echo "Already using a dev template." && return 1
|
||||
nix flake init -t "github:the-nix-way/dev-templates#$1"
|
||||
direnv allow
|
||||
}
|
||||
function dva() {
|
||||
[ -z $1 ] && echo 'usage: dva <lang>' && return 1
|
||||
[ -z $(dvl $1) ] && echo "Dev template $1 not found." && return 1
|
||||
echo "use flake \"github:the-nix-way/dev-templates?dir=$1\"" >> .envrc
|
||||
direnv allow
|
||||
}
|
||||
function dvr() {
|
||||
[ -z $1 ] && echo 'usage: dvr <lang>' && return 1
|
||||
[ ! -f ".envrc" ] && echo "No dev template found." && return 1
|
||||
if ! grep -q "github:the-nix-way/dev-templates?dir=$1" .envrc; then
|
||||
echo "Dev template $1 not found." && return 1
|
||||
fi
|
||||
sed -i "/use flake \"github:the-nix-way\/dev-templates?dir=$1\"/d" .envrc
|
||||
direnv allow
|
||||
}
|
||||
function dve() {
|
||||
if [ -f ".envrc" ]; then
|
||||
grep -o 'github:the-nix-way/dev-templates?dir=[^"]*' .envrc | sed 's/github:the-nix-way\/dev-templates?dir=//g'
|
||||
fi
|
||||
}
|
||||
function dvl() {
|
||||
local enabled_templates=()
|
||||
if [ -f ".envrc" ]; then
|
||||
enabled_templates=($(grep -o 'github:the-nix-way/dev-templates?dir=[^"]*' .envrc | sed 's/github:the-nix-way\/dev-templates?dir=//g'))
|
||||
fi
|
||||
|
||||
local templates
|
||||
templates=$(curl -s https://api.github.com/repos/the-nix-way/dev-templates/contents | \
|
||||
jq -r '.[] | select(.type == "dir") | select(.name != ".github") | .name')
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "$templates" | while read -r template; do
|
||||
[[ " ${enabled_templates[*]} " == *" $template "* ]] && echo "* $template" || echo " $template"
|
||||
done
|
||||
else
|
||||
echo "$templates" | grep -x "$1"
|
||||
fi
|
||||
}
|
||||
function dvs() {
|
||||
if [ -f "shell.nix" -o -f ".envrc" ]; then
|
||||
echo "Dev shell already exists"
|
||||
return 1
|
||||
fi
|
||||
echo "use nix" > .envrc
|
||||
cat > shell.nix <<EOF
|
||||
let
|
||||
pkgs = import <nixpkgs> { config.allowUnfree = true; };
|
||||
#unstable = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz") {
|
||||
# config.allowUnfree = true;
|
||||
#};
|
||||
in pkgs.mkShell {
|
||||
packages = [
|
||||
];
|
||||
}
|
||||
EOF
|
||||
direnv allow
|
||||
}
|
||||
|
||||
# Docker
|
||||
#alias docker="podman"
|
||||
|
|
@ -329,16 +398,20 @@ alias kh="echo 'k -- kubectl
|
|||
kg -- kubectl get ...
|
||||
kga -- kubectl get all
|
||||
kgan -- kubectl get all in all namespaces
|
||||
kd -- kubectl describe
|
||||
kxl -- list contexts
|
||||
knl -- list namespaces
|
||||
kx <context> -- switch context ...
|
||||
kxs <context> -- set \$KUBE_CONTEXT
|
||||
kn <namespace> -- switch namespace ...
|
||||
klf <pod> -- follow logs
|
||||
kat <pod> [cmd] -- attach and run cmd in pod'"
|
||||
alias k="kubectl"
|
||||
alias kg="kubectl get --show-kind"
|
||||
function kgj() { kubectl get -o json $@ | jq . | bat -pl json }
|
||||
alias kga="kubectl get all"
|
||||
alias kgan="kubectl --all-namespaces=true get all"
|
||||
function kd() { kubectl describe ${1} | bat -pl yaml }
|
||||
alias kxl="kubectl config get-contexts"
|
||||
alias knl="kubectl get namespaces"
|
||||
alias kx="kubectl config use-context"
|
||||
|
|
|
|||
50
.zshrc
50
.zshrc
|
|
@ -13,7 +13,7 @@ fpath=(/usr/local/share/zsh-completions /opt/homebrew/share/zsh/site-functions $
|
|||
#typeset -u fpath
|
||||
|
||||
# Options
|
||||
setopt prompt_subst inc_append_history hist_ignore_space hist_ignore_all_dups hist_expire_dups_first hist_find_no_dups hist_save_no_dups hist_reduce_blanks extendedglob nomatch notify dvorak interactive_comments # correct
|
||||
setopt prompt_subst append_history hist_ignore_space hist_ignore_all_dups hist_expire_dups_first hist_find_no_dups hist_save_no_dups hist_reduce_blanks extendedglob nomatch notify dvorak interactive_comments # correct
|
||||
unsetopt beep
|
||||
bindkey -e
|
||||
|
||||
|
|
@ -53,8 +53,11 @@ esac
|
|||
# Paths
|
||||
#export LD_LIBRARY_PATH=/opt/csw/lib
|
||||
#zsh's path
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
export MANPATH=~/local/share/man:/usr/man:/usr/share/man:/usr/local/share/man
|
||||
if whence systemctl > /dev/null ; then
|
||||
systemctl --user import-environment PATH
|
||||
fi
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||
#export MANPATH=~/local/share/man:/usr/man:/usr/share/man:/usr/local/share/man
|
||||
#paths=(/cat/bin)
|
||||
prepaths=(/opt/puppetlabs/pdk/bin ~/.config/emacs/bin /opt/homebrew/bin /usr/local/bin /usr/local/sbin /usr/local/opt/node@8/bin ~/.local/bin ~/.rbenv/bin ~/local/talon ~/local/bin ~/local/sbin)
|
||||
#for dir in $paths ; do
|
||||
|
|
@ -65,14 +68,14 @@ prepaths=(/opt/puppetlabs/pdk/bin ~/.config/emacs/bin /opt/homebrew/bin /usr/loc
|
|||
# export MANPATH=$MANPATH:${dir:a:h}/man
|
||||
# fi
|
||||
#done
|
||||
for dir in $prepaths ; do
|
||||
if [ -d $dir ] ; then
|
||||
export PATH=$dir:$PATH
|
||||
fi
|
||||
if [ -d ${dir:a:h}/man ] ; then
|
||||
export MANPATH=${dir:a:h}/man:$MANPATH
|
||||
fi
|
||||
done
|
||||
#for dir in $prepaths ; do
|
||||
# if [ -d $dir ] ; then
|
||||
# export PATH=$dir:$PATH
|
||||
# fi
|
||||
# if [ -d ${dir:a:h}/man ] ; then
|
||||
# export MANPATH=${dir:a:h}/man:$MANPATH
|
||||
# fi
|
||||
#done
|
||||
# Load profiles from /etc/profile.d
|
||||
if test -d /etc/profile.d/; then
|
||||
for profile in /etc/profile.d/*.sh; do
|
||||
|
|
@ -105,6 +108,7 @@ fi
|
|||
# export PATH=$PATH:$dir
|
||||
#done
|
||||
export XDG_DATA_DIRS="$HOME/.local/share:$XDG_DATA_DIRS"
|
||||
export CM_DIR="$HOME/.config/clipmenu"
|
||||
|
||||
# Setting vars
|
||||
#TERM=rxvt
|
||||
|
|
@ -163,7 +167,16 @@ terraform_wrapper() {
|
|||
fi
|
||||
fi
|
||||
}
|
||||
RPROMPT=$'$(terraform_wrapper)$(vcs_info_wrapper)${PTIME}'
|
||||
kubectl_wrapper() {
|
||||
if type -p kubectl > /dev/null ; then
|
||||
local k8s_context=$(kubectl config current-context)
|
||||
local k8s_namespace=$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}')
|
||||
if [ -n "$k8s_context" ]; then
|
||||
echo "%{$fg_bold[grey]%}[%{$fg_no_bold[blue]%}${k8s_context}:${k8s_namespace}%{$fg_bold[grey]%}]%{$reset_color%}$del"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
RPROMPT=$'$(kubectl_wrapper)$(terraform_wrapper)$(vcs_info_wrapper)${PTIME}'
|
||||
|
||||
if [ `uname -s` = "SunOS" ] ; then
|
||||
export LANG="C"
|
||||
|
|
@ -295,12 +308,7 @@ EOF
|
|||
# eval "$(command pyenv init - zsh)" # --no-rehash)"
|
||||
#fi
|
||||
#[ -f ~/.zsh-fuzzy-match/fuzzy-match.zsh ] && source ~/.zsh-fuzzy-match/fuzzy-match.zsh
|
||||
if [ -d ~/.asdf ] ; then
|
||||
. $HOME/.asdf/asdf.sh
|
||||
if [ -d $HOME/.asdf/plugins/java ]; then
|
||||
. $HOME/.asdf/plugins/java/set-java-home.zsh
|
||||
fi
|
||||
fi
|
||||
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
|
||||
enabledotnet() {
|
||||
if [ -d ~/.dotnet/tools ] ; then
|
||||
# Add .NET Core SDK tools
|
||||
|
|
@ -312,6 +320,11 @@ enabledotnet() {
|
|||
#export PATH=$(go env GOPATH)/bin:$PATH
|
||||
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
# and for nixos
|
||||
if [ -n "${commands[fzf-share]}" ]; then
|
||||
source "$(fzf-share)/key-bindings.zsh"
|
||||
source "$(fzf-share)/completion.zsh"
|
||||
fi
|
||||
|
||||
getstageadsktoken() {
|
||||
TEMP_TOKEN=$(echo -n ${ADSK_HUNNER_STG_CLI_CLIENT_ID}:${ADSK_HUNNER_STG_CLI_CLIENT_SECRET} | base64)
|
||||
|
|
@ -382,6 +395,7 @@ fi
|
|||
[ ! -s /home/hunner/.travis/travis.sh ] || source /home/hunner/.travis/travis.sh
|
||||
|
||||
#eval "$(starship init zsh)"
|
||||
eval "$(direnv hook zsh)"
|
||||
|
||||
# The next line updates PATH for the Google Cloud SDK.
|
||||
if [ -f '/home/hunner/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/home/hunner/Downloads/google-cloud-sdk/path.zsh.inc'; fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue