Add: json2yaml, nvim, host support & more

This commit is contained in:
Gerrit Pannek 2022-02-15 08:34:33 +01:00
parent 82f100058d
commit f9c314858c
6 changed files with 84 additions and 68 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*.swp *.swp
*.pyc *.pyc
/hosts/lb*

83
bashrc
View file

@ -15,64 +15,22 @@ else
USER=$(whoami) USER=$(whoami)
fi fi
export PATH=$PATH:~/bin:~/local/bin export PATH=$PATH:~/bin:~/local/bin:~/local/usr/bin
function tmux_title { function tmux_title {
printf '\033]2;%s\033\\' $@ printf '\033]2;%s\033\\' $@
} }
#tmux_title $(hostname -s) #tmux_title $(hostname -s)
# load powerline if [ -f ~/git/homedir-config/hosts/$(hostname -s)/bashrc ] ; then
if which powerline-daemon &>/dev/null; then source ~/git/homedir-config/hosts/$(hostname -s)/bashrc
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
else else
# otherwise Git prompt source ~/git/homedir-config/hosts/any/bashrc
PS1='\[\033[0;32m\]${USER}@\h\[\033[0m\] [\[\033[0;33m\]\w\[\]\[\033[0;32m\]]\n'$PROMPT_SUFFIX
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_FETCH_REMOTE_STATUS=0
GIT_PROMPT_IGNORE_STASH=1
GIT_PROMPT_THEME=Noldorized
source ~/.bash-git-prompt/gitprompt.sh
function prompt_callback {
REPO=$(git remote -v | sed -r 's/^origin.*\/(.*)\ .*/\1/' | head -1)
tmux_title "$REPO($GIT_BRANCH)"
}
fi fi
PYVERSION=$(python3 --version | grep -Eo '[0-9]\.[0-9]') if type nvim &>/dev/null ; then
if [ -f $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ]; then alias vim=nvim
export VIRTUAL_ENV="$HOME/.venv"
export PATH=$VIRTUAL_ENV/bin:$PATH
# powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
function _update_ps1() {
if git log --oneline -n1 &>/dev/null ; then
REPO=$(git remote -v | sed -r 's/^origin.*\/(.*)\ .*/\1/' | sed 's/.git$//'| head -1)
BRANCH=$(git branch --show-current)
tmux_title "$REPO($BRANCH)"
else
tmux_title "$(hostname)"
fi
PS1=$(powerline-shell $?)
}
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
# source $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
elif [ -f ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ] ; then
#source ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
echo no
elif [ -f /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh ]; then
source /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh
fi fi
set +x
# LS_COLORS # LS_COLORS
eval $(dircolors -b $HOME/.dircolors) eval $(dircolors -b $HOME/.dircolors)
@ -83,17 +41,22 @@ export LESS='-R'
export TERM=xterm-256color export TERM=xterm-256color
export MC_SKIN=$HOME/.mc/lib/solarized.ini export MC_SKIN=$HOME/.mc/lib/solarized.ini
if [ -e ~/.local/bin/virtualenvwrapper.sh ] ; then #if [ -e ~/.local/bin/virtualenvwrapper.sh ] ; then
# Python stuff # # Python stuff
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 # export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh # source ~/.local/bin/virtualenvwrapper.sh
export WORKON_HOME=/home/nold/.virtualenvs # export WORKON_HOME=/home/nold/.virtualenvs
export PIP_VIRTUALENV_BASE=/home/nold/.virtualenvs # export PIP_VIRTUALENV_BASE=/home/nold/.virtualenvs
fi #fi
# Functions
function json2yaml {
python3 -c 'import sys, yaml, json; print(yaml.dump(json.loads(sys.stdin.read())))'
}
# Aliases # Aliases
alias ls="ls --color=always --time-style=long-iso -F" alias ls="ls --color=always --time-style=long-iso -F"
alias dfh="df -hT -t ext4 -t zfs" alias dfh="df -hT -t ext4 -t zfs -t xfs"
alias lsof='lsof 2>/dev/null | grep' alias lsof='lsof 2>/dev/null | grep'
# Git # Git
@ -106,14 +69,6 @@ alias gpush="git push"
alias gpull="git pull" alias gpull="git pull"
alias gcap="git commit --amend --no-edit && git push -f" alias gcap="git commit --amend --no-edit && git push -f"
# Docker-Compose
alias dcu="docker-compose up -d --remove-orphans"
alias dcd="docker-compose down"
alias dcp="docker-compose pull"
alias dcb="docker-compose build"
alias dcl="docker-compose logs"
alias dclf="docker-compose logs --tail=50 -f"
# k3s / k8s / helm # k3s / k8s / helm
alias k="kubectl" alias k="kubectl"
alias kga="kubectl get all --all-namespaces -o wide" alias kga="kubectl get all --all-namespaces -o wide"

View file

@ -11,7 +11,9 @@ Plugin 'scrooloose/nerdtree'
Plugin 'vim-syntastic/syntastic' Plugin 'vim-syntastic/syntastic'
Plugin 'farmergreg/vim-lastplace.git' Plugin 'farmergreg/vim-lastplace.git'
Plugin 'dense-analysis/ale' Plugin 'dense-analysis/ale'
Plugin 'fatih/vim-go' " Needs Python/Python3 support compiled into vim:
"Plugin 'mvanderkamp/vim-pudb-and-jam'
"Plugin 'fatih/vim-go'
call vundle#end() " required call vundle#end() " required
filetype plugin indent on " required filetype plugin indent on " required
" "
@ -134,6 +136,15 @@ let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠' let g:ale_sign_warning = '⚠'
let g:ale_lint_on_text_changed = 'never' let g:ale_lint_on_text_changed = 'never'
" ------------------------------------ PuDB -------------------------------------------
nnoremap <leader>bc :<C-U>PudbClearAll<CR>
nnoremap <leader>be :<C-U>PudbEdit<CR>
nnoremap <leader>bl :<C-U>PudbList<CR>
nnoremap <leader>bq :<C-U>PudbQfList<CR>
nnoremap <leader>bp :<C-U>PudbToggle<CR>
nnoremap <leader>bu :<C-U>PudbUpdate<CR>
" ------------------------------------ Whitespace Highlighting ------------------------------------------- " ------------------------------------ Whitespace Highlighting -------------------------------------------
autocmd ColorScheme * highlight ExtraWhitespaces ctermbg=red guibg=red autocmd ColorScheme * highlight ExtraWhitespaces ctermbg=red guibg=red
"" Extra Whitespace Highlighting "" Extra Whitespace Highlighting

37
hosts/any/bashrc Normal file
View file

@ -0,0 +1,37 @@
# load powerline
if which powerline-daemon &>/dev/null; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
fi
PYVERSION=$(python3 --version | grep -Eo '[0-9]\.[0-9]')
if [ -f $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ]; then
export VIRTUAL_ENV="$HOME/.venv"
export PATH=$VIRTUAL_ENV/bin:$PATH
# powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
function _update_ps1() {
if git log --oneline -n1 &>/dev/null ; then
REPO=$(git remote -v | sed -r 's/^origin.*\/(.*)\ .*/\1/' | sed 's/.git$//'| head -1)
BRANCH=$(git branch --show-current)
tmux_title "$REPO($BRANCH)"
else
tmux_title "$(hostname)"
fi
PS1=$(powerline-shell $?)
}
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
# source $HOME/.venv/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
elif [ -f ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh ] ; then
#source ~/.local/lib/python${PYVERSION}/site-packages/powerline/bindings/bash/powerline.sh
echo no
elif [ -f /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh ]; then
source /usr/local/lib/python${PYVERSION}/dist-packages/powerline/bindings/bash/powerline.sh
fi

View file

@ -13,8 +13,13 @@ function linkfiles {
fi fi
if [ ! -L ~/.${targetdir}${name} ] ; then if [ ! -L ~/.${targetdir}${name} ] ; then
if [ -f hosts/$(hostname -s)/${name} ] ; then
dotfile="$(pwd)/hosts/$(hostname -s)/${name}"
else
dotfile="$(pwd)/$dir/${name}"
fi
mv -v ~/.${targetdir}${name} ~/.config/homedir-backup mv -v ~/.${targetdir}${name} ~/.config/homedir-backup
ln -s $(pwd)/$dir/${name} ~/.${targetdir}${name} ln -s "$dotfile" ~/.${targetdir}${name}
fi fi
done done
} }

View file

@ -1,11 +1,18 @@
#!/bin/bash #!/bin/bash
GIT_DIRS=(. ~/.vim/bundle ~/.config/nvim) GIT_DIRS=(. ~/.vim/bundle ~/.config/nvim ~/.tmux/plugins/tpm)
for dir in ${GIT_DIRS[@]} ; do for dir in ${GIT_DIRS[@]} ; do
if [ -d "$dir" ] ; then
git -C "$dir" git stash git -C "$dir" git stash
git -C "$dir" pull git -C "$dir" pull
git -C "$dir" git stash pop git -C "$dir" git stash pop
else
echo "Skipping: $dir"
fi
done done
nvim -c "autocmd User PackerComplete quitall" -c "PackerSync" if type nvim &>/dev/null ; then
nvim -c "autocmd User PackerComplete quitall" -c "PackerSync"
fi
vim -c ":PluginUpdate" -c ":q" -c ":q" vim -c ":PluginUpdate" -c ":q" -c ":q"