From 6b3b3a7b54ae8d262c0cb72ce7afa84d89c59f44 Mon Sep 17 00:00:00 2001 From: Christian Ringger <ringger@phys.ethz.ch> Date: Thu, 6 Oct 2022 09:10:07 +0200 Subject: [PATCH] added profile frei --- profile/frei/.gitconfig | 121 +++++++++++++++++++++++++++++++ profile/frei/.gitignore_global | 11 +++ profile/frei/.vimrc | 111 ++++++++++++++++++++++++++++ profile/frei/envrcd.d/00-config | 7 ++ profile/frei/envrcd.d/10-envvars | 29 ++++++++ profile/frei/envrcd.d/20-aliases | 10 +++ profile/frei/envrcd.d/30-prompt | 52 +++++++++++++ 7 files changed, 341 insertions(+) create mode 100644 profile/frei/.gitconfig create mode 100644 profile/frei/.gitignore_global create mode 100644 profile/frei/.vimrc create mode 100644 profile/frei/envrcd.d/00-config create mode 100644 profile/frei/envrcd.d/10-envvars create mode 100644 profile/frei/envrcd.d/20-aliases create mode 100644 profile/frei/envrcd.d/30-prompt diff --git a/profile/frei/.gitconfig b/profile/frei/.gitconfig new file mode 100644 index 0000000..031e945 --- /dev/null +++ b/profile/frei/.gitconfig @@ -0,0 +1,121 @@ +[core] + editor = vim + excludesfile = ~/.gitignore_global + pager = diff-so-fancy | less --tabs=4 -RFX + #pager = delta --dark --plus-color="#004200" --minus-color="#420000" --theme="DarkNeon" --highlight-removed + #pager = delta --dark --plus-color="#004d1e" --minus-color="#5e000a" --theme="DarkNeon" --highlight-removed + +[user] + name = Patrick Frei + email = frei@phys.ethz.ch + signingkey = 120465DFCAFEF89D + +[gitlab] + #url = "https://gitlab.phys.ethz.ch" + #token = "" + +[color] + ui = auto + +[color "diff"] + meta = 240 # metainformation + frag = cyan # line number in hunk header + func = white # function name in hunk header + plain = white # context text + new = green # added lines + old = red # removed lines + commit = yellow # commit headers + whitespace = red reverse # whitespace errors + +[color "diff-highlight"] + oldNormal = red + oldHighlight = red 52 + newNormal = green + newHighlight = green 22 + +[color "status"] + added = green + changed = red + untracked = yellow + +[color "grep"] + filename = yellow + +[color "decorate"] + head = "#00afaf" + branch = "#87d787" + remoteBranch = "#ff5fff" + #tag + #stash + +[diff] + tool = vimdiff + compactionHeuristic = true + colorMoved = default + +[difftool] + prompt = true + +[diff-so-fancy] + # Disable green marker at the beginning of new empty lines + markEmptyLines = false + +[diff "ansible-vault"] + textconv = ansible-vault view + cachetextconv = false + +[merge] + tool = vimdiff + +[interactive] + singlekey = true + +[push] + default = simple + +[pull] + # Only pull if fast-forward is possible. Use `git pull --rebase` or `git pull --no-ff` otherwise. + # ff = only + # Use `git pull --rebase` by default, otherwise use `git fetch; git merge` + rebase = true + +[rebase] + # Automatically stash and pop your uncommitted changes + autoStash = true + +[alias] + co = checkout + st = status + # diff and show based on words instead of lines + diffw = diff --color-words + showw = show --color-words + d = diff + dc = diff --cached + ds = diff --staged + wd = diff --color-words + wdc = diff --cached --color-words + wdiff = diff --color-words + ci = commit -v + cm = commit -m + aa = add -A + undo = reset --hard + ls = ls-files + k = !gitk --all + pra = pull --rebase --autostash + su = submodule update --recursive --remote + ranking = "!git shortlog | egrep -v '^ |^$' | sed -e 's/^\\(.*\\) (\\(.*\\)):/\\2 \\1/' | sort -rn" + addremove = "!git add . && git ls-files --deleted | xargs --no-run-if-empty git rm" + # prettier log (limited to 10 commits) + logg = !git --no-pager log --pretty=tformat:'%Creset (%ar) - %Cred %an: %Cgreen %s %Creset' --graph -n 10 + # prettier log (limited to 10 commits, showing hash) + loggh = !git --no-pager log --pretty=tformat:'%C(yellow) %H %Creset (%ar) - %Cred %an: %Cgreen %s %Creset' --graph -n 10 + # prettier log (showing all commits) + logga = log --pretty=format:'%Creset (%ar) - %Cred %an: %Cgreen %s' --graph + # prettier log (showing all commits, showing hash) + loggha = log --pretty=format:'%C(yellow) %H %Creset (%ar) - %Cred %an: %Cgreen %s' --graph + loggah = log --pretty=format:'%C(yellow) %H %Creset (%ar) - %Cred %an: %Cgreen %s' --graph + adogb = log --all --decorate --oneline --graph + adogv = !"git adogb --format=format:'%C(#d7ff5f)%h%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(#5fd7ff)%an%C(reset) %C(#d7d7ff)(%ar)%C(reset)'" + adogd = !"git adogb --date=format:'%Y-%m-%d %H:%M:%S' --format=format:'%C(#d7ff5f)%h%C(reset)%C(auto)%d%C(reset) %C(normal)%s%C(reset) %C(#5fd7ff)%an%C(reset) %C(#d7d7ff)(%ad)%C(reset)'" + adogj = !"git adogv" + adog = !"git adogv" diff --git a/profile/frei/.gitignore_global b/profile/frei/.gitignore_global new file mode 100644 index 0000000..5e6c2a0 --- /dev/null +++ b/profile/frei/.gitignore_global @@ -0,0 +1,11 @@ +.DS_Store +.*.sw? +*~ +vendor/bundle/* +.ruby-version +.vagrant +.ropeproject +.ipynb_checkpoints/ +__pycache__ +.cache +tags diff --git a/profile/frei/.vimrc b/profile/frei/.vimrc new file mode 100644 index 0000000..1e23217 --- /dev/null +++ b/profile/frei/.vimrc @@ -0,0 +1,111 @@ +" --- general settings ---{{{ +" load debian settings from $VIMRUNTIME/debian.vim +runtime! debian.vim + +" insert custom path to &runtimepath +let &runtimepath=$ENVRCD_VIM_PATH.','.&runtimepath + +syntax on "enable syntax highlighting +set nocompatible "use vim defaults instead of 100% vi compatibility +set encoding=utf8 "default file encoding +set ttyfast "fast terminal +set mouse= "disable mouse mode +filetype plugin on "enable filetype plugins +filetype indent on "automatic indentation according to filetype +"set autoindent "preserve indentation on new line +set backspace=eol,start,indent "allow backspace at end of line etc +set showmatch "show matching parenthesis +"set linebreak "break line at end of a word +"set textwidth=0 "don't break text after a certain length +set tabstop=4 "show existing tab with 4 spaces width +set shiftwidth=4 "when indenting with '>', use 4 spaces width +set softtabstop=4 "use 4 spaces per tab when editing +set expandtab "when pressing tab, insert 4 spaces +set smarttab "use sw at beginning of line, ts otherwise +set incsearch "incremental search +set wrapscan "continue search from top when reaching the end +set ignorecase "search is not case-sensitive +set smartcase "search case-sensitive for uppercase patterns +set hlsearch "search pattern highlighting +set magic "enable extended regexes +set spellsuggest=7 "show 7 suggestions when spellchecking +set nopaste "fix middlemouse button paste (seems default setting) +set history=999 "increase history (default = 20) +set undolevels=999 "more undo (default=100) +set nobackup "toggle keeping ~ backups of files when saving +set swapfile "use swp file while a file is open +set modeline "scan first/last lines of file for vim commands +set modelines=5 "number of lines checked for modelines +set display=lastline "show beginning of broken line at bottom of window instead of displaying @ +"set clipboard=unnamed "make all operations such as yy, dd, p work with the clipboard +set wildmenu "show matches for command-line completion +set wildmode=longest:full,full "define how tab completion proceeds on partial match +set wildignore+=*.o,*.pdf "Let tab completion ignore certain file types +set fillchars=fold:- + +" temporary workaround for jessie's old vim version +if v:version >704 || v:version==704 && has('patch710') + set listchars=eol:¬,tab:>-,trail:~,space:· "define replacement for invisible characters (set invlist) +endif + +" Disable auto-comment after breaking lines with formatoptions +au FileType * setl fo-=c fo-=r fo-=o +"}}} + +" --- functions ---{{{ +" --- map key to toggle opt --- +function MapToggle(key, opt) + let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>" + exec 'nnoremap '.a:key.' '.cmd + exec 'inoremap '.a:key." \<C-O>".cmd +endfunction +command -nargs=+ MapToggle call MapToggle(<f-args>) + +" --- toggle mouse=i on/off --- +function ToggleMouse() + if (&mouse == 'i') || (&mouse == 'a') + set mouse= + else + set mouse=i + endif +endfunc + +" --- Clean trailing spaces --- +function! CleanSpaces() + %s/\s\+$//e +endfunction +"}}} + +" --- keyboard mappings ---{{{ +" --- F key toggles --- +" toggle paste mode (normal/insert) +MapToggle <F2> paste +set pastetoggle=<F2> +" toggle mouse mode (normal/insert) +nnoremap <F3> :call ToggleMouse()<CR> +inoremap <F3> <C-O>:call ToggleMouse()<CR> +" toggle list mode (normal/insert) +MapToggle <F4> list + +" --- normal mappings --- +" toggle paste mode +MapToggle <Leader>p paste +" set mouse modes +nnoremap <Leader>m :set mouse=<CR> +nnoremap <Leader>mi :set mouse=i<CR> +nnoremap <Leader>ma :set mouse=a<CR> +" toggle list of invisible characters +MapToggle <Leader>w list +" remap space to fold/unfold +map <space> za +" remap \s to toggle spellchecking +map <Leader>s :set invspell<CR> +" remap \n to toggle display of line numbers +map <Leader>n :set invnu<CR> +" remap \h to stop hlsearch until next search +map <Leader>h :noh<CR> +"}}} + +" --- vim modeline ---{{{ +" vim: set foldmethod=marker: +"}}} diff --git a/profile/frei/envrcd.d/00-config b/profile/frei/envrcd.d/00-config new file mode 100644 index 0000000..999e2db --- /dev/null +++ b/profile/frei/envrcd.d/00-config @@ -0,0 +1,7 @@ +#!/bin/bash + +# load the defaults +source_profile_if_exists "default" + +# set the path to this profile +export ENVRCD_PROFILE_PATH="${ENVRCD_PATH}/profile/globi" diff --git a/profile/frei/envrcd.d/10-envvars b/profile/frei/envrcd.d/10-envvars new file mode 100644 index 0000000..8283c73 --- /dev/null +++ b/profile/frei/envrcd.d/10-envvars @@ -0,0 +1,29 @@ +#!/bin/bash + +# --- path --- +export PATH=~/bin:${ENVRCD_PROFILE_PATH}/bin:${PATH} + +# --- git --- +if [ "${ENVRCD_USER}" == "globi" ]; then + export GIT_AUTHOR_NAME='Christian Ringger' + export GIT_AUTHOR_EMAIL='ringger@phys.ethz.ch' + export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}" + export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}" +fi + +# --- debian packaging --- +if [ "${ENVRCD_USER}" == "globi" ]; then + export DEBEMAIL="ringger@phys.ethz.ch" + export DEBFULLNAME="Christian Ringger" +fi + +# ignore these commands for history +export HISTIGNORE="" + + +# --- ansible --- +#if [ "${ENVRCD_USER}" == "globi" ] && [ "${USER}" == "chringge" ]; then +# #export ANSIBLE_CONFIG="~/.ansible.cfg" +# export ANSIBLE_STRATEGY_PLUGINS="~/.ansible/mitogen/ansible_mitogen/plugins/strategy" +# export ANSIBLE_STRATEGY="mitogen_linear" +#fi diff --git a/profile/frei/envrcd.d/20-aliases b/profile/frei/envrcd.d/20-aliases new file mode 100644 index 0000000..b90b1d4 --- /dev/null +++ b/profile/frei/envrcd.d/20-aliases @@ -0,0 +1,10 @@ +#!/bin/bash + + +alias kc='eval $(keychain --nogui --eval --agents ssh,gpg --quick id_rsa 99EEA27988963CFE)' +alias kcs='eval $(keychain --nogui --eval --agents ssh --quick id_rsa)' + +unalias git +if [ "${ENVRCD_USER}" != "globi" ] || [ "${HOSTNAME}" != "portus" ] || [ "${USER}" != "chringge" ]; then + alias git="HOME=${ENVRCD_PROFILE_PATH} git" +fi \ No newline at end of file diff --git a/profile/frei/envrcd.d/30-prompt b/profile/frei/envrcd.d/30-prompt new file mode 100644 index 0000000..079664b --- /dev/null +++ b/profile/frei/envrcd.d/30-prompt @@ -0,0 +1,52 @@ +#!/bin/bash + +source_if_exists "${ENVRCD_PATH}/profile/_assets/functions/truncate_pwd" +source_if_exists "${ENVRCD_PATH}/profile/_assets/functions/git_status" + +function envrcd_prompt_default { + # truncate the directory path if it exceeds a certain length. arguments: spacefree pwdminlen + envrcd_function_truncate_pwd + + if [ -z "${ENVRCD_COLOR_OFF}" ]; then + local NO="\[\e[0m\]" # NORMAL FONT + local BO="\[\e[1m\]" # BOLD FONT + local LI="\[\e[2m\]" # LIGHT FONT + local BL="\[\e[30m\]" # BLACK + local RE="\[\e[31m\]" # RED + local GR="\[\e[32m\]" # GREEN + local YE="\[\e[33m\]" # YELLOW + local BL="\[\e[34m\]" # BLUE + local MA="\[\e[35m\]" # MAGENTA + local CY="\[\e[36m\]" # CYAN + local WH="\[\e[37m\]" # WHITE + + if [ -z "${ENVRCD_INVENTORY}" ] || [ "${ENVRCD_INVENTORY}" = "production" ]; then + # set root color to red (production) + local RC=${RE} + else + # set root color to yellow (testing) + local RC=${YE} + fi + fi + + # Check for python virtualenv + local VENV="${VIRTUAL_ENV##*/}" + VENV="${VENV:+(${VENV})}" + + # Check for chroot + local CHROOT="${debian_chroot:+($debian_chroot)}" + + local ENVRCD_PS1_ROOT="${BO}${RC}\h${NO}:${BO}${BL}${TRUNCPWD}${NO}${YE}${VENV}${CHROOT}${NO}# " + local ENVRCD_PS1_USER="${BO}${GR}\u@\h${NO}:${BO}${BL}${TRUNCPWD}${NO}${YE}${VENV}${CHROOT}${NO}$ " + local ENVRCD_PS1_SUDO="${BO}${RC}\u@\h${NO}:${BO}${BL}${TRUNCPWD}${NO}${YE}${VENV}${CHROOT}${NO}$ " + + if [ -z "${ENVRCD_UID_NUM}" ]; then + export PS1="${ENVRCD_PS1_ROOT}" + else + export PS1="${ENVRCD_PS1_USER}" + fi + + export SUDO_PS1="${ENVRCD_PS1_SUDO}" +} + +PROMPT_COMMAND="${ENVRCD_NAME}_prompt_default" -- GitLab