Archived
1
0
Fork 0

Add Toolbox image

This commit is contained in:
J. Elfring (x) 2021-03-27 18:35:37 +01:00
parent bfef7e23a9
commit ace066a36d
4 changed files with 336 additions and 0 deletions

40
toolbox/Dockerfile Normal file
View file

@ -0,0 +1,40 @@
FROM alpine:latest
LABEL maintainer "J. Elfring <code@elfring.ms>"
RUN apk add --update --no-cache \
bash \
bind-tools \
busybox-extras \
ca-certificates \
curl \
git \
jq \
msmtp \
mysql-client \
netcat-openbsd \
openssh-client \
openssl \
postgresql-client \
rsync \
socat \
sqlite \
vim \
w3m \
wget
RUN apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \
helm \
kubectl
ADD assets/profile.d/* /etc/profile.d/
RUN mv /etc/profile.d/color_prompt /etc/profile.d/color_prompt.sh
COPY assets/vimrc /etc/vim/vimrc
WORKDIR /root
CMD /bin/bash -li

View file

@ -0,0 +1,38 @@
#!/bin/bash
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Shortcuts
alias g="git"
alias h="history"
alias k="kubectl"
# Always use color output for `ls`
# And sort directories before files
alias ls="ls --color --group-directories-first"
# ls abbreviation
alias l="ls -l"
alias ll="ls -l"
alias la="ls -la"
# Always enable colored `grep` output
alias grep='grep --color=auto '
# Enable aliases to be sudoed
alias sudo='sudo '
# Canonical hex dump some systems have this symlinked
command -v hd > /dev/null || alias hd="hexdump -C"
# vi == vim
alias vi='vim'
# Passwort erstellen
alias mkpasswd='openssl rand -base64 40 | cut -c1-40'

View file

@ -0,0 +1,65 @@
#!/bin/bash
# Trap RC != 0 and display
EC() {
echo -e '\e[1;31m'code $?'\e[m\n'
}
trap EC ERR
# Create a new directory and enter it
mkd() {
mkdir -p "$@" && cd "$@"
}
# Make a temporary directory and enter it
tmpd() {
if [ $# -eq 0 ]; then
dir=`mktemp -d` && cd $dir
else
dir=`mktemp -d -t $1.XXXXXXXXXX` && cd $dir
fi
}
# Run `dig` and display the most useful info
digga() {
dig +nocmd "$1" any +multiline +noall +answer
}
## Dump SSL Cert from host
## sslcheck example.com:25 -starttls smtp
## sslcheck example.com:443
sslcheck(){
echo -n | openssl s_client -connect $* | tee /dev/tty | openssl x509 -text -noout
}
## SSH agent
## Add sth like test -z $noKeychain && agent to ~/.extra
function agent(){
/usr/bin/keychain --nolock --nogui $HOME/.ssh/id_rsa
source $HOME/.keychain/$HOSTNAME-sh
}
## Kubernetes Goodies
k(){
kubectl $*
}
k-sel(){
kubeconfig=$(find ~/.kube/kubesel -type f | rev | cut -d "/" -f 1 | rev | sort | fzf --height=25%)
export KUBECONFIG=~/.kube/kubesel/$kubeconfig
echo
kubectl config get-contexts
}
k-ns(){
kubectl config set-context
--current \
--namespace=$(kubectl get namespace | grep Active \
| cut -d " " -f1 \
| fzf --height=25%
)
echo
kubectl config get-contexts
}

193
toolbox/assets/vimrc Executable file
View file

@ -0,0 +1,193 @@
" Basics
"
set nocompatible " be iMproved, required
let mapleader = ","
let g:mapleader = ","
let maplocalleader = ";"
" Settings
"
set noerrorbells " No beeps
set number " Show line numbers
set backspace=indent,eol,start " Makes backspace key more powerful.
set showcmd " Show me what I'm typing
set noswapfile " Don't use swapfile
set nobackup " Don't create annoying backup files
set nowritebackup
set splitright " Split vertical windows right to the current windows
set splitbelow " Split horizontal windows below to the current windows
set encoding=utf-8 " Set default encoding to UTF-8
set autowrite " Automatically save before :next, :make etc.
set autoread " Automatically reread changed files without asking me anything
set laststatus=2
set hidden
set ruler " Show the cursor position all the time
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
set showmatch " Show matching brackets by flickering
set showmode
" Search Options
set incsearch
set hlsearch
set ignorecase
set smartcase
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> # :call VisualSelection('b')<CR>
" Center search results
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap <leader><space> :nohlsearch<CR>
set ttyfast
set lazyredraw
set nocursorcolumn
set nocursorline
set synmaxcol=300
set re=1
" open help vertically
command! -nargs=* -complete=help Help vertical belowright help <args>
" Make Vim to handle long lines nicely.
set wrap
set textwidth=79
set formatoptions=qrn1
set complete-=i
set nrformats-=octal
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=10
" Different Cursorshapes for the modes
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
" Better Completion
set complete=.,w,b,u,t
set completeopt=longest,menuone
set history=500
set tabpagemax=50
set scrolloff=7
set sidescrolloff=7
set display+=lastline
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
syntax on
syntax sync minlines=256
filetype plugin indent on
colorscheme elflord
if has('gui_running')
"set transparency=3
"fix js regex syntax
set regexpengine=1
endif
" Toggle line numbers and rulers
nmap <leader>ll :set number!<cr>
nmap <leader>lr :set relativenumber!<cr>
nmap <leader>cc :set cursorcolumn!<cr>
nmap <leader>cl :set cursorline!<cr>
" Better split switching
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
map <C-down> <C-W>j
map <C-up> <C-W>k
map <C-left> <C-W>h
map <C-right> <C-W>l
" Center the screen
nnoremap <space> zz
" Move up and down on splitted lines (on small width screens)
map <Up> gk
map <Down> gj
map k gk
map j gj
" Spell checking
nnoremap <F6> :setlocal spell! spell?<CR>
map <leader>ss :setlocal spell!<cr>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
" trim all whitespaces away
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Do not show stupid q: window
map q: :q
" dont save .netrwhist history
let g:netrw_dirhistmax=0
" Allow saving of files as sudo
cmap w!! w !sudo tee > /dev/null %
" Paste Mode
set pastetoggle=<F2>
" ----------------------------------------- "
" File Type settings "
" ----------------------------------------- "
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set smarttab
set expandtab
set shiftround
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.json setlocal et ts=2 sw=2 sts=2
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.md setlocal et ts=4 sw=4 sts=4
au BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.py setlocal et ts=4 sw=4 sts=4
au BufNewFile,BufRead *.yml,*.yaml setlocal et ts=2 sw=2 sts=2
au FileType nginx setlocal noet ts=4 sw=4 sts=4
au FileType dockerfile setlocal et ts=2 sw=2 sts=2
au FileType fstab,systemd set noet
au FileType gitconfig,sh,toml set noet
" ==================== Wildmenu ====================
set wildmenu
" set wildmode=list:longest
set wildmode=list:full
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=go/pkg " Go static files
set wildignore+=go/bin " Go bin files
set wildignore+=go/bin-vagrant " Go bin-vagrant files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
" vim:ts=2:sw=2:et