Merge branch 'heavy-aws'

This commit is contained in:
Stefan Gaiselmann 2020-11-09 08:35:21 +01:00
commit e8b3091bfb
6 changed files with 330 additions and 3 deletions

1
.chezmoiignore Normal file
View File

@ -0,0 +1 @@
vim-lightline.tar.gz

View File

@ -15,3 +15,46 @@ Test with `centos7-01`:
. apply it with `./chezmoi apply` . apply it with `./chezmoi apply`
After that a `bin` directory will exist (if not yet present before), move the executable to this dir to have it `PATH`. After that a `bin` directory will exist (if not yet present before), move the executable to this dir to have it `PATH`.
=== AWS Systeme (Draft)
TODO: create user file for initialization at provisioning
. install go `sudo yum install -y golang golang-bin`
. install git `sudo yum install -y git-all`
. install _chezmoi_ from git repo (see below)
. check GOPATH and adjust if necessary
. initialize with `chezmoi init https://gitea.sdroid.uber.space/heavy/dotfiles.git` (Use 'heavy' as user).
. check what will happen with `chezmoi diff`
. TODO: vi .config/chezmoi/chezmoi.toml (Template is not correct)
. apply it with `chezmoi apply`
.chezmoi installation
[source,console]
cd $(mktemp -d)
git clone --depth=1 https://github.com/twpayne/chezmoi.git
cd chezmoi
go install
==== New User
Better try modifications with a new user to keep the defaul user accessible to the system.
See below links to proceed.
* https://aws.amazon.com/de/premiumsupport/knowledge-center/new-user-accounts-linux-instance/
* https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#retrieving-the-public-key
=== Uberspace
Alternative way to include .sshrc by detecting SSH connection.
[source,bash]
----
# User specific aliases and functions
if [ -f ~/.sshrc ] && [ -z "$SSH_CLIENT" ]; then
echo "Not a ssh connection"
else
echo "ssh client is present: $SSH_CLIENT"
. ~/.sshrc
fi
----

View File

@ -6,9 +6,58 @@
[alias] [alias]
graph = log --graph --pretty=format:'%Cred%h %Creset-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(blue)<%an>%Creset' --abbrev-commit --date=relative -30 graph = log --graph --pretty=format:'%Cred%h %Creset-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(blue)<%an>%Creset' --abbrev-commit --date=relative -30
logshort = log --pretty=format:'%Cred%h %Cgreen[%cd]%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --date=short
showfull = show --format=fuller --name-only
# more aliases from https://stackoverflow.com/questions/2553786/how-do-i-alias-commands-in-git
bv = branch -a -vv
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]%Creset%Cgreen\\ (%cd)" --decorate --numstat --date=relative
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
# list remote branches ordered by date
rr = for-each-ref --sort=-committerdate refs/remotes/ --count=20 --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
# show tracked files
ls-tracked = ls-tree -r --name-only HEAD
# show number of commits per author
# https://stackoverflow.com/questions/9839083/git-number-of-commits-per-author-on-all-branches
stats = shortlog -s -n --all --no-merges
# show staged changes
diffc = diff --cached -w
diffw = diff -w
wdiff = diff --word-diff=color --unified=1
# show stats
stat = show --stat --format=fuller
# from https://dzone.com/articles/lesser-known-git-commands
commend = commit --amend --no-edit
stashed = stash list --date=local
s = status --column --show-stash
ss = status -s --branch -uno
co = checkout
pr = remote prune origin
# from pixelbeat
brdate = for-each-ref --sort=-committerdate --format='%(committerdate:iso8601) %(refname:short)' refs/heads/
st = stash list --date=local
alias = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ /
d = diff -w
dc = diff -w --cached
[core] [core]
editor = vim editor = vim
[push]
# default = matching
default = simple # safer option, push only current branch
[merge]
tool = p4merge
ff = false
[pull]
ff = only

View File

@ -1,10 +1,10 @@
# #
# sshrc will be called byaliased ssh command 's'. # sshrc will be called byaliased ssh command 's'.
# #
if [ -f $HOME/.profile ]; then if [ -f $HOME/.profile ] && [ "$SOURCE_PROFILE" = "true" ]; then
source $HOME/.profile source $HOME/.profile
fi fi
if [ -f $HOME/.bashrc ]; then if [ -f $HOME/.bashrc ] && [ "$SOURCE_BASHRC" = "true" ]; then
source $HOME/.bashrc source $HOME/.bashrc
fi fi

234
dot_vimrc Normal file
View File

@ -0,0 +1,234 @@
" ██
" ░░
" ██ ██ ██ ██████████ ██████ █████
" ░██ ░██░██░░██░░██░░██░░██░░█ ██░░░██
" ░░██ ░██ ░██ ░██ ░██ ░██ ░██ ░ ░██ ░░
" ░░████ ░██ ░██ ░██ ░██ ░██ ░██ ██
" ░░██ ░██ ███ ░██ ░██░███ ░░█████
" ░░ ░░ ░░░ ░░ ░░ ░░░ ░░░░░
"
"
" ▓▓▓▓▓▓▓▓▓▓
" ▓ author ▓ Stefan Gaiselmann
" ░▓ based ▓ on work of xero <x@xero.nu>
" ░▓ code ▓ http://code.xero.nu/dotfiles
" ░░░░░░░░░░
"
" Use vim settings, rather then vi settings (much better!)
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype plugin indent on " enable detection, plugins and indenting in one step
syntax on
" Test https://github.com/mintty/mintty/wiki/Tips
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
" Inspiried by http://nvie.com/posts/how-i-boosted-my-vim/
" Editing behaviour {{{
set showmode " always show what mode we're currently editing in
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set scrolloff=4 " keep 4 lines off the edges of the screen when scrolling
set virtualedit=all " allow the cursor to go in to "invalid" places
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set listchars=eol:$,tab:>-,trail:·,extends:#,nbsp:·
set nolist " don't show invisible characters by default,
" but it is enabled for some file types (see later)
set pastetoggle=<F2> " when in insert mode, press <F2> to go to
" paste mode, where you can paste mass data
" that won't be autoindented
set fileformats="unix,dos,mac"
set formatoptions+=1 " When wrapping paragraphs, don't end lines
" with 1-letter words (looks stupid)
set nrformats= " make <C-a> and <C-x> play well with
" zero-padded numbers (i.e. don't consider
" them octal or hex)
set shortmess+=I " hide the launch screen
set clipboard=unnamed " normal OS clipboard interaction
set autoread " automatically reload files changed outside of Vim
" Vim behaviour {{{
set hidden " hide buffers instead of closing them this
" means that the current buffer can be put
" to background without being written; and
" that marks and undo history are preserved
set switchbuf=useopen " reveal already opened files from the
" quickfix window instead of opening new
" buffers
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
if v:version >= 730
set undofile " keep a persistent backup file
set undodir=~/.vim/.undo,~/tmp,/tmp
endif
set nobackup " do not keep backup files, it's 70's style cluttering
set noswapfile " do not write annoying intermediate swap files,
" who did ever restore from swap files anyway?
set directory=~/.vim/.tmp,~/tmp,/tmp
" store swap files in one of these directories
" (in case swapfile is ever turned on)
set viminfo='20,\"80 " read/write a .viminfo file, don't store more
" than 80 lines of registers
set wildmenu " make tab completion for files/buffers act like bash
set wildmode=list:full " show a list when pressing tab and complete
" first full match
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set showcmd " show (partial) command in the last line of the screen
" this also shows visual selection info
set nomodeline " disable mode lines (security measure)
set cursorline " underline the current line, for quick orientation
" }}}
" colorscheme mustang
" colorscheme solarized
" https://superuser.com/questions/249779/how-to-setup-a-line-length-marker-in-vim-gvim
" https://vi.stackexchange.com/questions/356/how-can-i-set-up-a-ruler-at-a-specific-column
" set colorcolumn=80
let &colorcolumn="80,".join(range(120,999),",")
" ┏━┓╺┳╸┏━┓╺┳╸╻ ╻┏━┓╻ ╻┏┓╻┏━╸
" ┗━┓ ┃ ┣━┫ ┃ ┃ ┃┗━┓┃ ┃┃┗┫┣╸
" ┗━┛ ╹ ╹ ╹ ╹ ┗━┛┗━┛┗━╸╹╹ ╹┗━╸
"
" extension of https://github.com/itchyny/lightline.vim/tree/master
set laststatus=2
hi BgColor guibg=#3A3A3A guifg=#ffffff ctermbg=237 ctermfg=255
hi ModColor guibg=#3A3A3A guifg=#afaf00 ctermbg=237 ctermfg=142
hi StatColor guibg=#3a3a3a guifg=#ffffff ctermbg=237 ctermfg=255
hi GitColor guibg=#4e4e4e guifg=#ffffff ctermbg=239 ctermfg=255
hi VoidColor guibg=#222222 guifg=#4e4e4e ctermbg=NONE ctermfg=239
hi TypeColor guibg=#D78700 guifg=#262626 ctermbg=66 ctermfg=235
hi PosColor guibg=#8787AF guifg=#262626 ctermbg=103 ctermfg=235
function! WizardStatus(mode)
let statusline="%#BgColor#"
if &modified == 1
let statusline.="%#ModColor# »» "
else
let statusline.=" "
endif
if &readonly != ''
hi StatColor guifg=#af0000 ctermfg=124
endif
let statusline.="%#StatColor#%F "
let statusline .= '%#VoidColor#▒░ '
let statusline .= "%=%h%w\ %#TypeColor#▓"
if &filetype != ''
let statusline .="▒ %Y "
endif
let statusline .="▒ %{&encoding}:%{&fileformat} %#PosColor#▒ %p%% ░ %l/%L\.\%c\ ▒"
return statusline
endfunction
au WinEnter * setlocal statusline=%!WizardStatus('Enter')
au WinLeave * setlocal statusline=%!WizardStatus('Leave')
set statusline=%!WizardStatus('Enter')
function! Colorize(mode)
if a:mode == 'i'
hi StatColor guibg=#D78700 guifg=#222222 ctermbg=110 ctermfg=235
elseif a:mode == 'r'
hi StatColor guibg=#D78700 guifg=#222222 ctermbg=172 ctermfg=235
elseif a:mode == 'v'
hi StatColor guibg=#D78700 guifg=#222222 ctermbg=172 ctermfg=235
else
hi StatColor guibg=#af0000 guifg=#222222 ctermbg=124 ctermfg=235
endif
endfunction
au InsertEnter * call Colorize(v:insertmode)
au InsertLeave * hi StatColor guibg=#3a3a3a guifg=#ffffff ctermbg=237 ctermfg=255
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'filename'], ['filesize', 'more' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename',
\ 'filesize': 'LightLineFilesize',
\ 'more': 'AndMore'
\ },
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ }
function! LigthLineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightLineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return ""
else
return ""
endif
endfunction
function! LightLineFugitive()
" return exists('*fugitive#head') ? "\ue0a0 ".fugitive#head() : ''
" " patched font required
" return exists('*fugitive#head') ? "± ".fugitive#head() : ''
return exists('*fugitive#head') ? "\ue0a0 ".fugitive#head() : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LigthLineModified() ? ' ' .LigthLineModified() : '')
endfunction
function! LightLineFilesize()
let size = getfsize(expand(@%))
return size . ' bytes'
endfunction
function! AndMore()
" return "TODO: more cool stuff!"
" return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
return WebDevIconsGetFileTypeSymbol() "winwidth(0) > 70 ? (&fileformat . ' x ' . WebDevIconsGetFileTypeSymbol()) : 'no ft'
endfunction

BIN
vim-lightline.tar.gz Normal file

Binary file not shown.