diff --git a/.bashrc b/.bashrc index 74c90b8..22d9a4c 100644 --- a/.bashrc +++ b/.bashrc @@ -1,20 +1,58 @@ +############################################################################# +# ┌────────────────────┐ +# │ BASHRC │ +# └────────────────────┘ # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -#export TERM=xterm-256color -VISUAL=nvim -EDITOR=nvim +export TERM=xterm-256color +VISUAL=vim +EDITOR=vim HISTSIZE=1000 HISTFILESIZE=2000 -parse_git_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -} +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth +############################################################################# +# ┌─────────────────────────────┐ +# │ ALIASES & FUNCTIONS │ +# └─────────────────────────────┘ +# must be sourced first +############################################################################# +source "$HOME/.config/bash/.bash_aliases" +source "$HOME/.config/bash/.bash_functions" + +############################################################################# +# ┌────────────────────┐ +# │ ZSH │ +# └────────────────────┘ +# https://gist.github.com/fworks/af4c896c9de47d827d4caa6fd7154b6b +############################################################################# +# Launch Zsh +#if [ -t 1 ]; then +#exec zsh-5.8 +#fi -# export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ " -#export PS1="\[\033[35m\]\u@\[\033[32m\]\h \[\033[33m\]\w \[\033[91m\]\$(parse_git_branch)\[\033[00m\]$ " -# PROMPT_COMMAND='echo -e "\e[?16;0;200c"' -alias configfiles='git --git-dir="D:\dotfiles\dotfiles" --work-tree="$HOME"' -################################################################################################################ -# export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[0;32m\]$(if git rev-parse --git-dir > /dev/null 2>&1; then echo " - ["; fi)$(git branch 2>/dev/null | grep "^*" )\[\033[0;32m\]$(if git rev-parse --git-dir > /dev/null 2>&1; then echo "]"; fi)\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] ' -# export PS1="\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]\u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)\n\[\033[0;32m\]└─\[\033[0m\]\[\033[0;32m\] \$\[\033[0m\]\[\033[0;32m\] ▶\[\033[0m\] " -############################################################################# -#https://gist.github.com/justintv/168835#gistcomment-2711710 +############################################################################# +# ┌────────────────────┐ +# │ PROMPT │ +# └────────────────────┘ +# ref : https://gist.github.com/justintv/168835#gistcomment-2711710 +############################################################################# +#source_if_exists "$HOME/.config/git/minimal.sh" +source_if_exists "$HOME/.config/git/git-prompt1.sh" +#source_if_exists "$HOME/.config/git/minimal_fast_prompt.sh" +#source_if_exists "$HOME/.config/git/powerlevel10k.sh" +#source_if_exists "$HOME/.config/git/custom.sh" +#source_if_exists "$HOME/.config/git/custom2.sh" + #GIT_PS1_SHOWDIRTYSTATE=true + #GIT_PS1_SHOWSTASHSTATE=true + #GIT_PS1_SHOWUPSTREAM="auto" + #PS1='\t:\[\033[32m\]$(__git_ps1 " (%s)")\[\033[00m\] \W$ ' +############################################################################# +# ┌────────────────────┐ +# │ TMUX │ +# └────────────────────┘ +############################################################################# +# Not so sure : putting it in seperate script makes detaching from tmux +# session, results normal bash prompt +source_if_exists "$HOME/.config/tmux/scripts/startup.sh" diff --git a/.config/bash/.bash_aliases b/.config/bash/.bash_aliases new file mode 100644 index 0000000..14713ce --- /dev/null +++ b/.config/bash/.bash_aliases @@ -0,0 +1,3 @@ +alias configfiles='git --git-dir="D:\dotfiles\dotfiles" --work-tree="$HOME"' +alias wikifiles='git --git-dir="D:\dotfiles\wiki\vimwiki\.git"\ + --work-tree="D:\dotfiles\wiki\vimwiki"' diff --git a/.config/bash/.bash_functions b/.config/bash/.bash_functions new file mode 100644 index 0000000..dc5b0b7 --- /dev/null +++ b/.config/bash/.bash_functions @@ -0,0 +1,15 @@ +source_if_exists(){ + [ -f "$1" ] && source "$1" +} +is_in_git_repo() { + git rev-parse HEAD > /dev/null 2>&1 +} +gb() { + is_in_git_repo && + git branch -a -vv --color=always | grep -v '/HEAD\s' | + fzy | sed 's/^..//' | awk '{print $1}' | + sed 's#^remotes/[^/]*/##' +} + +bind '"\er": redraw-current-line' +bind '"\C-g\C-b": "$(gb)\e\C-e\er"' diff --git a/.config/git/custom.sh b/.config/git/custom.sh new file mode 100644 index 0000000..2a8628c --- /dev/null +++ b/.config/git/custom.sh @@ -0,0 +1,24 @@ +git_stats() { + local STATUS=$(git status -s 2> /dev/null) + local ADDED=$(echo "$STATUS" | grep '??' | wc -l) + local DELETED=$(echo "$STATUS" | grep ' D' | wc -l) + local MODIFIED=$(echo "$STATUS" | grep ' M' | wc -l) + local STATS='' + if [ $ADDED != 0 ]; then + STATS="\e[42m $ADDED " + fi + if [ $DELETED != 0 ]; then + STATS="$STATS\e[101m $DELETED " + fi + if [ $MODIFIED != 0 ]; then + STATS="$STATS\e[30;103m $MODIFIED " + fi + echo -e "\e[0m $STATS\e[0m" +} +__PS1_BEFORE='\n\n' +__PS1_USER='\[\e[97;104m\] \u ' +__PS1_LOCATION='\[\e[30;43m\] \w ' +__PS1_GIT_BRANCH='\[\e[97;45m\] `__git_ps1` ' __PS1_GIT_STATS='`git_stats` ' +__PS1_AFTER='\[\e[0m\]\n\n' + +export PS1="${__PS1_BEFORE}${__PS1_USER}${__PS1_LOCATION}${__PS1_GIT_BRANCH}${__PS1_GIT_STATS}${__PS1_AFTER}" diff --git a/.config/git/custom2.sh b/.config/git/custom2.sh new file mode 100644 index 0000000..3f9fb5e --- /dev/null +++ b/.config/git/custom2.sh @@ -0,0 +1,154 @@ +# ANSI color escape sequences. Useful else, not just the prompt. +C_Red='\e[2;31m'; C_BRed='\e[1;31m'; C_Green='\e[2;32m'; +C_BGreen='\e[1;32m'; C_Yellow='\e[2;33m'; C_BYellow='\e[1;33m'; +C_Grey='\e[2;37m'; C_Reset='\e[0m'; C_BPink='\e[1;35m'; +C_Italic='\e[3m'; C_Blue='\e[2;34m'; C_BBlue='\e[1;34m'; +C_Pink='\e[2;35m'; C_Cyan='\e[2;36m'; C_BCyan='\e[1;36m' + +# Values '1' or '2' are valid, for new and old versions, respectively. +PROMPT_STYLE=2 + +PROMPT_PARSER(){ + if [ $PROMPT_STYLE -eq 1 ]; then + if git rev-parse --is-inside-work-tree &> /dev/null; then + local Status=`git status -s` + if [ -n "$Status" ]; then + local StatusColor=$C_BRed + else + local StatusColor=$C_BGreen + fi + + local Top=`git rev-parse --show-toplevel` + read Line < "$Top"/.git/HEAD + local Branch="$C_Italic$StatusColor${Line##*/}$C_Reset " + fi + + if [ $1 -gt 0 ]; then + local Exit="$C_BRed🗴$C_Reset" + else + local Exit="$C_BGreen🗸$C_Reset" + fi + + local Basename=${PWD##*/} + local Dirname=${PWD%/*} + + if [ "$Dirname/$Basename" == '/' ]; then + CWD="$C_Italic$C_BGreen/$C_Reset" + else + CWD="$C_Grey$Dirname/$C_Italic$Basename$C_Reset" + + # If the CWD is too long, just show basename with '.../' prepended, if + # it's valid to do so. I think ANSI escape sequences are being counted + # in its length, causing it not work as it should, but I like the + # result, none-the-less. + local Slashes=${CWD//[!\/]/} + TempColumns=$((COLUMNS + 20)) # <-- Seems to work around sequences. + if ((${#CWD} > (TempColumns - ${#Branch}) - 2)); then + if [ ${#Slashes} -ge 2 ]; then + CWD="$C_Grey.../$C_Reset$C_BGreen$Basename$C_Reset" + else + CWD=$C_BGreen$Basename$C_Reset + fi + fi + fi + + PS1="$Exit $Branch$CWD\n: " + + unset Line + elif [ $PROMPT_STYLE -eq 2 ]; then + X=$1 + (( $X == 0 )) && X= + + if git rev-parse --is-inside-work-tree &> /dev/null; then + GI=( + '≎' # Clean + '≍' # Uncommitted changes + '≭' # Unstaged changes + '≺' # New file(s) + '⊀' # Removed file(s) + '≔' # Initial commit + '∾' # Branch is ahead + '⮂' # Fix conflicts + '!' # Unknown (ERROR) + '-' # Removed file(s) + ) + + Status=`git status 2> /dev/null` + Top=`git rev-parse --show-toplevel` + + local GitDir=`git rev-parse --git-dir` + if [ "$GitDir" == '.' ] || [ "$GitDir" == "${PWD%%/.git/*}/.git" ]; then + Desc="${C_BRed}∷ ${C_Grey}Looking under the hood..." + else + if [ -n "$Top" ]; then + # Get the current branch name. + IFS='/' read -a A < "$Top/.git/HEAD" + local GB=${A[${#A[@]}-1]} + fi + + # The following is in a very specific order of priority. + if [ -z "$(git rev-parse --branches)" ]; then + Desc="${C_BCyan}${GI[5]} ${C_Grey}Branch '${GB:-?}' awaits its initial commit." + else + while read -ra Line; do + if [ "${Line[0]}${Line[1]}${Line[2]}" == '(fixconflictsand' ]; then + Desc="${C_BCyan}${GI[7]} ${C_Grey}Branch '${GB:-?}' has conflict(s)." + break + elif [ "${Line[0]}${Line[1]}" == 'Untrackedfiles:' ]; then + NFTTL=0 + while read -a Line; do + [ "${Line[0]}" == '??' ] && let NFTTL++ + done <<< "$(git status --short)" + printf -v NFTTL "%'d" $NFTTL + + Desc="${C_BCyan}${GI[3]} ${C_Grey}Branch '${GB:-?}' has $NFTTL new file(s)." + break + elif [ "${Line[0]}" == 'deleted:' ]; then + Desc="${C_BCyan}${GI[9]} ${C_Grey}Branch '${GB:-?}' detects removed file(s)." + break + elif [ "${Line[0]}" == 'modified:' ]; then + readarray Buffer <<< "$(git --no-pager diff --name-only)" + printf -v ModifiedFiles "%'d" ${#Buffer[@]} + Desc="${C_BCyan}${GI[2]} ${C_Grey}Branch '${GB:-?}' has $ModifiedFiles modified file(s)." + break + elif [ "${Line[0]}${Line[1]}${Line[2]}${Line[3]}" == 'Changestobecommitted:' ]; then + Desc="${C_BCyan}${GI[1]} ${C_Grey}Branch '${GB:-?}' has changes to commit." + break + elif [ "${Line[0]}${Line[1]}${Line[3]}" == 'Yourbranchahead' ]; then + printf -v TTLCommits "%'d" "${Line[7]}" + Desc="${C_BCyan}${GI[6]} ${C_Grey}Branch '${GB:-?}' leads by $TTLCommits commit(s)." + break + elif [ "${Line[0]}${Line[1]}${Line[2]}" == 'nothingtocommit,' ]; then + printf -v TTLCommits "%'d" "$(git rev-list --count HEAD)" + + Desc="${C_BCyan}${GI[0]} ${C_Grey}Branch '${GB:-?}' is $TTLCommits commit(s) clean." + break + fi + done <<< "$Status" + fi + fi + fi + + #PS1="\[${C_Reset}\]╭──╼${X}╾──☉ ${Desc}\[${C_Reset}\]\n╰─☉ " + + # 2021-06-13: Temporary block — just experimenting. + if [ -n "$Desc" ]; then + if [ -n "$X" ]; then + PS1="\[${C_Reset}\]${Desc}\[${C_Reset}\]\n\[\e[91m\]${X} \[\e[0m\]\[\e[3;2;37m\]➙ \[\e[0m\] " + else + PS1="\[${C_Reset}\]${Desc}\[${C_Reset}\]\n\[\e[3;2;37m\]➙ \[\e[0m\] " + fi + else + if [ -n "$X" ]; then + PS1="\[${C_Reset}\]\[\e[91m\]${X} \[\e[0m\]\[\e[3;2;37m\]➙ \[\e[0m\] " + else + PS1="\[${C_Reset}\]\[\e[2;37m\]➙ \[\e[0m\] " + fi + fi + + unset Z Line Desc GI Status Top X GB CWD\ + Buffer ModifiedFiles TTLCommits NFTTL + fi +} + +PROMPT_COMMAND='PROMPT_PARSER $?' diff --git a/.config/git/git-prompt1.sh b/.config/git/git-prompt1.sh new file mode 100644 index 0000000..2df4ed1 --- /dev/null +++ b/.config/git/git-prompt1.sh @@ -0,0 +1,29 @@ +#! /bin/sh +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +#export PS1='\n\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]\u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)'$'\n\[\033[0;32m\]└─\[\033[0m\]\[\033[0;32m\] \$\[\033[0m\]\[\033[0;32m\] ▶\[\033[0m\] ' +#┌─╭─ + +#export PS1='\n\[\e[0;32m\]\[\e[0m\]\[\e[0;32m\]╭─ \u\[\e[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\] $(parse_git_branch)'$'\n\[\033[0;32m\]╰─▶\[\033[0m\]\[\033[0;32m\] » $ \[\033[0m\]\[\033[0;32m\] \[\033[0m\] \[$(tput setaf 118)\]' +# +function __git_ps1_fast() { +# ref : https://gist.github.com/urbanautomaton/5206496 + local dir="$PWD" + local git_dir + + until [[ -z "$dir" ]]; do + git_dir="$dir/.git" + if [[ -d "$git_dir" ]]; then + echo " (`git rev-parse --abbrev-ref HEAD`)" + return + fi + + dir="${dir%/*}" + done +} +export GIT_PS1_SHOWDIRTYSTATE= +export GIT_PS1_SHOWUNTRACKEDFILES= +export PS1='\n\[\e[0;36m\]╭─ \u @\h ::\w `__git_ps1_fast`'$'\n''\[\e[0;36m\]╰─▶$ \[\033[0m\]\[\e[0;32m\]' +#export PS1='\u @\h\n╰─▶ » $ \[$(tput setaf 118)\]' diff --git a/.config/git/gitstatus.plugin.sh b/.config/git/gitstatus.plugin.sh new file mode 100644 index 0000000..9a75cb5 --- /dev/null +++ b/.config/git/gitstatus.plugin.sh @@ -0,0 +1,470 @@ +# Bash bindings for gitstatus. + +[[ $- == *i* ]] || return # non-interactive shell + +# Starts gitstatusd in the background. Does nothing and succeeds if gitstatusd +# is already running. +# +# Usage: gitstatus_start [OPTION]... +# +# -t FLOAT Fail the self-check on initialization if not getting a response from +# gitstatusd for this this many seconds. Defaults to 5. +# +# -s INT Report at most this many staged changes; negative value means infinity. +# Defaults to 1. +# +# -u INT Report at most this many unstaged changes; negative value means infinity. +# Defaults to 1. +# +# -c INT Report at most this many conflicted changes; negative value means infinity. +# Defaults to 1. +# +# -d INT Report at most this many untracked files; negative value means infinity. +# Defaults to 1. +# +# -m INT Report -1 unstaged, untracked and conflicted if there are more than this many +# files in the index. Negative value means infinity. Defaults to -1. +# +# -e Count files within untracked directories like `git status --untracked-files`. +# +# -U Unless this option is specified, report zero untracked files for repositories +# with status.showUntrackedFiles = false. +# +# -W Unless this option is specified, report zero untracked files for repositories +# with bash.showUntrackedFiles = false. +# +# -D Unless this option is specified, report zero staged, unstaged and conflicted +# changes for repositories with bash.showDirtyState = false. +# +# -r INT Close git repositories that haven't been used for this many seconds. This is +# meant to release resources such as memory and file descriptors. The next request +# for a repo that's been closed is much slower than for a repo that hasn't been. +# Negative value means infinity. The default is 3600 (one hour). +function gitstatus_start() { + if [[ "$BASH_VERSION" < 4 ]]; then + >&2 printf 'gitstatus_start: need bash version >= 4.0, found %s\n' "$BASH_VERSION" + >&2 printf '\n' + >&2 printf 'To see the version of the current shell, type:\n' + >&2 printf '\n' + >&2 printf ' \033[32mecho\033[0m \033[33m"$BASH_VERSION"\033[0m\n' + >&2 printf '\n' + >&2 printf 'The output of `\033[32mbash\033[0m --version` may be different and is not relevant.\n' + return 1 + fi + + unset OPTIND + local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags + local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1 + local ignore_status_show_untracked_files + while getopts "t:s:u:c:d:m:r:eUWD" opt; do + case "$opt" in + t) timeout=$OPTARG;; + s) max_num_staged=$OPTARG;; + u) max_num_unstaged=$OPTARG;; + c) max_num_conflicted=$OPTARG;; + d) max_num_untracked=$OPTARG;; + m) max_dirty=$OPTARG;; + r) ttl=$OPTARG;; + e) extra_flags+='--recurse-untracked-dirs ';; + U) extra_flags+='--ignore-status-show-untracked-files ';; + W) extra_flags+='--ignore-bash-show-untracked-files ';; + D) extra_flags+='--ignore-bash-show-dirty-state ';; + *) return 1;; + esac + done + + (( OPTIND == $# + 1 )) || { echo "usage: gitstatus_start [OPTION]..." >&2; return 1; } + + [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || return 0 # already started + + if [[ "${BASH_SOURCE[0]}" == */* ]]; then + local gitstatus_plugin_dir="${BASH_SOURCE[0]%/*}" + if [[ "$gitstatus_plugin_dir" != /* ]]; then + gitstatus_plugin_dir="$PWD"/"$gitstatus_plugin_dir" + fi + else + local gitstatus_plugin_dir="$PWD" + fi + + local tmpdir req_fifo resp_fifo culprit + + function gitstatus_start_impl() { + local log_level="${GITSTATUS_LOG_LEVEL:-}" + [[ -n "$log_level" || "${GITSTATUS_ENABLE_LOGGING:-0}" != 1 ]] || log_level=INFO + + local uname_sm + uname_sm="$(command uname -sm)" || return + uname_sm="${uname_sm,,}" + local uname_s="${uname_sm% *}" + local uname_m="${uname_sm#* }" + + if [[ "${GITSTATUS_NUM_THREADS:-0}" -gt 0 ]]; then + local threads="$GITSTATUS_NUM_THREADS" + else + local cpus + if ! command -v sysctl &>/dev/null || [[ "$uname_s" == linux ]] || + ! cpus="$(command sysctl -n hw.ncpu)"; then + if ! command -v getconf &>/dev/null || ! cpus="$(command getconf _NPROCESSORS_ONLN)"; then + cpus=8 + fi + fi + local threads=$((cpus > 16 ? 32 : cpus > 0 ? 2 * cpus : 16)) + fi + + local daemon_args=( + --parent-pid="$$" + --num-threads="$threads" + --max-num-staged="$max_num_staged" + --max-num-unstaged="$max_num_unstaged" + --max-num-conflicted="$max_num_conflicted" + --max-num-untracked="$max_num_untracked" + --dirty-max-index-size="$max_dirty" + --repo-ttl-seconds="$ttl" + $extra_flags) + + tmpdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus.bash.$$.XXXXXXXXXX)" || return + + if [[ -n "$log_level" ]]; then + GITSTATUS_DAEMON_LOG="$tmpdir"/daemon.log + [[ "$log_level" == INFO ]] || daemon_args+=(--log-level="$log_level") + else + GITSTATUS_DAEMON_LOG=/dev/null + fi + + req_fifo="$tmpdir"/req.fifo + resp_fifo="$tmpdir"/resp.fifo + command mkfifo -- "$req_fifo" "$resp_fifo" || return + + { + ( + trap '' INT QUIT TSTP + [[ "$GITSTATUS_DAEMON_LOG" == /dev/null ]] || set -x + builtin cd / + + ( + local fd_in fd_out + exec {fd_in}<"$req_fifo" {fd_out}>>"$resp_fifo" || exit + echo "$BASHPID" >&"$fd_out" + + local _gitstatus_bash_daemon _gitstatus_bash_version _gitstatus_bash_downloaded + + function _gitstatus_set_daemon() { + _gitstatus_bash_daemon="$1" + _gitstatus_bash_version="$2" + _gitstatus_bash_downloaded="$3" + } + + set -- -d "$gitstatus_plugin_dir" -s "$uname_s" -m "$uname_m" \ + -p "printf '.\036' >&$fd_out" -e "$fd_out" -- _gitstatus_set_daemon + [[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || set -- -n "$@" + source "$gitstatus_plugin_dir"/install || return + [[ -n "$_gitstatus_bash_daemon" ]] || return + [[ -n "$_gitstatus_bash_version" ]] || return + [[ "$_gitstatus_bash_downloaded" == [01] ]] || return + + local sig=(TERM ILL PIPE) + + if (( UID == EUID )); then + local home=~ + else + local user + user="$(command id -un)" || return + [[ "$user" =~ ^[a-zA-Z0-9_,.-]+$ ]] || return + eval "local home=~$user" + [[ -n "$home" ]] || return + fi + + if [[ -x "$_gitstatus_bash_daemon" ]]; then + HOME="$home" "$_gitstatus_bash_daemon" \ + -G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" & + local pid=$! + trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]} + wait "$pid" + local ret=$? + trap - ${sig[@]} + case "$ret" in + 0|129|130|131|137|141|143|159) + echo -nE $'}bye\x1f0\x1e' >&"$fd_out" + exit "$ret" + ;; + esac + fi + + (( ! _gitstatus_bash_downloaded )) || return + [[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || return + [[ "$_gitstatus_bash_daemon" == \ + "${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}"/* ]] || return + + set -- -f "$@" + _gitstatus_bash_daemon= + _gitstatus_bash_version= + _gitstatus_bash_downloaded= + source "$gitstatus_plugin_dir"/install || return + [[ -n "$_gitstatus_bash_daemon" ]] || return + [[ -n "$_gitstatus_bash_version" ]] || return + [[ "$_gitstatus_bash_downloaded" == 1 ]] || return + + HOME="$home" "$_gitstatus_bash_daemon" \ + -G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" & + local pid=$! + trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]} + wait "$pid" + trap - ${sig[@]} + echo -nE $'}bye\x1f0\x1e' >&"$fd_out" + ) & disown + ) & disown + } 0"$GITSTATUS_DAEMON_LOG" + + exec {_GITSTATUS_REQ_FD}>>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return + command rm -f -- "$req_fifo" "$resp_fifo" || return + [[ "$GITSTATUS_DAEMON_LOG" != /dev/null ]] || command rmdir -- "$tmpdir" 2>/dev/null + + IFS='' read -r -u $_GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID || return + [[ "$GITSTATUS_DAEMON_PID" == [1-9]* ]] || return + + local reply + echo -nE $'}hello\x1f\x1e' >&$_GITSTATUS_REQ_FD || return + local dl= + while true; do + reply= + if ! IFS='' read -rd $'\x1e' -u $_GITSTATUS_RESP_FD -t "$timeout" reply; then + culprit="$reply" + return 1 + fi + [[ "$reply" == $'}hello\x1f0' ]] && break + if [[ -z "$dl" ]]; then + dl=1 + if [[ -t 2 ]]; then + local spinner=('\b\033[33m-\033[0m' '\b\033[33m\\\033[0m' '\b\033[33m|\033[0m' '\b\033[33m/\033[0m') + >&2 printf '[\033[33mgitstatus\033[0m] fetching \033[32mgitstatusd\033[0m .. ' + else + local spinner=('.') + >&2 printf '[gitstatus] fetching gitstatusd ..' + fi + fi + >&2 printf "${spinner[0]}" + spinner=("${spinner[@]:1}" "${spinner[0]}") + done + + if [[ -n "$dl" ]]; then + if [[ -t 2 ]]; then + >&2 printf '\b[\033[32mok\033[0m]\n' + else + >&2 echo ' [ok]' + fi + fi + + _GITSTATUS_DIRTY_MAX_INDEX_SIZE=$max_dirty + _GITSTATUS_CLIENT_PID="$BASHPID" + } + + if ! gitstatus_start_impl; then + >&2 printf '\n' + >&2 printf '[\033[31mERROR\033[0m]: gitstatus failed to initialize.\n' + if [[ -n "${culprit-}" ]]; then + >&2 printf '\n%s\n' "$culprit" + fi + [[ -z "${req_fifo:-}" ]] || command rm -f "$req_fifo" + [[ -z "${resp_fifo:-}" ]] || command rm -f "$resp_fifo" + unset -f gitstatus_start_impl + gitstatus_stop + return 1 + fi + + export _GITSTATUS_CLIENT_PID _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID + unset -f gitstatus_start_impl +} + +# Stops gitstatusd if it's running. +function gitstatus_stop() { + if [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]]; then + [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true + [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true + [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true + fi + unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID + unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE _GITSTATUS_CLIENT_PID +} + +# Retrives status of a git repository from a directory under its working tree. +# +# Usage: gitstatus_query [OPTION]... +# +# -d STR Directory to query. Defaults to $PWD. Has no effect if GIT_DIR is set. +# -t FLOAT Timeout in seconds. Will block for at most this long. If no results +# are available by then, will return error. +# -p Don't compute anything that requires reading Git index. If this option is used, +# the following parameters will be 0: VCS_STATUS_INDEX_SIZE, +# VCS_STATUS_{NUM,HAS}_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED}. +# +# On success sets VCS_STATUS_RESULT to one of the following values: +# +# norepo-sync The directory doesn't belong to a git repository. +# ok-sync The directory belongs to a git repository. +# +# If VCS_STATUS_RESULT is ok-sync, additional variables are set: +# +# VCS_STATUS_WORKDIR Git repo working directory. Not empty. +# VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or +# empty if there is no HEAD (empty repo). +# VCS_STATUS_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. +# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. +# VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. +# VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". +# VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. +# VCS_STATUS_REMOTE_URL Remote URL. Can be empty. +# VCS_STATUS_ACTION Repository state, A.K.A. action. Can be empty. +# VCS_STATUS_INDEX_SIZE The number of files in the index. +# VCS_STATUS_NUM_STAGED The number of staged changes. +# VCS_STATUS_NUM_CONFLICTED The number of conflicted changes. +# VCS_STATUS_NUM_UNSTAGED The number of unstaged changes. +# VCS_STATUS_NUM_UNTRACKED The number of untracked files. +# VCS_STATUS_HAS_STAGED 1 if there are staged changes, 0 otherwise. +# VCS_STATUS_HAS_CONFLICTED 1 if there are conflicted changes, 0 otherwise. +# VCS_STATUS_HAS_UNSTAGED 1 if there are unstaged changes, 0 if there aren't, -1 if +# unknown. +# VCS_STATUS_NUM_STAGED_NEW The number of staged new files. Note that renamed files +# are reported as deleted plus new. +# VCS_STATUS_NUM_STAGED_DELETED The number of staged deleted files. Note that renamed files +# are reported as deleted plus new. +# VCS_STATUS_NUM_UNSTAGED_DELETED The number of unstaged deleted files. Note that renamed files +# are reported as deleted plus new. +# VCS_STATUS_HAS_UNTRACKED 1 if there are untracked files, 0 if there aren't, -1 if +# unknown. +# VCS_STATUS_COMMITS_AHEAD Number of commits the current branch is ahead of upstream. +# Non-negative integer. +# VCS_STATUS_COMMITS_BEHIND Number of commits the current branch is behind upstream. +# Non-negative integer. +# VCS_STATUS_STASHES Number of stashes. Non-negative integer. +# VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same +# commit as HEAD. +# VCS_STATUS_PUSH_REMOTE_NAME The push remote name, e.g. "upstream" or "origin". +# VCS_STATUS_PUSH_REMOTE_URL Push remote URL. Can be empty. +# VCS_STATUS_PUSH_COMMITS_AHEAD Number of commits the current branch is ahead of push remote. +# Non-negative integer. +# VCS_STATUS_PUSH_COMMITS_BEHIND Number of commits the current branch is behind push remote. +# Non-negative integer. +# VCS_STATUS_NUM_SKIP_WORKTREE The number of files in the index with skip-worktree bit set. +# Non-negative integer. +# VCS_STATUS_NUM_ASSUME_UNCHANGED The number of files in the index with assume-unchanged bit set. +# Non-negative integer. +# +# The point of reporting -1 via VCS_STATUS_HAS_* is to allow the command to skip scanning files in +# large repos. See -m flag of gitstatus_start. +# +# gitstatus_query returns an error if gitstatus_start hasn't been called in the same +# shell or the call had failed. +function gitstatus_query() { + unset OPTIND + local opt dir timeout=() no_diff=0 + while getopts "d:c:t:p" opt "$@"; do + case "$opt" in + d) dir=$OPTARG;; + t) timeout=(-t "$OPTARG");; + p) no_diff=1;; + *) return 1;; + esac + done + (( OPTIND == $# + 1 )) || { echo "usage: gitstatus_query [OPTION]..." >&2; return 1; } + + [[ -n "$GITSTATUS_DAEMON_PID" ]] || return # not started + + local req_id="$RANDOM.$RANDOM.$RANDOM.$RANDOM" + if [[ -z "${GIT_DIR:-}" ]]; then + [[ "$dir" == /* ]] || dir="$(pwd -P)/$dir" || return + elif [[ "$GIT_DIR" == /* ]]; then + dir=:"$GIT_DIR" + else + dir=:"$(pwd -P)/$GIT_DIR" || return + fi + echo -nE "$req_id"$'\x1f'"$dir"$'\x1f'"$no_diff"$'\x1e' >&$_GITSTATUS_REQ_FD || return + + local -a resp + while true; do + IFS=$'\x1f' read -rd $'\x1e' -a resp -u $_GITSTATUS_RESP_FD "${timeout[@]}" || return + [[ "${resp[0]}" == "$req_id" ]] && break + done + + if [[ "${resp[1]}" == 1 ]]; then + VCS_STATUS_RESULT=ok-sync + VCS_STATUS_WORKDIR="${resp[2]}" + VCS_STATUS_COMMIT="${resp[3]}" + VCS_STATUS_LOCAL_BRANCH="${resp[4]}" + VCS_STATUS_REMOTE_BRANCH="${resp[5]}" + VCS_STATUS_REMOTE_NAME="${resp[6]}" + VCS_STATUS_REMOTE_URL="${resp[7]}" + VCS_STATUS_ACTION="${resp[8]}" + VCS_STATUS_INDEX_SIZE="${resp[9]}" + VCS_STATUS_NUM_STAGED="${resp[10]}" + VCS_STATUS_NUM_UNSTAGED="${resp[11]}" + VCS_STATUS_NUM_CONFLICTED="${resp[12]}" + VCS_STATUS_NUM_UNTRACKED="${resp[13]}" + VCS_STATUS_COMMITS_AHEAD="${resp[14]}" + VCS_STATUS_COMMITS_BEHIND="${resp[15]}" + VCS_STATUS_STASHES="${resp[16]}" + VCS_STATUS_TAG="${resp[17]}" + VCS_STATUS_NUM_UNSTAGED_DELETED="${resp[18]}" + VCS_STATUS_NUM_STAGED_NEW="${resp[19]:-0}" + VCS_STATUS_NUM_STAGED_DELETED="${resp[20]:-0}" + VCS_STATUS_PUSH_REMOTE_NAME="${resp[21]:-}" + VCS_STATUS_PUSH_REMOTE_URL="${resp[22]:-}" + VCS_STATUS_PUSH_COMMITS_AHEAD="${resp[23]:-0}" + VCS_STATUS_PUSH_COMMITS_BEHIND="${resp[24]:-0}" + VCS_STATUS_NUM_SKIP_WORKTREE="${resp[25]:-0}" + VCS_STATUS_NUM_ASSUME_UNCHANGED="${resp[26]:-0}" + VCS_STATUS_COMMIT_ENCODING="${resp[27]-}" + VCS_STATUS_COMMIT_SUMMARY="${resp[28]-}" + VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) + if (( _GITSTATUS_DIRTY_MAX_INDEX_SIZE >= 0 && + VCS_STATUS_INDEX_SIZE > _GITSTATUS_DIRTY_MAX_INDEX_SIZE_ )); then + VCS_STATUS_HAS_UNSTAGED=-1 + VCS_STATUS_HAS_CONFLICTED=-1 + VCS_STATUS_HAS_UNTRACKED=-1 + else + VCS_STATUS_HAS_UNSTAGED=$((VCS_STATUS_NUM_UNSTAGED > 0)) + VCS_STATUS_HAS_CONFLICTED=$((VCS_STATUS_NUM_CONFLICTED > 0)) + VCS_STATUS_HAS_UNTRACKED=$((VCS_STATUS_NUM_UNTRACKED > 0)) + fi + else + VCS_STATUS_RESULT=norepo-sync + unset VCS_STATUS_WORKDIR + unset VCS_STATUS_COMMIT + unset VCS_STATUS_LOCAL_BRANCH + unset VCS_STATUS_REMOTE_BRANCH + unset VCS_STATUS_REMOTE_NAME + unset VCS_STATUS_REMOTE_URL + unset VCS_STATUS_ACTION + unset VCS_STATUS_INDEX_SIZE + unset VCS_STATUS_NUM_STAGED + unset VCS_STATUS_NUM_UNSTAGED + unset VCS_STATUS_NUM_CONFLICTED + unset VCS_STATUS_NUM_UNTRACKED + unset VCS_STATUS_HAS_STAGED + unset VCS_STATUS_HAS_UNSTAGED + unset VCS_STATUS_HAS_CONFLICTED + unset VCS_STATUS_HAS_UNTRACKED + unset VCS_STATUS_COMMITS_AHEAD + unset VCS_STATUS_COMMITS_BEHIND + unset VCS_STATUS_STASHES + unset VCS_STATUS_TAG + unset VCS_STATUS_NUM_UNSTAGED_DELETED + unset VCS_STATUS_NUM_STAGED_NEW + unset VCS_STATUS_NUM_STAGED_DELETED + unset VCS_STATUS_PUSH_REMOTE_NAME + unset VCS_STATUS_PUSH_REMOTE_URL + unset VCS_STATUS_PUSH_COMMITS_AHEAD + unset VCS_STATUS_PUSH_COMMITS_BEHIND + unset VCS_STATUS_NUM_SKIP_WORKTREE + unset VCS_STATUS_NUM_ASSUME_UNCHANGED + unset VCS_STATUS_COMMIT_ENCODING + unset VCS_STATUS_COMMIT_SUMMARY + fi +} + +# Usage: gitstatus_check. +# +# Returns 0 if and only if gitstatus_start has succeeded previously. +# If it returns non-zero, gitstatus_query is guaranteed to return non-zero. +function gitstatus_check() { + [[ -n "$GITSTATUS_DAEMON_PID" ]] +} diff --git a/.config/git/minimal.sh b/.config/git/minimal.sh new file mode 100644 index 0000000..fe91c4b --- /dev/null +++ b/.config/git/minimal.sh @@ -0,0 +1,53 @@ +#! /bin/bash +colorize(){ + local temp=$1 + echo "\001${!temp}\002" +} +gitbranch_helper() { + echo -n '(' && git branch 2>/dev/null | grep '^*' | colrm 1 2 | tr -d '\n' && echo -n ')' +} +git_branch() { + gitbranch_helper | sed 's/()//' +} +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} +BOLD=$(tput bold) +RESET=$(tput sgr0) +if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + BLACK0=$(tput setaf 0) + BLACK0_BG=$(tput setab 0) + RED=$(tput setaf 9) + RED_BG=$(tput setab 9) + GRAY=$(tput setaf 8) + GRAY_BG=$(tput setab 8) + GREEN=$(tput setaf 113) + GREEN_BG=$(tput setab 113) + WHITE=$(tput setaf 15) + WHITE_BG=$(tput setab 15) + ORANGE=$(tput setaf 208) + ORANGE_BG=$(tput setab 208) + GOLD=$(tput setaf 178) + GOLD_BG=$(tput setab 178) + GOLD3=$(tput setaf 142) + GOLD3_BG=$(tput setab 142) + YELLOW=$(tput setaf 178 ) + YELLOW_BG=$(tput setab 178 ) + Chartreuse3=$(tput setaf 76) + Chartreuse3_BG=$(tput setab 76) +fi + +export GIT_PS1_SHOWDIRTYSTATE=1 +export GIT_PS1_SHOWCOLORHINTS=1 +export GIT_PS1_SHOWUNTRACKEDFILES= +PS1="\n$(colorize GOLD)\u$(colorize RESET)$(colorize GREEN) @ $(colorize GOLD3)\h :: \w$(colorize GOLD) \$(parse_git_branch) $(colorize RESET)" + +# if [[ ${#VIRTUAL_ENV} -gt 0 ]] +# then + # PS1+=$' \uE235 ' + # PS1+="$(basename ${VIRTUAL_ENV}) " +# fi + +#PS1+="\n$(colorize GREEN)└─\$ ▶ $(colorize RESET) " +PS1="$PS1"$'\n'"$(colorize GREEN)└─\$ ▶ $(colorize RESET) " +export PS1 diff --git a/.config/git/minimal_fast_prompt.sh b/.config/git/minimal_fast_prompt.sh new file mode 100644 index 0000000..09cec6c --- /dev/null +++ b/.config/git/minimal_fast_prompt.sh @@ -0,0 +1,75 @@ +#! /bin/bash +############################################################################### +# Prompt references +# + https://wiki.archlinux.org/title/Bash/Prompt_customization#PROMPT_COMMAND +# + https://web.archive.org/web/20161214154424/https://stackoverflow.com/questions/103857/what-is-your-favorite-bash-prompt + +#rightprompt() +#{ + #printf "%*s" $COLUMNS "right prompt" +#} +# +#export PS1='\[$(tput sc; rightprompt; tput rc)\]left prompt > ' +############################################################################### +colorize(){ + local temp=$1 + echo "\001${!temp}\002" +} +gitbranch_helper() { + echo -n '(' && git branch 2>/dev/null | grep '^*' | colrm 1 2 | tr -d '\n' && echo -n ')' +} +git_branch() { + gitbranch_helper | sed 's/()//' +} +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} + +set_colors(){ +BOLD=$(tput bold) +RESET=$(tput sgr0) +if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then + BLACK0=$(tput setaf 0) + BLACK0_BG=$(tput setab 0) + RED=$(tput setaf 9) + RED_BG=$(tput setab 9) + GRAY=$(tput setaf 8) + GRAY_BG=$(tput setab 8) + GREEN=$(tput setaf 113) + GREEN_BG=$(tput setab 113) + WHITE=$(tput setaf 15) + WHITE_BG=$(tput setab 15) + ORANGE=$(tput setaf 208) + ORANGE_BG=$(tput setab 208) + GOLD=$(tput setaf 178) + GOLD_BG=$(tput setab 178) + GOLD3=$(tput setaf 142) + GOLD3_BG=$(tput setab 142) + YELLOW=$(tput setaf 178 ) + YELLOW_BG=$(tput setab 178 ) + Chartreuse3=$(tput setaf 76) + Chartreuse3_BG=$(tput setab 76) +fi + +} +export GIT_PS1_SHOWDIRTYSTATE=1 +export GIT_PS1_SHOWCOLORHINTS=1 +export GIT_PS1_SHOWUNTRACKEDFILES= + +__prompt_command(){ + +PS1="\n$(colorize GOLD)\u$(colorize RESET)$(colorize GREEN) @ $(colorize GOLD3)\h :: \w$(colorize GOLD) \$(parse_git_branch) $(colorize RESET)" + +# if [[ ${#VIRTUAL_ENV} -gt 0 ]] +# then + # PS1+=$' \uE235 ' + # PS1+="$(basename ${VIRTUAL_ENV}) " +# fi + +#PS1+="\n$(colorize GREEN)└─\$ ▶ $(colorize RESET) " +PS1="$PS1"$'\n'"$(colorize GREEN)└─\$ ▶ $(colorize RESET) " +} +PROMPT_COMMAND=__prompt_command + +set_colors +unset set_colors diff --git a/.config/git/powerlevel10k.sh b/.config/git/powerlevel10k.sh new file mode 100644 index 0000000..67990ee --- /dev/null +++ b/.config/git/powerlevel10k.sh @@ -0,0 +1,104 @@ +# Simple Bash prompt with Git status. + +# Source gitstatus.plugin.sh from $GITSTATUS_DIR or from the same directory +# in which the current script resides if the variable isn't set. +if [[ -n "${GITSTATUS_DIR:-}" ]]; then + source "$GITSTATUS_DIR" || return +elif [[ "${BASH_SOURCE[0]}" == */* ]]; then + source "${BASH_SOURCE[0]%/*}/gitstatus.plugin.sh" || return +else + source gitstatus.plugin.sh || return +fi +exit +# Sets GITSTATUS_PROMPT to reflect the state of the current git repository. +# The value is empty if not in a git repository. Forwards all arguments to +# gitstatus_query. +# +# Example value of GITSTATUS_PROMPT: master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 +# +# master current branch +# ⇣42 local branch is 42 commits behind the remote +# ⇡42 local branch is 42 commits ahead of the remote +# ⇠42 local branch is 42 commits behind the push remote +# ⇢42 local branch is 42 commits ahead of the push remote +# *42 42 stashes +# merge merge in progress +# ~42 42 merge conflicts +# +42 42 staged changes +# !42 42 unstaged changes +# ?42 42 untracked files +function gitstatus_prompt_update() { + GITSTATUS_PROMPT="" + + gitstatus_query "$@" || return 1 # error + [[ "$VCS_STATUS_RESULT" == ok-sync ]] || return 0 # not a git repo + + local reset=$'\001\e[0m\002' # no color + local clean=$'\001\e[38;5;076m\002' # green foreground + local untracked=$'\001\e[38;5;014m\002' # teal foreground + local modified=$'\001\e[38;5;011m\002' # yellow foreground + local conflicted=$'\001\e[38;5;196m\002' # red foreground + + local p + + local where # branch name, tag or commit + if [[ -n "$VCS_STATUS_LOCAL_BRANCH" ]]; then + where="$VCS_STATUS_LOCAL_BRANCH" + elif [[ -n "$VCS_STATUS_TAG" ]]; then + p+="${reset}#" + where="$VCS_STATUS_TAG" + else + p+="${reset}@" + where="${VCS_STATUS_COMMIT:0:8}" + fi + + (( ${#where} > 32 )) && where="${where:0:12}…${where: -12}" # truncate long branch names and tags + p+="${clean}${where}" + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && p+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && p+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n "$VCS_STATUS_ACTION" ]] && p+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && p+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && p+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + (( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${untracked}?${VCS_STATUS_NUM_UNTRACKED}" + + GITSTATUS_PROMPT="${p}${reset}" +} + +# Start gitstatusd in the background. +gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 + +# On every prompt, fetch git status and set GITSTATUS_PROMPT. +PROMPT_COMMAND=gitstatus_prompt_update +PROMPT_DIRTRIM=3 + +# Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded. +shopt -s promptvars + +# Customize prompt. Put $GITSTATUS_PROMPT in it reflect git status. +# +# Example: +# +# user@host ~/projects/skynet master ⇡42 +# $ █ +PS1='\[\033[01;32m\]\u@\h\[\033[00m\] ' # green user@host +PS1+='\[\033[01;34m\]\w\[\033[00m\]' # blue current working directory +PS1+='${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' # git status (requires promptvars option) +PS1+='\n\[\033[01;$((31+!$?))m\]\$\[\033[00m\] ' # green/red (success/error) $/# (normal/root) +PS1+='\[\e]0;\u@\h: \w\a\]' # terminal title: user@host: dir diff --git a/.config/tmux/plugins/tmux-resurrect b/.config/tmux/plugins/tmux-resurrect new file mode 160000 index 0000000..6be2f34 --- /dev/null +++ b/.config/tmux/plugins/tmux-resurrect @@ -0,0 +1 @@ +Subproject commit 6be2f34b5f06c8a6a23dc3dc835e69c132d58a18 diff --git a/.config/tmux/scripts/startup.sh b/.config/tmux/scripts/startup.sh new file mode 100644 index 0000000..90ff8ab --- /dev/null +++ b/.config/tmux/scripts/startup.sh @@ -0,0 +1,14 @@ +#! /bin/sh +if command -v tmux &> /dev/null \ + && [ -n "$PS1" ] \ + && [[ ! "$TERM" =~ screen ]] \ + && [[ ! "$TERM" =~ tmux ]] \ + && [ -z "$TMUX" ]; then + #tmux a -t default || exec tmux new -s default && exit; + #-A : attach to 'default' session if already exists + #-s : session name + # tmux new-session -d -s "default"; + #exec tmux new-session -c "$HOME" -A -s default ; + + tmux new-session -c "$HOME" -A -s default ; +fi diff --git a/.config/tmux/scripts/wiki.sh b/.config/tmux/scripts/wiki.sh new file mode 100644 index 0000000..d3bce8a --- /dev/null +++ b/.config/tmux/scripts/wiki.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Script to open Vimwiki dir in tmux popup + +# exit if tmux not running +# -z checks if len of string is zero +# $TMX variable is automatically set if tmux server is running +[ -z "$TMUX" ] && exit 1 + +SESSION="wiki" + +if [ "$(tmux display-message -p -F "#{session_name}")" = "${SESSION}" ];then + # for -F option see https://man7.org/linux/man-pages/man1/tmux.1.html#FORMATS + #echo "Detaching from ${SESSION}" + tmux detach-client # detach if already in the popup + tmux display-message "detached from session:${SESSION}" + exit 0 # 0 for success +fi + +WINDOW="vimwiki" +SESSION_EXISTS=0 + +WIKI_INDEX_FILE="/d/dotfiles/wiki/vimwiki/index.md" + +open_wiki(){ + echo "Creating wiki session..." +# create a session if doesn't exist in a detached state + tmux new-session -d -s "${SESSION}" \;\ + rename-window -t "${SESSION}:0" "${WINDOW}" \;\ + split-window -t "${SESSION}:${WINDOW}.0" -h \;\ + send-keys -t ${SESSION}:${WINDOW}.0 "vi ${WIKI_INDEX_FILE}" ENTER \;\ + send-keys -t ${SESSION}:${WINDOW}.1 "cd \$(dirname ${WIKI_INDEX_FILE});clear" ENTER \;\ + select-pane -t "${SESSION}:${WINDOW}.0" \; +} + +tmux has-session -t "${SESSION}" &> /dev/null +[ $? == 0 ] && SESSION_EXISTS=1 +[ ${SESSION_EXISTS} == 0 ] && open_wiki +#echo "Attaching to session 'wiki'" +tmux display-message "Attaching to session:${SESSION}" +tmux display-popup -E -h "85%" -w "85%" "tmux attach -t ${SESSION}" + +#tmux display-popup -E -h "80%" -w "80%" "tmux new-session -A -s ${SESSION} \;\ + #rename-window -t 0 \"${WINDOW}\" \;\ + #split-window -h \;\ + #select-pane -t 0 \;\ + #send-keys -t ${SESSION}.0 \"${VI_CMD}\" ENTER" + diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf new file mode 100644 index 0000000..f9b1eda --- /dev/null +++ b/.config/tmux/tmux.conf @@ -0,0 +1,129 @@ +set -s default-terminal 'xterm-256color' + +###################### +# Custom scripts +###################### +bind-key O run-shell -b "bash ~/.config/tmux/scripts/wiki.sh" +bind-key I display-popup -h 85% -w 85% -E "source ~/.profile;vi \"$(find ~/.config | fzy)\"" +bind-key N display-popup -h 85% -w 85% -E "source ~/.profile;vi ~/.config/tmux/tmux.conf" + +# credits : https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ +###################### +# Prefix +###################### +unbind C-b +set-option -g prefix C-a + +###################### +# Splits +###################### +unbind '"' +unbind '%' + +bind | split-window -h +bind - split-window -v + +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +unbind-key l +# by default used for last used window +bind h select-pane -L +bind l select-pane -R +bind k select-pane -U +bind j select-pane -D + +###################### +# Splits border +###################### +#set -g pane-border-style fg=magenta +#set -g pane-active-border-style "bg=color fg=color0" +#set -g pane-border-fg magenta +#set -g pane-active-border-fg green +#set -g pane-active-border-bg default +###################### +# Source config +###################### + +bind R source-file ~/.config/tmux/tmux.conf \; display-message "Reloading tmux config" + +###################### +# Mouse control +###################### +# > tmux 2.1 +set -g mouse on +#set -g mouse-select-window on +#set -g mouse-select-pane on +#set -g mouse-resize-pane on + +###################### +# Windows +###################### +set-option -g allow-rename off +set-window-option -g mode-keys vi +bind L last-window +###################### +# Copy-Paste Mode +###################### +# use v to trigger selection +bind-key -T copy-mode-vi v send-keys -X begin-selection + +# use y to yank current selection +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'tee /dev/clipboard' + +bind-key -T copy-mode-vi r send-keys -X rectangle-toggle +###################### +# Synchronize Panes +###################### +bind-key S set-window-option synchronize-panes \; display-message "Synchronize-panes #{?pane_synchronized,on,off}" + +###################### +# Visual aspects +###################### + +# loud or quiet? +set -g visual-activity off +set -g visual-bell off +set -g visual-silence off +setw -g monitor-activity off +set -g bell-action none + +# modes +setw -g clock-mode-colour colour5 +setw -g mode-style 'fg=colour1 bg=colour18 bold' + +# panes +set -g pane-border-style 'fg=colour235 bg=colour235' +set -g pane-active-border-style 'fg=colour236 bg=colour236' + +###################### +# statusbar +# status-left window-list status-right + +#set-option -g status-style bg=default #make status bar transparent +#set-option -g status-bg default +#set-option -g status-fg color255 +###################### +set -g status-position bottom +set -g status-justify left +set -g status-style 'bg=default fg=colour223 dim' +set -g status-left '#{?client_prefix,#[bg=colour100],}#{?client_prefix,#[fg=colour0],} ❐ #S #{?window_zoomed_flag,🔍,}' +set -g status-right '#{?pane_synchronized, * ,}' +set -g status-right-length 50 +set -g status-left-length 20 + +setw -g window-status-current-style 'fg=colour235 bg=colour172' +setw -g window-status-current-format ' #I:#[bold]#W#[default]#F ' + +setw -g window-status-style 'fg=colour223 bg=colour237' +setw -g window-status-format ' #I:#W#F ' + + +setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold' + +# messages +set -g message-style 'fg=colour254 bg=colour16 bold' + +#run-shell "$HOME/.config/tmux/plugins/tmux-resurrect/resurrect.tmux" diff --git a/.config/utils/pandoc/md2pdf.sh b/.config/utils/pandoc/md2pdf.sh new file mode 100644 index 0000000..5db5a3f --- /dev/null +++ b/.config/utils/pandoc/md2pdf.sh @@ -0,0 +1,43 @@ +#! /bin/sh +if [ "$1" == "-h" ] ; then + echo "Usage: `basename $0` [input_file] [out_dir] [-h]" +fi + +if [ -z "$1" ] + then + echo "No input file specified." + exit 0 +fi + +if [ -z "$2" ];then + out_dir=pdf +else + out_dir=$2 +fi +echo "Creating output dir if not exists : $out_dir" +mkdir -p "$out_dir" +echo "======== Markdown to PDF ================" +filename_full=$(basename -- "$1") +extension="${filename_full##*.}" +filename="${filename_full%.*}" +out_file=$out_dir/${filename}".pdf" +data_dir="$HOME/.config/utils/pandoc" +header_file="$data_dir/templates/head.tex" +user_metadata_file="$(dirname \"$1\")/metadata.yml" +metadata_file="~/.config/utils/templates/metadata.yml" +[ -f "$user_metadata_file" ] && metadata_file="$user_metadata_file" +echo "Source file": $filename_full +echo "Target file": $out_file +echo "Metadata file": $metadata_file + +pandoc -N -s \ + --data-dir="$data_dir"\ + --template=eisvogel.tex \ + -H "$header_file" \ + --listings $1 \ + --toc --toc-depth=4 \ + --metadata-file "$metadata_file" \ + -o $out_file + + +echo "=========================================" diff --git a/.config/utils/pandoc/templates/Document1.pdf b/.config/utils/pandoc/templates/Document1.pdf new file mode 100644 index 0000000..bab1da4 Binary files /dev/null and b/.config/utils/pandoc/templates/Document1.pdf differ diff --git a/.config/utils/pandoc/templates/README.md b/.config/utils/pandoc/templates/README.md new file mode 100644 index 0000000..8d2d69e --- /dev/null +++ b/.config/utils/pandoc/templates/README.md @@ -0,0 +1,9 @@ +# Dev Utils + +## Markdown to Pdf + +Templates/utils for converting markdown file to pdf format using [Pandoc](https://pandoc.org/MANUAL.html) + +## LICENSE : +* [https://github.com/Wandmalfarbe/pandoc-latex-template : LICENSE](https://github.com/Wandmalfarbe/pandoc-latex-template/blob/6baf692c89a5be30a44e4dd0137d8a07bd0a114c/LICENSE) +* Jdhao's [blog](https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/) : [Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)](https://creativecommons.org/licenses/by-nc-nd/4.0/) diff --git a/.config/utils/pandoc/templates/background.pdf b/.config/utils/pandoc/templates/background.pdf new file mode 100644 index 0000000..6c8ed29 Binary files /dev/null and b/.config/utils/pandoc/templates/background.pdf differ diff --git a/.config/utils/pandoc/templates/background1.PNG b/.config/utils/pandoc/templates/background1.PNG new file mode 100644 index 0000000..2efb8d2 Binary files /dev/null and b/.config/utils/pandoc/templates/background1.PNG differ diff --git a/.config/utils/pandoc/templates/background1.pdf b/.config/utils/pandoc/templates/background1.pdf new file mode 100644 index 0000000..c0850b1 Binary files /dev/null and b/.config/utils/pandoc/templates/background1.pdf differ diff --git a/.config/utils/pandoc/templates/background1_edited.png b/.config/utils/pandoc/templates/background1_edited.png new file mode 100644 index 0000000..87c6ec9 Binary files /dev/null and b/.config/utils/pandoc/templates/background1_edited.png differ diff --git a/.config/utils/pandoc/templates/eisvogel.tex b/.config/utils/pandoc/templates/eisvogel.tex new file mode 100644 index 0000000..c7fba87 --- /dev/null +++ b/.config/utils/pandoc/templates/eisvogel.tex @@ -0,0 +1,1064 @@ +%% +% Copyright (c) 2017 - 2021, Pascal Wagler; +% Copyright (c) 2014 - 2021, John MacFarlane +% +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions +% are met: +% +% - Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% +% - Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% +% - Neither the name of John MacFarlane nor the names of other +% contributors may be used to endorse or promote products derived +% from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +% FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +% COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +% INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +% BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +% LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +% ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +%% + +%% +% This is the Eisvogel pandoc LaTeX template. +% +% For usage information and examples visit the official GitHub page: +% https://github.com/Wandmalfarbe/pandoc-latex-template +%% + +% Options for packages loaded elsewhere +\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} +\PassOptionsToPackage{hyphens}{url} +\PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor} +$if(dir)$ +$if(latex-dir-rtl)$ +\PassOptionsToPackage{RTLdocument}{bidi} +$endif$ +$endif$ +$if(CJKmainfont)$ +\PassOptionsToPackage{space}{xeCJK} +$endif$ +% +\documentclass[ +$if(fontsize)$ + $fontsize$, +$endif$ +$if(lang)$ + $babel-lang$, +$endif$ +$if(papersize)$ + $papersize$paper, +$else$ + paper=a4, +$endif$ +$if(beamer)$ + ignorenonframetext, +$if(handout)$ + handout, +$endif$ +$if(aspectratio)$ + aspectratio=$aspectratio$, +$endif$ +$endif$ +$for(classoption)$ + $classoption$$sep$, +$endfor$ + ,captions=tableheading +]{$if(beamer)$$documentclass$$else$$if(book)$scrbook$else$scrartcl$endif$$endif$} +$if(beamer)$ +$if(background-image)$ +\usebackgroundtemplate{% + \includegraphics[width=\paperwidth]{$background-image$}% +} +$endif$ +\usepackage{pgfpages} +\setbeamertemplate{caption}[numbered] +\setbeamertemplate{caption label separator}{: } +\setbeamercolor{caption name}{fg=normal text.fg} +\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ +$for(beameroption)$ +\setbeameroption{$beameroption$} +$endfor$ +% Prevent slide breaks in the middle of a paragraph +\widowpenalties 1 10000 +\raggedbottom +$if(section-titles)$ +\setbeamertemplate{part page}{ + \centering + \begin{beamercolorbox}[sep=16pt,center]{part title} + \usebeamerfont{part title}\insertpart\par + \end{beamercolorbox} +} +\setbeamertemplate{section page}{ + \centering + \begin{beamercolorbox}[sep=12pt,center]{part title} + \usebeamerfont{section title}\insertsection\par + \end{beamercolorbox} +} +\setbeamertemplate{subsection page}{ + \centering + \begin{beamercolorbox}[sep=8pt,center]{part title} + \usebeamerfont{subsection title}\insertsubsection\par + \end{beamercolorbox} +} +\AtBeginPart{ + \frame{\partpage} +} +\AtBeginSection{ + \ifbibliography + \else + \frame{\sectionpage} + \fi +} +\AtBeginSubsection{ + \frame{\subsectionpage} +} +$endif$ +$endif$ +$if(beamerarticle)$ +\usepackage{beamerarticle} % needs to be loaded first +$endif$ +\usepackage{amsmath,amssymb} +$if(fontfamily)$ +\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} +$else$ +\usepackage{lmodern} +$endif$ +$if(linestretch)$ +\usepackage{setspace} +$else$ +\usepackage{setspace} +\setstretch{1.2} +$endif$ +\usepackage{ifxetex,ifluatex} +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} + \usepackage[utf8]{inputenc} + \usepackage{textcomp} % provide euro and other symbols +\else % if luatex or xetex +$if(mathspec)$ + \ifxetex + \usepackage{mathspec} + \else + \usepackage{unicode-math} + \fi +$else$ + \usepackage{unicode-math} +$endif$ + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} +$if(mainfont)$ + \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} +$endif$ +$if(sansfont)$ + \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} +$endif$ +$if(monofont)$ + \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} +$endif$ +$for(fontfamilies)$ + \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} +$endfor$ +$if(mathfont)$ +$if(mathspec)$ + \ifxetex + \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} + \else + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} + \fi +$else$ + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} +$endif$ +$endif$ +$if(CJKmainfont)$ + \ifxetex + \usepackage{xeCJK} + \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} + \fi +$endif$ +$if(luatexjapresetoptions)$ + \ifluatex + \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} + \fi +$endif$ +$if(CJKmainfont)$ + \ifluatex + \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} + \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} + \fi +$endif$ +\fi +$if(beamer)$ +$if(theme)$ +\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} +$endif$ +$if(colortheme)$ +\usecolortheme{$colortheme$} +$endif$ +$if(fonttheme)$ +\usefonttheme{$fonttheme$} +$endif$ +$if(mainfont)$ +\usefonttheme{serif} % use mainfont rather than sansfont for slide text +$endif$ +$if(innertheme)$ +\useinnertheme{$innertheme$} +$endif$ +$if(outertheme)$ +\useoutertheme{$outertheme$} +$endif$ +$endif$ +% Use upquote if available, for straight quotes in verbatim environments +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} +\IfFileExists{microtype.sty}{% use microtype if available + \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} + \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts +}{} +$if(indent)$ +$else$ +\makeatletter +\@ifundefined{KOMAClassName}{% if non-KOMA class + \IfFileExists{parskip.sty}{% + \usepackage{parskip} + }{% else + \setlength{\parindent}{0pt} + \setlength{\parskip}{6pt plus 2pt minus 1pt}} +}{% if KOMA class + \KOMAoptions{parskip=half}} +\makeatother +$endif$ +$if(verbatim-in-note)$ +\usepackage{fancyvrb} +$endif$ +\usepackage{xcolor} +\definecolor{default-linkcolor}{HTML}{A50000} +\definecolor{default-filecolor}{HTML}{A50000} +\definecolor{default-citecolor}{HTML}{4077C0} +\definecolor{default-urlcolor}{HTML}{4077C0} +\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available +$if(footnotes-pretty)$ +% load footmisc in order to customize footnotes (footmisc has to be loaded before hyperref, cf. https://tex.stackexchange.com/a/169124/144087) +\usepackage[hang,flushmargin,bottom,multiple]{footmisc} +\setlength{\footnotemargin}{0.8em} % set space between footnote nr and text +\setlength{\footnotesep}{\baselineskip} % set space between multiple footnotes +\setlength{\skip\footins}{0.3cm} % set space between page content and footnote +\setlength{\footskip}{0.9cm} % set space between footnote and page bottom +$endif$ +\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} +\hypersetup{ +$if(title-meta)$ + pdftitle={$title-meta$}, +$endif$ +$if(author-meta)$ + pdfauthor={$author-meta$}, +$endif$ +$if(lang)$ + pdflang={$lang$}, +$endif$ +$if(subject)$ + pdfsubject={$subject$}, +$endif$ +$if(keywords)$ + pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, +$endif$ +$if(colorlinks)$ + colorlinks=true, + linkcolor=$if(linkcolor)$$linkcolor$$else$default-linkcolor$endif$, + filecolor=$if(filecolor)$$filecolor$$else$default-filecolor$endif$, + citecolor=$if(citecolor)$$citecolor$$else$default-citecolor$endif$, + urlcolor=$if(urlcolor)$$urlcolor$$else$default-urlcolor$endif$, +$else$ + hidelinks, +$endif$ + breaklinks=true, + pdfcreator={LaTeX via pandoc with the Eisvogel template}} +\urlstyle{same} % disable monospaced font for URLs +$if(verbatim-in-note)$ +\VerbatimFootnotes % allow verbatim text in footnotes +$endif$ +$if(geometry)$ +$if(beamer)$ +\geometry{$for(geometry)$$geometry$$sep$,$endfor$} +$else$ +\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} +$endif$ +$else$ +$if(beamer)$ +$else$ +\usepackage[margin=2.5cm,includehead=true,includefoot=true,centering,$for(geometry)$$geometry$$sep$,$endfor$]{geometry} +$endif$ +$endif$ +$if(logo)$ +\usepackage[export]{adjustbox} +\usepackage{graphicx} +$endif$ +$if(beamer)$ +\newif\ifbibliography +$endif$ +$if(listings)$ +\usepackage{listings} +\newcommand{\passthrough}[1]{#1} +\lstset{defaultdialect=[5.3]Lua} +\lstset{defaultdialect=[x86masm]Assembler} +$endif$ +$if(listings-no-page-break)$ +\usepackage{etoolbox} +\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}} +\AfterEndEnvironment{lstlisting}{\end{minipage}\par\addvspace{\topskip}} +$endif$ +$if(lhs)$ +\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} +$endif$ +$if(highlighting-macros)$ +$highlighting-macros$ + +% Workaround/bugfix from jannick0. +% See https://github.com/jgm/pandoc/issues/4302#issuecomment-360669013) +% or https://github.com/Wandmalfarbe/pandoc-latex-template/issues/2 +% +% Redefine the verbatim environment 'Highlighting' to break long lines (with +% the help of fvextra). Redefinition is necessary because it is unlikely that +% pandoc includes fvextra in the default template. +\usepackage{fvextra} +\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,fontsize=$if(code-block-font-size)$$code-block-font-size$$else$\small$endif$,commandchars=\\\{\}} + +$endif$ +$if(tables)$ +\usepackage{longtable,booktabs,array} +$if(multirow)$ +\usepackage{multirow} +$endif$ +\usepackage{calc} % for calculating minipage widths +$if(beamer)$ +\usepackage{caption} +% Make caption package work with longtable +\makeatletter +\def\fnum@table{\tablename~\thetable} +\makeatother +$else$ +% Correct order of tables after \paragraph or \subparagraph +\usepackage{etoolbox} +\makeatletter +\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} +\makeatother +% Allow footnotes in longtable head/foot +\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} +\makesavenoteenv{longtable} +$endif$ +$endif$ +% add backlinks to footnote references, cf. https://tex.stackexchange.com/questions/302266/make-footnote-clickable-both-ways +$if(footnotes-disable-backlinks)$ +$else$ +\usepackage{footnotebackref} +$endif$ +$if(graphics)$ +\usepackage{graphicx} +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} +\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} +\makeatother +% Scale images if necessary, so that they will not overflow the page +% margins by default, and it is still possible to overwrite the defaults +% using explicit options in \includegraphics[width, height, ...]{} +\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} +% Set default figure placement to htbp +\makeatletter +\def\fps@figure{htbp} +\makeatother +$endif$ +$if(links-as-notes)$ +% Make links footnotes instead of hotlinks: +\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} +$endif$ +$if(strikeout)$ +\usepackage[normalem]{ulem} +% Avoid problems with \sout in headers with hyperref +\pdfstringdefDisableCommands{\renewcommand{\sout}{}} +$endif$ +\setlength{\emergencystretch}{3em} % prevent overfull lines +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +$if(numbersections)$ +\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} +$else$ +\setcounter{secnumdepth}{-\maxdimen} % remove section numbering +$endif$ +$if(beamer)$ +$else$ +$if(block-headings)$ +% Make \paragraph and \subparagraph free-standing +\ifx\paragraph\undefined\else + \let\oldparagraph\paragraph + \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\fi +\ifx\subparagraph\undefined\else + \let\oldsubparagraph\subparagraph + \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} +\fi +$endif$ +$endif$ +$if(pagestyle)$ +\pagestyle{$pagestyle$} +$endif$ + +% Make use of float-package and set default placement for figures to H. +% The option H means 'PUT IT HERE' (as opposed to the standard h option which means 'You may put it here if you like'). +\usepackage{float} +\floatplacement{figure}{$if(float-placement-figure)$$float-placement-figure$$else$H$endif$} + +$for(header-includes)$ +$header-includes$ +$endfor$ +$if(lang)$ +\ifxetex + $if(mainfont)$ + $else$ + % See issue https://github.com/reutenauer/polyglossia/issues/127 + \renewcommand*\familydefault{\sfdefault} + $endif$ + % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) + \usepackage{polyglossia} + \setmainlanguage[$for(polyglossia-lang.options)$$polyglossia-lang.options$$sep$,$endfor$]{$polyglossia-lang.name$} +$for(polyglossia-otherlangs)$ + \setotherlanguage[$for(polyglossia-otherlangs.options)$$polyglossia-otherlangs.options$$sep$,$endfor$]{$polyglossia-otherlangs.name$} +$endfor$ +\else + \usepackage[$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} +% get rid of language-specific shorthands (see #6817): +\let\LanguageShortHands\languageshorthands +\def\languageshorthands#1{} +$if(babel-newcommands)$ + $babel-newcommands$ +$endif$ +\fi +$endif$ +\ifluatex + \usepackage{selnolig} % disable illegal ligatures +\fi +$if(dir)$ +\ifxetex + % Load bidi as late as possible as it modifies e.g. graphicx + \usepackage{bidi} +\fi +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \TeXXeTstate=1 + \newcommand{\RL}[1]{\beginR #1\endR} + \newcommand{\LR}[1]{\beginL #1\endL} + \newenvironment{RTL}{\beginR}{\endR} + \newenvironment{LTR}{\beginL}{\endL} +\fi +$endif$ +$if(natbib)$ +\usepackage[$natbiboptions$]{natbib} +\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} +$endif$ +$if(biblatex)$ +\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} +$for(bibliography)$ +\addbibresource{$bibliography$} +$endfor$ +$endif$ +$if(csl-refs)$ +\newlength{\cslhangindent} +\setlength{\cslhangindent}{1.5em} +\newlength{\csllabelwidth} +\setlength{\csllabelwidth}{3em} +\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing + {% don't indent paragraphs + \setlength{\parindent}{0pt} + % turn on hanging indent if param 1 is 1 + \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi + % set entry spacing + \ifnum #2 > 0 + \setlength{\parskip}{#2\baselineskip} + \fi + }% + {} +\usepackage{calc} +\newcommand{\CSLBlock}[1]{#1\hfill\break} +\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} +\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} +\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} +$endif$ +$if(csquotes)$ +\usepackage{csquotes} +$endif$ + +$if(title)$ +\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} +$endif$ +$if(subtitle)$ +$if(beamer)$ +$else$ +\usepackage{etoolbox} +\makeatletter +\providecommand{\subtitle}[1]{% add subtitle to \maketitle + \apptocmd{\@title}{\par {\large #1 \par}}{}{} +} +\makeatother +$endif$ +\subtitle{$subtitle$} +$endif$ +\author{$for(author)$$author$$sep$ \and $endfor$} +\date{$date$} +$if(beamer)$ +$if(institute)$ +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +$if(titlegraphic)$ +\titlegraphic{\includegraphics{$titlegraphic$}} +$endif$ +$if(logo)$ +\logo{\includegraphics{$logo$}} +$endif$ +$endif$ + + + +%% +%% added +%% + +% +% language specification +% +% If no language is specified, use English as the default main document language. +% +$if(lang)$$else$ +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=english]{babel} +$if(babel-newcommands)$ + $babel-newcommands$ +$endif$ +\else + $if(mainfont)$ + $else$ + % Workaround for bug in Polyglossia that breaks `\familydefault` when `\setmainlanguage` is used. + % See https://github.com/Wandmalfarbe/pandoc-latex-template/issues/8 + % See https://github.com/reutenauer/polyglossia/issues/186 + % See https://github.com/reutenauer/polyglossia/issues/127 + \renewcommand*\familydefault{\sfdefault} + $endif$ + % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic) + \usepackage{polyglossia} + \setmainlanguage[]{english} +$for(polyglossia-otherlangs)$ + \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} +$endfor$ +\fi +$endif$ + +$if(page-background)$ +\usepackage[pages=all]{background} +$endif$ + +% +% for the background color of the title page +% +$if(titlepage)$ +\usepackage{pagecolor} +\usepackage{afterpage} +$if(titlepage-background)$ +\usepackage{tikz} +$endif$ +$if(geometry)$ +$else$ +\usepackage[margin=2.5cm,includehead=true,includefoot=true,centering]{geometry} +$endif$ +$endif$ + +% +% break urls +% +\PassOptionsToPackage{hyphens}{url} + +% +% When using babel or polyglossia with biblatex, loading csquotes is recommended +% to ensure that quoted texts are typeset according to the rules of your main language. +% +\usepackage{csquotes} + +% +% captions +% +\definecolor{caption-color}{HTML}{777777} +$if(beamer)$ +$else$ +\usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=$if(caption-justification)$$caption-justification$$else$raggedright$endif$]{caption} +\setcapindent{0em} +$endif$ + +% +% blockquote +% +\definecolor{blockquote-border}{RGB}{221,221,221} +\definecolor{blockquote-text}{RGB}{119,119,119} +\usepackage{mdframed} +\newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote} +\renewenvironment{quote}{\begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}% +\item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}} + +% +% Source Sans Pro as the de­fault font fam­ily +% Source Code Pro for monospace text +% +% 'default' option sets the default +% font family to Source Sans Pro, not \sfdefault. +% +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + $if(fontfamily)$ + $else$ + \usepackage[default]{sourcesanspro} + \usepackage{sourcecodepro} + $endif$ +\else % if not pdftex + $if(mainfont)$ + $else$ + \usepackage[default]{sourcesanspro} + \usepackage{sourcecodepro} + + % XeLaTeX specific adjustments for straight quotes: https://tex.stackexchange.com/a/354887 + % This issue is already fixed (see https://github.com/silkeh/latex-sourcecodepro/pull/5) but the + % fix is still unreleased. + % TODO: Remove this workaround when the new version of sourcecodepro is released on CTAN. + \ifxetex + \makeatletter + \defaultfontfeatures[\ttfamily] + { Numbers = \sourcecodepro@figurestyle, + Scale = \SourceCodePro@scale, + Extension = .otf } + \setmonofont + [ UprightFont = *-\sourcecodepro@regstyle, + ItalicFont = *-\sourcecodepro@regstyle It, + BoldFont = *-\sourcecodepro@boldstyle, + BoldItalicFont = *-\sourcecodepro@boldstyle It ] + {SourceCodePro} + \makeatother + \fi + $endif$ +\fi + +% +% heading color +% +\definecolor{heading-color}{RGB}{40,40,40} +$if(beamer)$ +$else$ +\addtokomafont{section}{\color{heading-color}} +$endif$ +% When using the classes report, scrreprt, book, +% scrbook or memoir, uncomment the following line. +%\addtokomafont{chapter}{\color{heading-color}} + +% +% variables for title, author and date +% +$if(beamer)$ +$else$ +\usepackage{titling} +\title{$title$} +\author{$for(author)$$author$$sep$, $endfor$} +\date{$date$} +$endif$ + +% +% tables +% +$if(tables)$ + +\definecolor{table-row-color}{HTML}{F5F5F5} +\definecolor{table-rule-color}{HTML}{999999} + +%\arrayrulecolor{black!40} +\arrayrulecolor{table-rule-color} % color of \toprule, \midrule, \bottomrule +\setlength\heavyrulewidth{0.3ex} % thickness of \toprule, \bottomrule +\renewcommand{\arraystretch}{1.3} % spacing (padding) + +$if(table-use-row-colors)$ +% TODO: This doesn't work anymore. I don't know why. +% Reset rownum counter so that each table +% starts with the same row colors. +% https://tex.stackexchange.com/questions/170637/restarting-rowcolors +% +% Unfortunately the colored cells extend beyond the edge of the +% table because pandoc uses @-expressions (@{}) like so: +% +% \begin{longtable}[]{@{}ll@{}} +% \end{longtable} +% +% https://en.wikibooks.org/wiki/LaTeX/Tables#.40-expressions +\let\oldlongtable\longtable +\let\endoldlongtable\endlongtable +\renewenvironment{longtable}{ +\rowcolors{3}{}{table-row-color!100} % row color +\oldlongtable} { +\endoldlongtable +\global\rownum=0\relax} +$endif$ +$endif$ + +% +% remove paragraph indention +% +\setlength{\parindent}{0pt} +\setlength{\parskip}{6pt plus 2pt minus 1pt} +\setlength{\emergencystretch}{3em} % prevent overfull lines + +% +% +% Listings +% +% + +$if(listings)$ + +% +% general listing colors +% +\definecolor{listing-background}{HTML}{F7F7F7} +\definecolor{listing-rule}{HTML}{B3B2B3} +\definecolor{listing-numbers}{HTML}{B3B2B3} +\definecolor{listing-text-color}{HTML}{000000} +\definecolor{listing-keyword}{HTML}{435489} +\definecolor{listing-keyword-2}{HTML}{1284CA} % additional keywords +\definecolor{listing-keyword-3}{HTML}{9137CB} % additional keywords +\definecolor{listing-identifier}{HTML}{435489} +\definecolor{listing-string}{HTML}{00999A} +\definecolor{listing-comment}{HTML}{8E8E8E} + +\lstdefinestyle{eisvogel_listing_style}{ + language = java, +$if(listings-disable-line-numbers)$ + xleftmargin = 0.6em, + framexleftmargin = 0.4em, +$else$ + numbers = left, + xleftmargin = 2.7em, + framexleftmargin = 2.5em, +$endif$ + backgroundcolor = \color{listing-background}, + basicstyle = \color{listing-text-color}\linespread{1.0}$if(code-block-font-size)$$code-block-font-size$$else$\small$endif$\ttfamily{}, + breaklines = true, + frame = single, + framesep = 0.19em, + rulecolor = \color{listing-rule}, + frameround = ffff, + tabsize = 4, + numberstyle = \color{listing-numbers}, + aboveskip = 1.0em, + belowskip = 0.1em, + abovecaptionskip = 0em, + belowcaptionskip = 1.0em, + keywordstyle = {\color{listing-keyword}\bfseries}, + keywordstyle = {[2]\color{listing-keyword-2}\bfseries}, + keywordstyle = {[3]\color{listing-keyword-3}\bfseries\itshape}, + sensitive = true, + identifierstyle = \color{listing-identifier}, + commentstyle = \color{listing-comment}, + stringstyle = \color{listing-string}, + showstringspaces = false, + escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments + literate = + {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1 + {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 + {à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 + {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1 + {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 + {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 + {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 + {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 + {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 + {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 + {€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1 + {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 + {…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1 + {”}{{''}}1 +} +\lstset{style=eisvogel_listing_style} + +% +% Java (Java SE 12, 2019-06-22) +% +\lstdefinelanguage{Java}{ + morekeywords={ + % normal keywords (without data types) + abstract,assert,break,case,catch,class,continue,default, + do,else,enum,exports,extends,final,finally,for,if,implements, + import,instanceof,interface,module,native,new,package,private, + protected,public,requires,return,static,strictfp,super,switch, + synchronized,this,throw,throws,transient,try,volatile,while, + % var is an identifier + var + }, + morekeywords={[2] % data types + % primitive data types + boolean,byte,char,double,float,int,long,short, + % String + String, + % primitive wrapper types + Boolean,Byte,Character,Double,Float,Integer,Long,Short + % number types + Number,AtomicInteger,AtomicLong,BigDecimal,BigInteger,DoubleAccumulator,DoubleAdder,LongAccumulator,LongAdder,Short, + % other + Object,Void,void + }, + morekeywords={[3] % literals + % reserved words for literal values + null,true,false, + }, + sensitive, + morecomment = [l]//, + morecomment = [s]{/*}{*/}, + morecomment = [s]{/**}{*/}, + morestring = [b]", + morestring = [b]', +} + +\lstdefinelanguage{XML}{ + morestring = [b]", + moredelim = [s][\bfseries\color{listing-keyword}]{<}{\ }, + moredelim = [s][\bfseries\color{listing-keyword}]{}, + moredelim = [l][\bfseries\color{listing-keyword}]{/>}, + moredelim = [l][\bfseries\color{listing-keyword}]{>}, + morecomment = [s]{}, + morecomment = [s]{}, + commentstyle = \color{listing-comment}, + stringstyle = \color{listing-string}, + identifierstyle = \color{listing-identifier} +} +$endif$ + +% +% header and footer +% +$if(beamer)$ +$else$ +$if(disable-header-and-footer)$ +$else$ +\usepackage[headsepline,footsepline]{scrlayer-scrpage} + +\newpairofpagestyles{eisvogel-header-footer}{ + \clearpairofpagestyles + \ihead[$if(header-right)$$header-right$$else$$date$$endif$]{$if(header-left)$$header-left$$else$$title$$endif$} + \chead[$if(header-center)$$header-center$$else$$endif$]{$if(header-center)$$header-center$$else$$endif$} + \ohead[$if(header-left)$$header-left$$else$$title$$endif$]{$if(header-right)$$header-right$$else$$date$$endif$} + \ifoot[$if(footer-right)$$footer-right$$else$\thepage$endif$]{$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$} + \cfoot[$if(footer-center)$$footer-center$$else$$endif$]{$if(footer-center)$$footer-center$$else$$endif$} + \ofoot[$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$]{$if(footer-right)$$footer-right$$else$\thepage$endif$} + \addtokomafont{pageheadfoot}{\upshape} +} +\pagestyle{eisvogel-header-footer} +$if(page-background)$ +\backgroundsetup{ +scale=1, +color=black, +opacity=$if(page-background-opacity)$$page-background-opacity$$else$0.2$endif$, +angle=0, +contents={% + \includegraphics[width=\paperwidth,height=\paperheight]{$page-background$} + }% +} +$endif$ +$endif$ +$endif$ + +%% +%% end added +%% + +\begin{document} + +%% +%% begin titlepage +%% +$if(beamer)$ +$else$ +$if(titlepage)$ +\begin{titlepage} +$if(titlepage-background)$ +\newgeometry{top=2cm, right=4cm, bottom=3cm, left=4cm} +$else$ +\newgeometry{left=6cm} +$endif$ +$if(titlepage-color)$ +\definecolor{titlepage-color}{HTML}{$titlepage-color$} +\newpagecolor{titlepage-color}\afterpage{\restorepagecolor} +$endif$ +$if(titlepage-background)$ +\tikz[remember picture,overlay] \node[inner sep=0pt] at (current page.center){\includegraphics[width=\paperwidth,height=\paperheight]{$titlepage-background$}}; +$endif$ +\newcommand{\colorRule}[3][black]{\textcolor[HTML]{#1}{\rule{#2}{#3}}} +\begin{flushleft} +\noindent +\\[-1em] +\color[HTML]{$if(titlepage-text-color)$$titlepage-text-color$$else$5F5F5F$endif$} +\makebox[0pt][l]{\colorRule[$if(titlepage-rule-color)$$titlepage-rule-color$$else$435488$endif$]{1.3\textwidth}{$if(titlepage-rule-height)$$titlepage-rule-height$$else$4$endif$pt}} +\par +\noindent + +$if(titlepage-background)$ +% The titlepage with a background image has other text spacing and text size +{ + \setstretch{2} + \vfill + \vskip -8em + \noindent {\huge \textbf{\textsf{$title$}}} + $if(subtitle)$ + \vskip 1em + {\Large \textsf{$subtitle$}} + $endif$ + \vskip 2em + \noindent {\Large \textsf{$for(author)$$author$$sep$, $endfor$} \vskip 0.6em \textsf{$date$}} + \vfill +} +$else$ +{ + \setstretch{1.4} + \vfill + \noindent {\huge \textbf{\textsf{$title$}}} + $if(subtitle)$ + \vskip 1em + {\Large \textsf{$subtitle$}} + $endif$ + \vskip 2em + \noindent {\Large \textsf{$for(author)$$author$$sep$, $endfor$}} + \vfill +} +$endif$ + +$if(logo)$ +\noindent +\includegraphics[width=$if(logo-width)$$logo-width$$else$35mm$endif$, left]{$logo$} +$endif$ + +$if(titlepage-background)$ +$else$ +\textsf{$date$} +$endif$ +\end{flushleft} +\end{titlepage} +\restoregeometry +$endif$ +$endif$ + +%% +%% end titlepage +%% + +$if(has-frontmatter)$ +\frontmatter +$endif$ +$if(title)$ +$if(beamer)$ +\frame{\titlepage} +$endif$ +$if(abstract)$ +\begin{abstract} +$abstract$ +\end{abstract} +$endif$ +$endif$ + +$if(first-chapter)$ +\setcounter{chapter}{$first-chapter$} +\addtocounter{chapter}{-1} +$endif$ + +$for(include-before)$ +$include-before$ + +$endfor$ +$if(toc)$ +$if(toc-title)$ +\renewcommand*\contentsname{$toc-title$} +$endif$ +$if(beamer)$ +\begin{frame}[allowframebreaks] +$if(toc-title)$ + \frametitle{$toc-title$} +$endif$ + \tableofcontents[hideallsubsections] +\end{frame} +$if(toc-own-page)$ +\newpage +$endif$ +$else$ +{ +$if(colorlinks)$ +\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} +$endif$ +\setcounter{tocdepth}{$toc-depth$} +\tableofcontents +$if(toc-own-page)$ +\newpage +$endif$ +} +$endif$ +$endif$ +$if(lot)$ +\listoftables +$endif$ +$if(lof)$ +\listoffigures +$endif$ +$if(linestretch)$ +\setstretch{$linestretch$} +$endif$ +$if(has-frontmatter)$ +\mainmatter +$endif$ +$body$ + +$if(has-frontmatter)$ +\backmatter +$endif$ +$if(natbib)$ +$if(bibliography)$ +$if(biblio-title)$ +$if(has-chapters)$ +\renewcommand\bibname{$biblio-title$} +$else$ +\renewcommand\refname{$biblio-title$} +$endif$ +$endif$ +$if(beamer)$ +\begin{frame}[allowframebreaks]{$biblio-title$} + \bibliographytrue +$endif$ + \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} +$if(beamer)$ +\end{frame} +$endif$ + +$endif$ +$endif$ +$if(biblatex)$ +$if(beamer)$ +\begin{frame}[allowframebreaks]{$biblio-title$} + \bibliographytrue + \printbibliography[heading=none] +\end{frame} +$else$ +\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ +$endif$ + +$endif$ +$for(include-after)$ +$include-after$ + +$endfor$ +\end{document} diff --git a/.config/utils/pandoc/templates/head.tex b/.config/utils/pandoc/templates/head.tex new file mode 100644 index 0000000..bd6626d --- /dev/null +++ b/.config/utils/pandoc/templates/head.tex @@ -0,0 +1,40 @@ +\usepackage{longtable} +\usepackage[T1]{fontenc} +\usepackage{lmodern} +% \usepackage[scaled]{helvet} + +\usepackage{glossaries} + +\makeglossaries +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Block Quotes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{framed} +\usepackage{quoting} + +\definecolor{bgcolor}{HTML}{DADADA} +\colorlet{shadecolor}{bgcolor} +% define a new environment shadedquotation. You can change leftmargin and +% rightmargin as you wish. +\newenvironment{shadedquotation} + {\begin{shaded*} + \quoting[leftmargin=1em, rightmargin=0pt, vskip=0pt, font=itshape] + } + {\endquoting + \end{shaded*} + } + +% +\def\quote{\shadedquotation} +\def\endquote{\endshadedquotation} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Inline Quotes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{fvextra} +\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}} + +\definecolor{bgcolor}{HTML}{E0E0E0} +\let\oldtexttt\texttt +\newcommand{\code}[1]{\begingroup\setlength{\fboxsep}{1pt}\colorbox{bgcolor}{\oldtexttt{\hspace*{2pt}\vphantom{A}#1\hspace*{2pt}}}\endgroup} +\renewcommand{\texttt}[1]{\code{\oldtexttt{#1}}} diff --git a/.config/utils/pandoc/templates/metadata.yml b/.config/utils/pandoc/templates/metadata.yml new file mode 100644 index 0000000..d7e98c5 --- /dev/null +++ b/.config/utils/pandoc/templates/metadata.yml @@ -0,0 +1,15 @@ +title: +date: <date> +keywords: [<tag1>,<tag2>], +lang: "en" +subtitle: "<subtitle>" +fontfamily: "Source Code Pro" +fontsize: 14pt +monofont: "Source Code Pro" +titlepage: true, +titlepage-text-color: "FFFFFF" +titlepage-rule-color: "360049" +titlepage-rule-height: 0 +titlepage-background: "<absolute or relative path>/templates/background.pdf" +page-background-none: "<absolute or relative path>/templates/background1.pdf" +toc-own-page: true diff --git a/.config/utils/pandoc/templates/template.tex b/.config/utils/pandoc/templates/template.tex new file mode 100644 index 0000000..1f6a16a --- /dev/null +++ b/.config/utils/pandoc/templates/template.tex @@ -0,0 +1,556 @@ +\PassOptionsToPackage{unicode=true$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} % options for packages loaded elsewhere +\PassOptionsToPackage{hyphens}{url} +$if(colorlinks)$ +\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} +$endif$ +$if(dir)$ +$if(latex-dir-rtl)$ +\PassOptionsToPackage{RTLdocument}{bidi} +$endif$ +$endif$ +% +\documentclass[ +$if(fontsize)$ + $fontsize$, +$endif$ +$if(lang)$ + $babel-lang$, +$endif$ +$if(papersize)$ + $papersize$paper, +$endif$ +$if(beamer)$ + ignorenonframetext, +$if(handout)$ + handout, +$endif$ +$if(aspectratio)$ + aspectratio=$aspectratio$, +$endif$ +$endif$ +$for(classoption)$ + $classoption$$sep$, +$endfor$ +]{$documentclass$} +$if(beamer)$ +$if(background-image)$ +\usebackgroundtemplate{% + \includegraphics[width=\paperwidth]{$background-image$}% +} +$endif$ + +\usepackage{pgfpages} +\setbeamertemplate{caption}[numbered] +\setbeamertemplate{caption label separator}{: } +\setbeamercolor{caption name}{fg=normal text.fg} +\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ +$for(beameroption)$ +\setbeameroption{$beameroption$} +$endfor$ +% Prevent slide breaks in the middle of a paragraph: +\widowpenalties 1 10000 +\raggedbottom +$if(section-titles)$ +\setbeamertemplate{part page}{ + \centering + \begin{beamercolorbox}[sep=16pt,center]{part title} + \usebeamerfont{part title}\insertpart\par + \end{beamercolorbox} +} +\setbeamertemplate{section page}{ + \centering + \begin{beamercolorbox}[sep=12pt,center]{part title} + \usebeamerfont{section title}\insertsection\par + \end{beamercolorbox} +} +\setbeamertemplate{subsection page}{ + \centering + \begin{beamercolorbox}[sep=8pt,center]{part title} + \usebeamerfont{subsection title}\insertsubsection\par + \end{beamercolorbox} +} +\AtBeginPart{ + \frame{\partpage} +} +\AtBeginSection{ + \ifbibliography + \else + \frame{\sectionpage} + \fi +} +\AtBeginSubsection{ + \frame{\subsectionpage} +} +$endif$ +$endif$ +$if(beamerarticle)$ +\usepackage{beamerarticle} % needs to be loaded first +$endif$ +$if(fontfamily)$ +\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} +$else$ +\usepackage{lmodern} +$endif$ +$if(linestretch)$ +\usepackage{setspace} +\setstretch{$linestretch$} +$endif$ +\usepackage{amssymb,amsmath} +\usepackage{ifxetex,ifluatex} +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} + \usepackage[utf8]{inputenc} + \usepackage{textcomp} % provides euro and other symbols +\else % if luatex or xelatex +$if(mathspec)$ + \ifxetex + \usepackage{mathspec} + \else + \usepackage{unicode-math} + \fi +$else$ + \usepackage{unicode-math} +$endif$ + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} +$if(mainfont)$ + \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} +$endif$ +$if(sansfont)$ + \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} +$endif$ +$if(monofont)$ + \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} +$endif$ +$for(fontfamilies)$ + \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} +$endfor$ +$if(mathfont)$ +$if(mathspec)$ + \ifxetex + \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} + \else + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} + \fi +$else$ + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} +$endif$ +$endif$ +$if(CJKmainfont)$ + \ifxetex + \usepackage{xeCJK} + \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} + \fi +$endif$ +$if(luatexjapresetoptions)$ + \ifluatex + \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} + \fi +$endif$ +$if(CJKmainfont)$ + \ifluatex + \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} + \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} + \fi +$endif$ +\fi +$if(beamer)$ +$if(theme)$ +\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} +$endif$ +$if(colortheme)$ +\usecolortheme{$colortheme$} +$endif$ +$if(fonttheme)$ +\usefonttheme{$fonttheme$} +$endif$ +$if(mainfont)$ +\usefonttheme{serif} % use mainfont rather than sansfont for slide text +$endif$ +$if(innertheme)$ +\useinnertheme{$innertheme$} +$endif$ +$if(outertheme)$ +\useoutertheme{$outertheme$} +$endif$ +$endif$ +%%%%%%%%%%% Fancy header and footer %%%%%%%%%%%%% +%\usepackage[fit]{truncate} +\usepackage{fancyhdr} +\pagestyle{fancy} % % This must be here, because defaults are set and renewcommand for section marks will work. + +\fancyhf{} + %\fancyhead[RO,LE]{\truncate{.95\headwidth}{\leftmark}} +\fancyhead[R]{\nouppercase{\leftmark}} + \fancyfoot[C]{\thepage} + +%\renewcommand{\sectionmark}[1]{\markright{#1}} +%\renewcommand{\chaptermark}[1]{\markleft{#1}} +%\renewcommand{\subsectionmark}[1]{} + +%\fancyhead[L]{\rightmark} +%\fancyhead[R]{\leftmark} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%https://en.wikibooks.org/wiki/LaTeX/Customizing_Page_Headers_and_Footers +%\renewcommand{\chaptermark}[1]{ \markboth{#1}{} } +% +%\renewcommand{\sectionmark}[1]{ \markright{#1} } +% +%\fancyhf{} +%\fancyhead[LE,RO]{\thepage} +%\fancyhead[RE]{\textit{ \nouppercase{\leftmark}} } +%\fancyhead[LO]{\textit{ \nouppercase{\rightmark}} } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%https://latex.org/forum/viewtopic.php?t=31420 + +%\pagestyle{fancy} +%\fancyhead{} +%\fancyhead[RO,LE]{\thepage} +%\fancyhead[CE]{Title of the book} +%\fancyhead[CO]{\chaptermark}<-- \chaptermark has no place here. It is used to *set* the mark(s) for a chapter, not to get it. +%\fancyhead[CO]{\leftmark} +%\fancyfoot{} +%\renewcommand{\chaptermark}[1]{\markboth{#1}{}} +%\renewcommand{\headrulewidth}{0.4pt} +%\renewcommand{\footrulewidth}{0pt} +%\fancypagestyle{plain}{}%<-- only if you really want to have the first page of a chapter showing the same stuff like the chapter's title just below it... + +%%%%%https://tex.stackexchange.com/questions/151784/how-to-display-current-section-title-in-header + +%\fancyhf{} +%\fancyhead[L]{\rightmark} +%\fancyhead[R]{\nouppercase{\leftmark}} +%%\renewcommand{\headrulewidth}{0pt} + + + +%\pagestyle{fancy} % This must be here, because defaults are set and renewcommand for section marks will work. +%\renewcommand{\sectionmark}[1]{\markright{#1}} +%\renewcommand{\subsectionmark}[1]{} +% +%%%https://tex.stackexchange.com/questions/222370/how-can-i-customize-and-use-the-leftmark-and-rightmark-commands-with-custom-fa +%%Fancyhdr Styles +%\fancypagestyle{frontmatter}{% + %\fancyhf{} % clear all fields + %\renewcommand{\headrulewidth}{0pt} + %\lhead{} + %\lfoot{} + %\cfoot{} + %\rfoot{} +%}% +%\fancypagestyle{mainmatter}{% + %\fancyhf{} % clear all fields + %\renewcommand{\headrulewidth}{0pt} + %\lhead{} + %\rhead{} + %\lfoot{} + %\cfoot{} + %\rfoot{} +%}% +%%%%%%%%%%% Fancy header and footer %%%%%%%%%%%%% + +% use upquote if available, for straight quotes in verbatim environments +\IfFileExists{upquote.sty}{\usepackage{upquote}}{} +\IfFileExists{microtype.sty}{% use microtype if available + \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} + \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts +}{} +$if(indent)$ +$else$ +\makeatletter +\@ifundefined{KOMAClassName}{% if non-KOMA class + \IfFileExists{parskip.sty}{% + \usepackage{parskip} + }{% else + \setlength{\parindent}{0pt} + \setlength{\parskip}{6pt plus 2pt minus 1pt}} +}{% if KOMA class + \KOMAoptions{parskip=half}} +\makeatother +$endif$ +$if(verbatim-in-note)$ +\usepackage{fancyvrb} +$endif$ +\usepackage{xcolor} +\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available +\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} +\hypersetup{ +$if(title-meta)$ + pdftitle={$title-meta$}, +$endif$ +$if(author-meta)$ + pdfauthor={$author-meta$}, +$endif$ +$if(keywords)$ + pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, +$endif$ +$if(colorlinks)$ + colorlinks=true, + linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, + filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, + citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, + urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, +$else$ + pdfborder={0 0 0}, +$endif$ + breaklinks=true} +\urlstyle{same} % don't use monospace font for urls +$if(verbatim-in-note)$ +\VerbatimFootnotes % allows verbatim text in footnotes +$endif$ +$if(geometry)$ +\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} +$endif$ +$if(beamer)$ +\newif\ifbibliography +$endif$ +$if(listings)$ +\usepackage{listings} +\newcommand{\passthrough}[1]{#1} +\lstset{defaultdialect=[5.3]Lua} +\lstset{defaultdialect=[x86masm]Assembler} +$endif$ +%%%%%%% Allow deeper lists %%%%%%%%%%%%%%%%%%% + \usepackage{enumitem} + \setlistdepth{20} + \renewlist{itemize}{itemize}{20} + \renewlist{enumerate}{enumerate}{20} + \setlist[itemize]{label= $cdot$ } + \setlist[itemize,1]{label=\textbullet} + \setlist[itemize,2]{label=--} + \setlist[itemize,3]{label=*} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +$if(lhs)$ +\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} +$endif$ +$if(highlighting-macros)$ +$highlighting-macros$ +$endif$ +$if(tables)$ +\usepackage{longtable,booktabs} +$if(beamer)$ +\usepackage{caption} +% These lines are needed to make table captions work with longtable: +\makeatletter +\def\fnum@table{\tablename~\thetable} +\makeatother +$else$ +% Allow footnotes in longtable head/foot +\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} +\makesavenoteenv{longtable} +$endif$ +$endif$ +$if(graphics)$ +\usepackage{graphicx,grffile} +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} +\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} +\makeatother +% Scale images if necessary, so that they will not overflow the page +% margins by default, and it is still possible to overwrite the defaults +% using explicit options in \includegraphics[width, height, ...]{} +\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} +$endif$ +$if(links-as-notes)$ +% Make links footnotes instead of hotlinks: +\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} +$endif$ +$if(strikeout)$ +\usepackage[normalem]{ulem} +% avoid problems with \sout in headers with hyperref: +\pdfstringdefDisableCommands{\renewcommand{\sout}{}} +$endif$ +\setlength{\emergencystretch}{3em} % prevent overfull lines +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +$if(numbersections)$ +\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} +$else$ +\setcounter{secnumdepth}{-2} +$endif$ +$if(beamer)$ +$else$ +$if(subparagraph)$ +$else$ +% Redefines (sub)paragraphs to behave more like sections +\ifx\paragraph\undefined\else + \let\oldparagraph\paragraph + \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\fi +\ifx\subparagraph\undefined\else + \let\oldsubparagraph\subparagraph + \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} +\fi +$endif$ +$endif$ +$if(pagestyle)$ +\pagestyle{$pagestyle$} +$endif$ + +% set default figure placement to htbp +\makeatletter +\def\fps@figure{htbp} +\makeatother + +$for(header-includes)$ +$header-includes$ +$endfor$ +$if(lang)$ +\ifnum 0\ifxetex 1\fi=0 % if pdftex or luatex + \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} +$if(babel-newcommands)$ + $babel-newcommands$ +$endif$ +\else % if xetex + % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic) + \usepackage{polyglossia} + \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} +$for(polyglossia-otherlangs)$ + \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} +$endfor$ +\fi +$endif$ +$if(dir)$ +\ifxetex + % load bidi as late as possible as it modifies e.g. graphicx + \usepackage{bidi} +\fi +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \TeXXeTstate=1 + \newcommand{\RL}[1]{\beginR #1\endR} + \newcommand{\LR}[1]{\beginL #1\endL} + \newenvironment{RTL}{\beginR}{\endR} + \newenvironment{LTR}{\beginL}{\endL} +\fi +$endif$ +$if(natbib)$ +\usepackage[$natbiboptions$]{natbib} +\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} +$endif$ +$if(biblatex)$ +\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} +$for(bibliography)$ +\addbibresource{$bibliography$} +$endfor$ +$endif$ + +$if(title)$ +\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} +$endif$ +$if(subtitle)$ +$if(beamer)$ +$else$ +\usepackage{etoolbox} +\makeatletter +\providecommand{\subtitle}[1]{% add subtitle to \maketitle + \apptocmd{\@title}{\par {\large #1 \par}}{}{} +} +\makeatother +$endif$ +\subtitle{$subtitle$} +$endif$ +$if(author)$ +\author{$for(author)$$author$$sep$ \and $endfor$} +$endif$ +\date{$date$} +$if(beamer)$ +$if(institute)$ +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +$if(titlegraphic)$ +\titlegraphic{\includegraphics{$titlegraphic$}} +$endif$ +$if(logo)$ +\logo{\includegraphics{$logo$}} +$endif$ +$endif$ + +\begin{document} +$if(title)$ +$if(beamer)$ +\frame{\titlepage} +$else$ +\maketitle +$endif$ +$if(abstract)$ +\begin{abstract} +$abstract$ +\end{abstract} +$endif$ +$endif$ + +$for(include-before)$ +$include-before$ + +$endfor$ +$if(toc)$ +$if(toc-title)$ +\renewcommand*\contentsname{$toc-title$} +$endif$ +$if(beamer)$ +\begin{frame} +$if(toc-title)$ + \frametitle{$toc-title$} +$endif$ + %\tableofcontents[hideallsubsections] +\tableofcontents +\end{frame} +$else$ +{ +$if(colorlinks)$ +\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} +$endif$ +\setcounter{tocdepth}{$toc-depth$} +%\setcounter{tocdepth}{4} +\setcounter{secnumdepth}{3} +\tableofcontents +%\setlistdepth{9}} +$endif$ +$endif$ +$if(lot)$ +\listoftables +$endif$ +$if(lof)$ +\listoffigures +$endif$ +$body$ + +$if(natbib)$ +$if(bibliography)$ +$if(biblio-title)$ +$if(book-class)$ +\renewcommand\bibname{$biblio-title$} +$else$ +\renewcommand\refname{$biblio-title$} +$endif$ +$endif$ +$if(beamer)$ +\begin{frame}[allowframebreaks]{$biblio-title$} + \bibliographytrue +$endif$ + \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} +$if(beamer)$ +\end{frame} +$endif$ + +$endif$ +$endif$ +$if(biblatex)$ +$if(beamer)$ +\begin{frame}[allowframebreaks]{$biblio-title$} + \bibliographytrue + \printbibliography[heading=none] +\end{frame} +$else$ +\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ +$endif$ + +$endif$ +$for(include-after)$ +$include-after$ + +$endfor$ +\end{document} diff --git a/.config/vim/ftplugin/bash.vim b/.config/vim/ftplugin/bash.vim new file mode 100644 index 0000000..a2dde0e --- /dev/null +++ b/.config/vim/ftplugin/bash.vim @@ -0,0 +1,5 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 +au BufRead,BufNewFile *.bash_* set filetype=bash diff --git a/.config/vim/ftplugin/tmux.vim b/.config/vim/ftplugin/tmux.vim new file mode 100644 index 0000000..1b803ee --- /dev/null +++ b/.config/vim/ftplugin/tmux.vim @@ -0,0 +1,5 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 +au BufRead,BufNewFile *.tmux.conf set filetype=tmux diff --git a/.config/vim/general/augroups.vim b/.config/vim/general/augroups.vim new file mode 100644 index 0000000..0fc756c --- /dev/null +++ b/.config/vim/general/augroups.vim @@ -0,0 +1,59 @@ +""" +"Auto Commands +""" +" trim trailing whitespace ----- {{{ +"https://vi.stackexchange.com/a/456 +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun + +augroup TRIM_WHITESPACE + autocmd! + autocmd BufWritePre * if !&binary && &ft !=# 'mail' + \| call TrimWhitespace() + \| endif +augroup END +" }}} + +" persistent folding state --- {{{ +augroup REMEMBER_FOLDS + autocmd! + autocmd BufWinLeave *.* mkview + autocmd BufWinEnter *.* silent! loadview +augroup END +" --- }}} + +" Cursor management --- {{{ +"https://github.com/microsoft/terminal/issues/4335 +" +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +" +augroup CURSOR_MANAGEMENT + autocmd! + +" powershell requires different format for escape codes +" see : +" (i) https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-5.1#example-6--use-vimodechangehandler-to-display-vi-mode-changes +" (ii) https://github.com/microsoft/terminal/issues/1604 +if has('win32') + "https://github.com/neovim/neovim/issues/4867#issuecomment-291249173" + autocmd VimEnter * silent !echo -ne "\1\e[6 q\2" + autocmd VimLeave * set guicursor=a:ver25 + +else + autocmd VimEnter * silent !echo -ne "\e[2 q" + autocmd VimLeave * silent !echo -ne "\e[6 q" +" autocmd VimLeave * let &t_me="\<Esc>]50;CursorShape=1\x7" +" autocmd VimLeave * let &t_SI.="\<Esc>[6 q" +endif +augroup END +" }} diff --git a/.config/vim/general/colorscheme_settings.vim b/.config/vim/general/colorscheme_settings.vim new file mode 100644 index 0000000..7f45291 --- /dev/null +++ b/.config/vim/general/colorscheme_settings.vim @@ -0,0 +1,31 @@ +let g:colorscheme='default' +" gruvbox ----- {{{ +if (has("termguicolors")) + set termguicolors +endif +set background=dark +set t_Co=256 +" colorscheme gruvbox +" au Colorscheme gruvbox :hi Keyword gui=italic cterm=italic +"https://github.com/sainnhe/gruvbox-material/blob/master/doc/gruvbox-material.txt +"soft,medium,hard +"let g:gruvbox_material_background = 'medium' +let g:gruvbox_material_transparent_background = 1 +let g:gruvbox_material_enable_bold = 1 +let g:gruvbox_material_enable_italic = 1 +"let g:gruvbox_material_statusline_style = 'original' +let g:gruvbox_material_diagnostic_virtual_text = 'colored' +let g:gruvbox_material_better_performance = 1 +"configuration must be dont before applying colorscheme +" +"if &filetype!='gitcommit' +let g:gruvbox_contrast_dark="hard" +let g:gruvbox_bold=1 +let g:gruvbox_italic=1 + +colorscheme gruvbox +"endif + +" }}} +" + diff --git a/.config/vim/general/cursor.vim b/.config/vim/general/cursor.vim new file mode 100644 index 0000000..4640c59 --- /dev/null +++ b/.config/vim/general/cursor.vim @@ -0,0 +1,23 @@ +" also see augroups.vim +" cursor ----- {{{ +" Cursor in terminal +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +if &term =~ '^xterm' + " normal mode || + " .= means shorthand for appending : see help .= + let &t_EI .= "\<Esc>[1 q" + " replace mode _ + let &t_SR .= "\e[4 q" + " insert mode | + let &t_SI .= "\<Esc>[6 q" +endif +" +" }}} + diff --git a/.config/vim/general/general.vim b/.config/vim/general/general.vim new file mode 100644 index 0000000..5707542 --- /dev/null +++ b/.config/vim/general/general.vim @@ -0,0 +1,115 @@ +"General Settings +set nocompatible +set belloff=all +"set novisualbell +set mouse=a +" CLIPBOARD ----- {{{ +"vim clipboard and system clipboard same now +set clipboard^=unnamedplus +" }}} + + +" EDITOR ----- {{{ +syntax on +set conceallevel=0 + +"wrap backspace +set backspace=indent,eol,start +"https://stackoverflow.com/a/53872985/12988588 +"dont save character deleted using `x` +"send it to The blackhole-register +nnoremap x "_x +"set autochdir +" filetype on +" filetype plugin on +" filetype indent on +set ignorecase +set smartcase +" use 4 spaces for tabs +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set expandtab +set smartindent +set number +set scrolloff=8 +set showtabline=2 +set lazyredraw +set scrolloff=999 +set colorcolumn=80 +set cursorline +" Show white spaces https://gist.github.com/jdavid82/d40f40e6f124aad6223eba0ff0c7ad65#file-vimrc-L37-L39 +"set listchars=tab:>·,trail:~,extends:>,precedes:<,space:· +"set list +"}}} + +" SEARCHING ----- {{{ +set incsearch "on by default" +set nohlsearch +" clear last used search pattern:http://vimdoc.sourceforge.net/htmldoc/pattern.html#last-pattern +" +let @/="" +" }}} + +" FOLDING ----- {{{ +" use pattern {{{ #code# }}} to detect fold region +" use zm to fold all markers and zr to release all folds with markers +set foldmethod=marker +" }}} + +" BUFFERS ----- {{{ +" remember foldings is nvim/general/augroups.vim +" }}} + +" SPLITS ----- {{{ +set splitbelow +set splitright +nnoremap <C-J> <C-W><C-J> +nnoremap <C-K> <C-W><C-K> +nnoremap <C-L> <C-W><C-L> +nnoremap <C-H> <C-W><C-H> + +"}}} + + +" Nice menu when typing `:find *.py` +set wildmode=longest,list,full +set wildmenu +" Ignore files +set wildignore+=*.pyc +set wildignore+=*_build/* +set wildignore+=**/coverage/* +set wildignore+=**/node_modules/* +set wildignore+=**/android/* +set wildignore+=**/ios/* +set wildignore+=**/.git/* +" }}} + +" coc needs it----- {{{ +" Set internal encoding of vim, not needed on neovim, since coc.nvim using some +" unicode characters in the file autoload/float.vim +set encoding=utf-8 + +" TextEdit might fail if hidden is not set. +set hidden + +" Some servers have issues with backup files, see #649. +set nobackup +set nowritebackup + +" Give more space for displaying messages. +set cmdheight=2 + +" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +" delays and poor user experience. +set updatetime=300 +set ttimeoutlen=0 +" Don't pass messages to |ins-completion-menu|. +set shortmess+=c +" }}} +" " show tabline +" set showtabline=2 +" if has('gui_running') + " set guioptions-=e +" endif + diff --git a/.config/vim/general/git.vim b/.config/vim/general/git.vim new file mode 100644 index 0000000..21933b4 --- /dev/null +++ b/.config/vim/general/git.vim @@ -0,0 +1,29 @@ +function Set_git_settings() + "colorscheme gruvbox + "below line is important : gruvbox-material doesn't work + let g:lightline.colorscheme='gruvbox' +endfunction + +if &diff + set nornu + "https://stackoverflow.com/questions/2019281/load-different-colorscheme-when-using-vimdiff + highlight! DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + highlight! DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + highlight! DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + highlight! DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red + " Fix the difficult-to-read default setting for diff text highlighting. The + " bang (!) is required since we are overwriting the DiffText setting. The highlighting + " for \"Todo" also looks nice (yellow) if you don't like the \"MatchParen" colors. + highlight! link DiffText MatchParen + "no transperant bg : set to default colors from gruvbox" + "found out using :hi Normal + highlight! Normal ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#282828 + :call Set_git_settings() +endif + + +augroup GITCOMMIT_SETTINGS + "https://vi.stackexchange.com/questions/4343/can-i-detect-whether-current-vim-instance-is-launched-by-git + autocmd! + autocmd FileType gitcommit,gitrebase silent :call Set_git_settings() +augroup END diff --git a/.config/vim/general/keybindings.vim b/.config/vim/general/keybindings.vim new file mode 100644 index 0000000..df0ef29 --- /dev/null +++ b/.config/vim/general/keybindings.vim @@ -0,0 +1,53 @@ +" MODES ----- {{{ +"use jk in insert mode to switch to normal mode +inoremap jk <ESC> +" }}} + +" yanking ----- {{{ +"to match the behaviour of 'C' and 'D' +nnoremap Y y$ +"replace with yanked word +"https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text +nnoremap S "_diwP +vnoremap S "_d"0P +"highlight the yanked area for an extened period +augroup highlight_yank + autocmd! + au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=300} +augroup END +" }}} + +" searching : the primeagen : top 5 keybindings ----- {{{ +"put the cursor at screen center while going to next search result +nnoremap n nzz +nnoremap N Nzz + +" }}} +" +" breakpoints ----- {{{ +"puts the next line at the end of current line : mz = create a mark called z , do J, `z = goto mark z +nnoremap J mzJ`z +"undo breakpoints +inoremap . .<C-g>u +inoremap , ,<C-g>u +inoremap ! !<C-g>u +inoremap ? ?<C-g>u +" }}} +" +" moving lines with ALT key ----- {{{ +"https://vim.fandom.com/wiki/Moving_lines_up_or_down +nnoremap <A-j> :m .+1<CR>== +nnoremap <A-k> :m .-2<CR>== +inoremap <A-j> <Esc>:m .+1<CR>==gi +inoremap <A-k> <Esc>:m .-2<CR>==gi +vnoremap <A-j> :m '>+1<CR>gv=gv +vnoremap <A-k> :m '<-2<CR>gv=gv +" }}} + +"htmlhttps://stackoverflow.com/questions/130734/how-can-one-close-html-tags-in-vim-quickly +"inoremap ><Space> ><Esc>F<lyt>o</<C-r>"><Esc>O<Space> + +" better indentation ----- {{{ +vnoremap > >gv +vnoremap < <gv +" }}} diff --git a/.config/vim/general/leader.vim b/.config/vim/general/leader.vim new file mode 100644 index 0000000..c2510dc --- /dev/null +++ b/.config/vim/general/leader.vim @@ -0,0 +1,24 @@ +" Mappings with leader key +" source vim file +nmap <leader>vs :source $MYVIMRC<CR> +nmap <leader>vo :e $MYVIMRC<CR> +" nmap <leader>so :vsplit <bar> :e $LOCALAPPDATA/nvim/init.vim<CR> +nnoremap <leader>n :bnext<CR> +nnoremap <leader>p :bprev<CR> +nnoremap <leader>b :buffers<CR> + +" splits ----- {{{ +"nnoremap <leader>w <C-W>w "removed to support vimwiki +nnoremap <leader>h <C-W>h +nnoremap <leader>l <C-W>l +nnoremap <leader>j <C-W>j +nnoremap <leader>k <C-W>k +" +nnoremap <silent> <Leader>r= <C-w>=<CR> +nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR> +nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR> +nnoremap <silent> <Leader>0 :exe "vertical resize " . (winwidth(0) * 3/2)<CR> +nnoremap <silent> <Leader>9 :exe "vertical resize " . (winwidth(0) * 2/3)<CR> +" }}} + +"nmap <leader>ws : diff --git a/.config/vim/vimrc b/.config/vim/vimrc new file mode 100644 index 0000000..13fa5ec --- /dev/null +++ b/.config/vim/vimrc @@ -0,0 +1,65 @@ +" ┌───────────────────────────┐ +" │ VIMRC │ +" └───────────────────────────┘ +" +" Resources +" changing vimrc folder : +" [stackexchange]: https://vi.stackexchange.com/questions/11879/how-can-put-vimrc-and-viminfo-into-vim-directory +" +" +let g:BASE_DIR="$HOME/.config/vim" +let rtp=&runtimepath +exec "set runtimepath=".g:BASE_DIR +let &runtimepath.="," + \.rtp."," + \.g:BASE_DIR."/after" + +set viminfo+=n.g:BASE_DIR.'/viminfo' + +exec "set directory=" + \.g:BASE_DIR."/swap//" + \.".," + \."$HOME/tmp," + \."/var/tmp," + \."/tmp" +exec "set backupdir=" + \.g:BASE_DIR."/backup//" + \.".," + \."$HOME/tmp," + \."$HOME/" +exec "set undodir=" + \.g:BASE_DIR."/undo//" + \."." +let g:netrw_home=g:BASE_DIR + +let mapleader="\<Space>" +exec "source ".g:BASE_DIR."/general/augroups.vim" +exec "source ".g:BASE_DIR."/general/general.vim" +exec "source ".g:BASE_DIR."/general/cursor.vim" +exec "source ".g:BASE_DIR."/general/keybindings.vim" +exec "source ".g:BASE_DIR."/general/leader.vim" + +highlight Comment cterm=italic gui=italic + +highlight ColorColumn ctermbg=235 guibg=lightgrey cterm=NONE gui=NONE +highlight CursorLine ctermbg=236 guibg=lightgrey cterm=NONE gui=NONE +highlight CursorLineNr ctermbg=236 guibg=lightgrey cterm=NONE gui=NONE + +highlight TabLineSel ctermbg=77 ctermfg=0 cterm=BOLD +highlight TabLineFill ctermbg=0 ctermfg=235 cterm=BOLD +highlight TabLineSel ctermbg=77 ctermfg=0 +highlight TabLine ctermbg=0 ctermfg=77 + +highlight visual ctermbg=238 guibg=#000000 gui=NONE + + +hi MatchParen ctermbg=0 guibg=lightblue +"hi! ColorColumn ctermbg=236 guibg=grey cterm=NONE +"hi! CursorLine ctermbg=236 guibg=grey cterm=NONE +"hi! CursorLineNr ctermbg=237 guibg=grey cterm=NONE +hi! LineNr ctermbg=232 guibg=grey cterm=NONE +"hi! NonText guifg=bg ctermfg=NONE +"hi! Visual ctermbg=237 guibg=#dddddd cterm=NONE +" +let g:netrw_cursor=0 " to use userdefined CursorLine and ColorColumn +let g:netrw_winsize=30 diff --git a/.config/vim/vimrc_bk b/.config/vim/vimrc_bk new file mode 100644 index 0000000..3998007 --- /dev/null +++ b/.config/vim/vimrc_bk @@ -0,0 +1,11 @@ +let mapleader="\<Space>" +source $HOME/.vim/general/augroups.vim +source $HOME/.vim/general/general.vim +source $HOME/.vim/general/cursor.vim +source $HOME/.vim/general/keybindings.vim +source $HOME/.vim/general/leader.vim + +hi CursorLine ctermbg=237 guibg=grey cterm=NONE +hi CursorLineNr ctermbg=237 guibg=grey cterm=NONE +hi! NonText guifg=bg ctermfg=NONE + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0038ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# ┌─────────────────────────────┐ +# │ │ +# │ Dotfiles GitIgnore │ +# │ │ +# └─────────────────────────────┘ +# ref : https://github.com/bitprophet/dotfiles/blob/main/.gitignore + + +# Ignore everything by default. +* + +!.config + +!.config/vim +!.config/vim/** + +!.config/tmux +!.config/tmux/** + +!.config/git +!.config/git/** + +!.config/utils +!.config/utils/** + +!.config/bash +!.config/bash/** + +#tmux plugins +.config/tmux/plugins + +# Bash stuff (profile just sources bashrc, since it's the only thing sourced +# when a shell is a login shell). +!.bash* +.*.swp +.bash_history +.bash_local +.bash_logout +!.profile + + +# Git aliases, identification info +#!.gitconfig +# The gitignore of this repository itself (!) +!.gitignore +# My global Git excludes file (acts as a global .gitignore) +#!.gitexcludes + + +# vim +.netrw* +view/ +.config/vim/swap + +# nvim +!AppData/Local/nvim +!AppData/Local/nvim/** + diff --git a/AppData/Local/nvim/general/augroups.vim b/AppData/Local/nvim/general/augroups.vim index ad09b52..3e5b81c 100644 --- a/AppData/Local/nvim/general/augroups.vim +++ b/AppData/Local/nvim/general/augroups.vim @@ -57,3 +57,15 @@ else endif augroup END " }} +" +"autocmd filetype netrw call Netrw_mappings() + +function! Netrw_mappings() + noremap <buffer>% :call CreateInPreview()<cr> +endfunction + +function! CreateInPreview() + let l:filename = input("please enter filename: ") + execute 'silent !touch ' . b:netrw_curdir.'/'.l:filename + redraw! +endf diff --git a/AppData/Local/nvim/general/colorscheme_settings.vim b/AppData/Local/nvim/general/colorscheme_settings.vim index 7f45291..2e2b4ab 100644 --- a/AppData/Local/nvim/general/colorscheme_settings.vim +++ b/AppData/Local/nvim/general/colorscheme_settings.vim @@ -1,8 +1,26 @@ +"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. +"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support +"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) +if (empty($TMUX)) + if (has("nvim")) + "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > + let $NVIM_TUI_ENABLE_TRUE_COLOR=1 + endif + "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > + "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > + " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > + if (has("termguicolors")) + set termguicolors + endif +endif + let g:colorscheme='default' + " gruvbox ----- {{{ if (has("termguicolors")) set termguicolors endif + set background=dark set t_Co=256 " colorscheme gruvbox @@ -10,7 +28,7 @@ set t_Co=256 "https://github.com/sainnhe/gruvbox-material/blob/master/doc/gruvbox-material.txt "soft,medium,hard "let g:gruvbox_material_background = 'medium' -let g:gruvbox_material_transparent_background = 1 +"let g:gruvbox_material_transparent_background = 1 let g:gruvbox_material_enable_bold = 1 let g:gruvbox_material_enable_italic = 1 "let g:gruvbox_material_statusline_style = 'original' diff --git a/AppData/Local/nvim/general/general.vim b/AppData/Local/nvim/general/general.vim index 6eee611..41d4e01 100644 --- a/AppData/Local/nvim/general/general.vim +++ b/AppData/Local/nvim/general/general.vim @@ -3,14 +3,12 @@ set mouse=a " CLIPBOARD ----- {{{ "vim clipboard and system clipboard same now set clipboard^=unnamed - "wrap backspace set backspace=indent,eol,start "https://stackoverflow.com/a/53872985/12988588 "dont save character deleted using `x` "send it to The blackhole-register nnoremap x "_x - "set autochdir " }}} @@ -108,4 +106,4 @@ set shortmess+=c " if has('gui_running') " set guioptions-=e " endif - +" diff --git a/AppData/Local/nvim/general/git.vim b/AppData/Local/nvim/general/git.vim index 21933b4..96afddb 100644 --- a/AppData/Local/nvim/general/git.vim +++ b/AppData/Local/nvim/general/git.vim @@ -26,4 +26,5 @@ augroup GITCOMMIT_SETTINGS "https://vi.stackexchange.com/questions/4343/can-i-detect-whether-current-vim-instance-is-launched-by-git autocmd! autocmd FileType gitcommit,gitrebase silent :call Set_git_settings() + highlight! Normal ctermfg=223 ctermbg=235 guifg=#ebdbb2 guibg=#282828 augroup END diff --git a/AppData/Local/nvim/general/leader.vim b/AppData/Local/nvim/general/leader.vim index 2b4c4f0..18e6468 100644 --- a/AppData/Local/nvim/general/leader.vim +++ b/AppData/Local/nvim/general/leader.vim @@ -1,7 +1,7 @@ " Mappings with leader key " source vim file -nmap <leader>sv :source $LOCALAPPDATA/nvim/init.vim<CR> -nmap <leader>so :e $LOCALAPPDATA/nvim/init.vim<CR> +nmap <leader>vs :source $LOCALAPPDATA/nvim/init.vim<CR> +nmap <leader>vo :e $LOCALAPPDATA/nvim/init.vim<CR> " nmap <leader>so :vsplit <bar> :e $LOCALAPPDATA/nvim/init.vim<CR> nnoremap <leader>n :bnext<CR> nnoremap <leader>p :bprev<CR> @@ -21,4 +21,5 @@ nnoremap <silent> <Leader>0 :exe "vertical resize " . (winwidth(0) * 3/2)<CR> nnoremap <silent> <Leader>9 :exe "vertical resize " . (winwidth(0) * 2/3)<CR> " }}} -"nmap <leader>ws : +"netrw +"nnoremap <silent><leader>t :Lexplore<CR> diff --git a/AppData/Local/nvim/init.vim b/AppData/Local/nvim/init.vim index 48177b7..8f485fe 100644 --- a/AppData/Local/nvim/init.vim +++ b/AppData/Local/nvim/init.vim @@ -39,5 +39,21 @@ source $LOCALAPPDATA/nvim/general/git.vim source $LOCALAPPDATA/nvim/helpers/commands.vim "hi Normal ctermbg=NONE guibg=NONE +" hi Comment gui=italic cterm=italic hi htmlArg gui=italic cterm=italic + +let g:netrw_banner = 0 +"let g:netrw_liststyle=3 +let g:netrw_winsize=30 +let g:netrw_list_hide = '^\.\.\=/\=$,.DS_Store,.idea,.git,__pycache__,venv,node_modules/,*\.o,*\.pyc,.*\.swp' +"let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' +"let g:netrw_hide = 1 +"let g:netrw_browse_split=2 +"let g:netrw_list_hide= netrw_gitignore#Hide() + ""\.',.*\.swp$' + ""\.',*\.git' + ""\.',*\node_modules' +" +"let g:netrw_list_hide= '.*\.swp$' +"let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$' diff --git a/AppData/Local/nvim/plugs/fzf.vim b/AppData/Local/nvim/plugs/fzf.vim index 55d5ded..eff8c2e 100644 --- a/AppData/Local/nvim/plugs/fzf.vim +++ b/AppData/Local/nvim/plugs/fzf.vim @@ -1,7 +1,10 @@ " fzf ----- {{{ " put search prompt at the top let $FZF_DEFAULT_OPTS ='--reverse' - nnoremap <C-p> :Files<CR> + nnoremap <leader>fg :GFiles<CR> + nnoremap <leader>ff :Files<CR> + nnoremap <leader>fb :Buffers<CR> +let g:fzf_preview_window = [] " let g:fzf_action = { " \ 'ctrl-t': 'tab split', " \ 'ctrl-s': 'split', diff --git a/AppData/Local/nvim/plugs/plugins.vim b/AppData/Local/nvim/plugs/plugins.vim index 85625b8..38f5a02 100644 --- a/AppData/Local/nvim/plugs/plugins.vim +++ b/AppData/Local/nvim/plugs/plugins.vim @@ -10,6 +10,8 @@ call plug#begin(s:PLUGIN_DIR) "Plug 'tiagofumo/vim-nerdtree-syntax-highlight' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-commentary' +" Plug 'tpope/vim-vinegar' + Plug 'ryanoasis/vim-devicons' " Track the engine. Plug 'SirVer/ultisnips' @@ -18,7 +20,7 @@ call plug#begin(s:PLUGIN_DIR) Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' "Plug 'nvim-lua/plenary.nvim' - "Plug 'nvim-telescope/telescope.nvim' + Plug 'nvim-telescope/telescope.nvim' Plug 'neoclide/coc.nvim', {'branch': 'release'} "Plug 'w0rp/ale' "Plug 'sheerun/vim-polyglot' @@ -37,5 +39,6 @@ call plug#begin(s:PLUGIN_DIR) Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } Plug 'junegunn/goyo.vim' + call plug#end() " }}} diff --git a/AppData/Local/nvim/plugs/telescope_plug.vim b/AppData/Local/nvim/plugs/telescope_plug.vim index f33f4f6..9738d23 100644 --- a/AppData/Local/nvim/plugs/telescope_plug.vim +++ b/AppData/Local/nvim/plugs/telescope_plug.vim @@ -1,10 +1,10 @@ " Find files using Telescope command-line sugar. "https://github.com/nvim-telescope/telescope.nvim/issues/1144 -nnoremap <leader>ff <cmd>Telescope find_files<cr> -nnoremap <leader>fg <cmd>Telescope git_files<cr> -nnoremap <leader>fl <cmd>Telescope live_grep<cr> -nnoremap <leader>fb <cmd>Telescope buffers<cr> -nnoremap <leader>fh <cmd>Telescope help_tags<cr> +nnoremap <leader>tf <cmd>Telescope find_files<cr> +nnoremap <leader>tg <cmd>Telescope git_files<cr> +nnoremap <leader>tl <cmd>Telescope live_grep<cr> +nnoremap <leader>tb <cmd>Telescope buffers<cr> +nnoremap <leader>th <cmd>Telescope help_tags<cr> lua << EOF require('telescope').setup{ defaults = { vimgrep_arguments = { 'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case', '--ignore-file', '.gitignore' }}} diff --git a/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 b/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 index 890382e..e21f517 100644 --- a/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 +++ b/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1 @@ -118,3 +118,8 @@ set-alias -name wikifiles -value wikifiles_fn ############################################ # Windows terminal settings $wtsettings = (Get-ChildItem "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" -Filter settings.json).FullName + +$env:GVIMINIT='let $MYGVIMRC=has("nvim")?$MYGVIMRC:"$HOME/.config/vim/vimrc" | source $MYGVIMRC' + +#export VIMINIT='let $MYVIMRC=has("nvim")?$MYVIMRC:"$HOME/.config/vim/vimrc" | source $MYVIMRC' +$env:VIMINIT='let $MYVIMRC=has("nvim")?"$LOCALAPPDATA/nvim/init.vim":"$HOME/.config/vim/vimrc" | source $MYVIMRC' diff --git a/README.md b/README.md index 0971857..fee348e 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Configuration files for different applications (_in windows_) [![Vim](https://img.shields.io/badge/VIM-%2311AB00.svg?&style=for-the-badge&logo=vim&logoColor=white)](https://www.vim.org/) [![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)](https://neovim.io/) [![Bash](https://img.shields.io/badge/Shell_Script-121011?style=for-the-badge&logo=gnu-bash&logoColor=white)](https://www.gnu.org/software/bash/) +[![Powershell](https://img.shields.io/badge/PowerShell-5391FE?style=for-the-badge&logo=PowerShell&logoColor=white)](https://docs.microsoft.com/en-us/powershell/) +[![Tmux](https://img.shields.io/badge/tmux-1BB91F?style=for-the-badge&logo=tmux&logoColor=white)](https://github.com/tmux/tmux) ## Fonts @@ -21,4 +23,4 @@ My favourites ## Warnings ⚠ -- Powershell profile has hardcoded paths.Please verify once before using it. +- Many files have hardcoded paths.Please verify once before using it.