diff --git a/.gitmodules b/.gitmodules index 4b0b5ff..8fcabea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "private"] path = private - url = ssh://git@git.a09.uk:48765/alex/alex-environ-private.git + url = ssh://git@git.a09.uk:48766/alex/alex-environ-private.git diff --git a/home/.bashrc b/home/.bashrc index ef5c4ac..629c288 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -4,6 +4,8 @@ [[ $- != *i* ]] && return #SET PATH IN .BASH_PROFILE +# Set the shell's editor to vi mode +set -o vi #don't put duplicate lines or lines beginning with a space into history HISTCONTROL=ignoreboth diff --git a/home/.config/cspell/config.yaml b/home/.config/cspell/config.yaml new file mode 100644 index 0000000..eefa686 --- /dev/null +++ b/home/.config/cspell/config.yaml @@ -0,0 +1,9 @@ +--- +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: "0.2" +#dictionaryDefinitions: +# - name: custom-words +# path: "~/.alex-environ/.home/cspell/custom-words.txt" +# addWords: true +#dictionaries: +# - custom-words diff --git a/home/.config/cspell/custom-words.txt b/home/.config/cspell/custom-words.txt new file mode 100644 index 0000000..e69de29 diff --git a/home/.config/pylintrc b/home/.config/pylintrc index db4d3e6..055628f 100644 --- a/home/.config/pylintrc +++ b/home/.config/pylintrc @@ -28,7 +28,7 @@ limit-inference-results=100 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +#load-plugins=pylint_django # Pickle collected data for later comparisons. persistent=yes diff --git a/home/.gitconfig b/home/.gitconfig index e1048bc..6bc3d4a 100644 --- a/home/.gitconfig +++ b/home/.gitconfig @@ -19,9 +19,7 @@ required = true clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f - -[core] - hooksPath = ~/.alex-environ/private/home/git_hooks - [alias] adog = log --all --decorate --oneline --graph +[rerere] + enabled = true diff --git a/home/.inputrc b/home/.inputrc new file mode 100644 index 0000000..b2cc9d6 --- /dev/null +++ b/home/.inputrc @@ -0,0 +1 @@ +set editing-mode vi diff --git a/home/.local/bin/kubectl-ssh b/home/.local/bin/kubectl-ssh new file mode 100755 index 0000000..8e5a23a --- /dev/null +++ b/home/.local/bin/kubectl-ssh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash + +set -e + +ssh_node() { + node=$1 + shift + if [ "$node" = "" ]; then + node=$(kubectl get node -o name "$@" | sed 's/node\///' | tr '\n' ' ') + node=${node::-1} + + if [[ "$node" =~ " " ]]; then + echo "Node name must be specified. Choose one of: [$node]" + exit 1 + else + echo "Single-node cluster detected. Defaulting to node $node" + fi + fi + + if [ $# -eq 1 ]; then + command="$1" + shift + fi + + ns=kube-system + pod=$( + kubectl create -n "$ns" -o name "$@" -f - </dev/null + + if [ -z "$command" ]; then + kubectl attach -n "$ns" -it "$pod" -c ssh-node "$@" + else + kubectl exec -n "$ns" -it "$pod" ssh-node -- "$command" + fi +} + +ssh_pod() { + # TODO: improve this + if [ "$1" == "" ]; then + echo "Pod name must be specified." + exit 1 + fi + # Use sh as a default and switch to bash if it's available + # shellcheck disable=SC2016 + kubectl exec -it "$@" -- sh -c 'exec "$( command -v bash || echo sh )"' +} + +print_usage() { + echo "Provider-agnostic way of opening a remote shell to a Kubernetes node." + echo + echo "Enables you to access a node even when it doesn't run an SSH server or" + echo "when you don't have the required credentials. Also, the way you log in" + echo "is always the same, regardless of what provides the Kubernetes cluster" + echo "(e.g. Minikube, Kind, Docker Desktop, GKE, AKS, EKS, ...)" + echo + echo "You must have cluster-admin rights to use this plugin." + echo + echo "The primary focus of this plugin is to provide access to nodes, but it" + echo "also provides a quick way of running a shell inside a pod." + echo + echo "Examples: " + echo " # Open a shell to node of a single-node cluster (e.g. Docker Desktop)" + echo " kubectl ssh node" + echo + echo " # Open a shell to node of a multi-node cluster (e.g. GKE)" + echo " kubectl ssh node my-worker-node-1" + echo + echo " # Execute the command ls on a node my-worker-node-1" + echo " kubectl ssh node my-worker-node-1 ls" + echo + echo " # Open a shell to a pod" + echo " kubectl ssh pod my-pod" + echo + echo "Usage:" + echo " kubectl ssh node [nodeName [command]]" + echo " kubectl ssh pod [podName] [-n namespace] [-c container]" + exit 0 +} + +if [ "$1" == "--help" ]; then + print_usage +fi + +if [[ "$1" == node/* ]]; then + nodeName=${1:5} + shift + ssh_node "$nodeName" "$@" +elif [ "$1" == "node" ]; then + shift + case "$1" in + -*) nodeName="";; + "") ;; + *) nodeName="$1"; shift ;; + esac + + ssh_node "$nodeName" "$@" +elif [[ "$1" == pod/* ]]; then + ssh_pod "$@" +elif [ "$1" == "pod" ]; then + shift + ssh_pod "$@" +else + print_usage +fi diff --git a/home/.vimrc.d/coc/coc-settings.json b/home/.vimrc.d/coc/coc-settings.json index 9a5808d..866e5e2 100644 --- a/home/.vimrc.d/coc/coc-settings.json +++ b/home/.vimrc.d/coc/coc-settings.json @@ -1,4 +1,6 @@ { + "coc.preferences.extensionUpdateCheck": "weekly", + "rust-client.disableRustup": true, "javascript.format.enabled": false, @@ -13,5 +15,4 @@ "jedi.enable": true, "suggest.noselect": true, - } diff --git a/home/.vimrc.d/dev-environ.vim b/home/.vimrc.d/dev-environ.vim index 0faade0..104f61a 100644 --- a/home/.vimrc.d/dev-environ.vim +++ b/home/.vimrc.d/dev-environ.vim @@ -43,9 +43,12 @@ let g:ale_fortran_gcc_use_free_form = 0 "JSON let g:ale_json_jq_options = '--sort-keys' +" Spell checking +let g:ale_cspell_options = '--config ~/.alex-envion/home/.config/cspell/config.yaml' + """Base Settings for COC let g:coc_config_home = '~/.alex-environ/home/.vimrc.d/coc' -let g:coc_global_extensions = ['coc-jedi', 'coc-rls', 'coc-tsserver', 'coc-json', 'coc-htmldjango'] +let g:coc_global_extensions = ['coc-jedi', 'coc-rust-analyzer', 'coc-tsserver', 'coc-json', 'coc-htmldjango'] """Language Specific Options. "Remeber that COC has it's own settings file too, so most of it's settings are "there. diff --git a/home/.vimrc.d/plugins.vim b/home/.vimrc.d/plugins.vim index 398a050..119d8c6 100644 --- a/home/.vimrc.d/plugins.vim +++ b/home/.vimrc.d/plugins.vim @@ -26,7 +26,7 @@ function! LoadPlugins() Plug 'amanning9/django-plus.vim' " Improvements for identifying files in django projects. Plug 'towolf/vim-helm' - Plug 'Glench/Vim-Jinja2-Syntax' " Jinja syntax detection. + Plug 'https://gitlab.com/HiPhish/jinja.vim.git' " Jinja syntax detection. endfunction " PLUGIN INITIALISATION diff --git a/home/scripts/ssh_agent_setup b/home/scripts/ssh_agent_setup index 82c3cdd..e1ad544 100755 --- a/home/scripts/ssh_agent_setup +++ b/home/scripts/ssh_agent_setup @@ -6,7 +6,6 @@ SSH_ENV=$HOME/.ssh/environment.`hostname` start_agent () { # $1 Socket path to bind to. - # If not running interactively, don't do anything else [[ $- != *i* ]] && return @@ -31,6 +30,11 @@ load_keys () fi } +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return +# If we are a subshell we should not do anything. +[[ $0 != -* ]] && return + # Source SSH settings, if applicable # If a ssh auth socket exists at this point, it must be from a forwarded agent. if [ -n "${SSH_AUTH_SOCK+set}" ] && [[ ${SSH_AUTH_SOCK} != *"com.apple.launchd"* ]] diff --git a/private b/private index 0e34233..b306aff 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 0e34233ad56224b2096022a2c8b0f4b4bd87d2d0 +Subproject commit b306afff013552ece60cd7e7cf8e5ec061ac71ba diff --git a/setup/linters b/setup/linters index 78bcbc7..fc30499 100644 --- a/setup/linters +++ b/setup/linters @@ -8,3 +8,4 @@ vint from npm -g fixjson +cspell diff --git a/setup/setupscript.sh b/setup/setupscript.sh index 89dee6b..7cbd81f 100755 --- a/setup/setupscript.sh +++ b/setup/setupscript.sh @@ -65,3 +65,6 @@ ln -s ${environ_home}/.config/mypy ~/.config/mypy ##### In home dir ln -s ${environ_home}/.fonts ~/.fonts + +# readline +ln -s ${environ_home}/.inputrc ~/.inputrc