mirror of https://git.decapod.one/brethil/dotfiles
Compare commits
10 Commits
56b8f1d05f
...
a9a45864d2
Author | SHA1 | Date |
---|---|---|
bretello | a9a45864d2 | |
bretello | 62c95b60d5 | |
bretello | c137ef0e0f | |
bretello | 3db7721edb | |
bretello | faf318c3d0 | |
bretello | 1ee73be7f9 | |
bretello | 8cdbefa3de | |
bretello | 22023f667e | |
bretello | 114bbe758e | |
bretello | 7312c868b3 |
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
My own dotfiles. `zsh` configuration based on [antibody](https://github.com/getantibody/antibody) and [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh), `vim` configuration uses [vim-plug](https://github.com/junegunn/vim-plug), [ALE](https://github.com/dense-analysis/ale) and more.
|
My own dotfiles. `zsh` configuration based on [antibody](https://github.com/getantibody/antibody) and [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh), `vim` configuration uses [vim-plug](https://github.com/junegunn/vim-plug), [ALE](https://github.com/dense-analysis/ale) and more.
|
||||||
|
|
||||||
[ci.decapod.one status](https://ci.decapod.one/api/badges/2/status.svg)
|
[!ci.decapod.one status](https://ci.decapod.one/api/badges/2/status.svg)
|
||||||
|
|
||||||
[zsh theme](docs/brethil-theme.png "zsh theme")
|
[zsh theme](docs/brethil-theme.png "zsh theme")
|
||||||
[vim theme](docs/vim.png "vim theme")
|
[vim theme](docs/vim.png "vim theme")
|
||||||
|
|
|
@ -58,8 +58,8 @@ fi
|
||||||
## Stress one CPU core
|
## Stress one CPU core
|
||||||
alias stress='yes >> /dev/null'
|
alias stress='yes >> /dev/null'
|
||||||
|
|
||||||
# define ssh without controlmaster
|
# ssh forcing a new connection (no persistent)
|
||||||
alias ssh1="ssh -o ControlMaster=no"
|
alias ssh1="ssh -o ControlMaster=yes -o ControlPersist=no"
|
||||||
|
|
||||||
alias watcha='watch ' # note the space after watch. This makes watch work with aliases
|
alias watcha='watch ' # note the space after watch. This makes watch work with aliases
|
||||||
|
|
||||||
|
@ -82,3 +82,7 @@ alias drp='dvc repro'
|
||||||
alias drps='dvc repro -s'
|
alias drps='dvc repro -s'
|
||||||
|
|
||||||
alias -g J="| jq "
|
alias -g J="| jq "
|
||||||
|
|
||||||
|
# These two depend on oh-my-zsh's clipcopy/clippaste functions
|
||||||
|
alias -g C='| clipcopy'
|
||||||
|
alias -g P='clippaste'
|
||||||
|
|
|
@ -18,19 +18,19 @@ antibody bundle < "$DOTFILES/antibody_plugins.txt"
|
||||||
source $DOTFILES/completion_style.zsh
|
source $DOTFILES/completion_style.zsh
|
||||||
source $DOTFILES/extras/fzf-tab-config.zsh
|
source $DOTFILES/extras/fzf-tab-config.zsh
|
||||||
|
|
||||||
if command -vp fd >/dev/null; then
|
if [[ $+commands[fd] ]]; then
|
||||||
export FZF_CTRL_T_COMMAND='fd'
|
export FZF_CTRL_T_COMMAND='fd'
|
||||||
else
|
else
|
||||||
export FZF_CTRL_T_COMMAND='find'
|
export FZF_CTRL_T_COMMAND='find'
|
||||||
fi
|
fi
|
||||||
export FZF_CTRL_T_OPTS=" --preview-window=right,60% --preview \"bash -c 'if [[ -d \"{}\" ]]; then tree -C \"{}\"; else bat --style=plain --color=always \"{}\"; fi'\" --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'"
|
export FZF_CTRL_T_OPTS=" --preview-window=right,60% --preview \"bash -c 'if [[ -d \"{}\" ]]; then tree -C \"{}\"; else bat --style=plain --color=always \"{}\"; fi'\" --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'"
|
||||||
|
|
||||||
if [[ "$(command -v systemctl)" ]]; then
|
if [[ $+commands[systemctl] ]]; then
|
||||||
antibody bundle robbyrussell/oh-my-zsh path:plugins/systemd
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/systemd
|
||||||
fi
|
fi
|
||||||
if [[ "$(command -v pacman)" ]]; then
|
if [[ $+commands[pacman] ]]; then
|
||||||
antibody bundle robbyrussell/oh-my-zsh path:plugins/archlinux
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/archlinux
|
||||||
elif [[ "$(command -v apt-get)" ]]; then
|
elif [[ $+commands[apt-get] ]]; then
|
||||||
antibody bundle robbyrussell/oh-my-zsh path:plugins/debian
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/debian
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -82,12 +82,8 @@ export ZSH_AUTOSUGGEST_COMPLETION_IGNORE='* \#*' # prevent completion for commen
|
||||||
|
|
||||||
# less options
|
# less options
|
||||||
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
||||||
if [[ "$(command -v bat)" || "$(command -v batcat)" ]]; then
|
if [[ $+commands[bat] || $+commands[batcat] ]]; then
|
||||||
if [[ "$(command -v bat)" ]]; then
|
if [[ $+commands[bat] ]]; then cmd=bat else cmd=batcat fi
|
||||||
cmd=bat
|
|
||||||
else
|
|
||||||
cmd=batcat
|
|
||||||
fi
|
|
||||||
|
|
||||||
alias cat=$cmd
|
alias cat=$cmd
|
||||||
export PAGER=$cmd
|
export PAGER=$cmd
|
||||||
|
|
|
@ -44,13 +44,6 @@ function calc
|
||||||
awk "BEGIN { print $* }"
|
awk "BEGIN { print $* }"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Print full path of item in current directory
|
|
||||||
function ppath
|
|
||||||
{
|
|
||||||
echo "$PWD/$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function warning {
|
function warning {
|
||||||
echo -e "${Yellow}Warning:$CLEAR $@" >&2
|
echo -e "${Yellow}Warning:$CLEAR $@" >&2
|
||||||
}
|
}
|
||||||
|
@ -76,6 +69,30 @@ function beeper
|
||||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# set an alarm in seconds, minutes, hours
|
||||||
|
function alarm {
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
echo "Usage: alarm 5[s]|5m|1h"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local t
|
||||||
|
if [[ $1 = *"m" ]]; then
|
||||||
|
t=$((${1/m/}*60))
|
||||||
|
extra="($1)"
|
||||||
|
elif [[ $1 = *"h" ]]; then
|
||||||
|
t=$((${1/h/}*3600))
|
||||||
|
extra="($1)"
|
||||||
|
elif [[ $1 = *"s" ]]; then
|
||||||
|
t=${1/s/}
|
||||||
|
else
|
||||||
|
t=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Setting a timer for $1 $extra"
|
||||||
|
|
||||||
|
sleep $t && beeper
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## Simple http server for current directory (or path)
|
## Simple http server for current directory (or path)
|
||||||
function httpserver
|
function httpserver
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
function start_tracing {
|
function start_tracing {
|
||||||
zmodload zsh/zprof
|
zmodload zsh/zprof
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
|
|
||||||
setopt PROMPT_SUBST
|
setopt PROMPT_SUBST
|
||||||
PS4+='+$EPOCHREALTIME %N:%i> '
|
PS4+='+$EPOCHREALTIME %N:%i> '
|
||||||
logfile=$(mktemp zsh_profile.XXXXXXXX)
|
logfile=$(mktemp --tmpdir zsh_profile.XXXXXXXX)
|
||||||
echo "logging to $logfile"
|
echo "logging to $logfile"
|
||||||
exec 3>&2 2>$logfile
|
exec 3>&2 2>$logfile
|
||||||
setopt XTRACE
|
setopt XTRACE
|
||||||
|
@ -14,5 +15,8 @@ function start_tracing {
|
||||||
function stop_tracing {
|
function stop_tracing {
|
||||||
unsetopt XTRACE
|
unsetopt XTRACE
|
||||||
exec 2>&3 3>&-
|
exec 2>&3 3>&-
|
||||||
zprof | tee zprof_out.log | vimscratch -
|
zprof | tee zprof_out.log | vim -c "set buftype=nofile" -
|
||||||
|
|
||||||
|
zmodload -u zsh/zprof
|
||||||
|
zmodload -u zsh/datetime
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||||
|
|
||||||
local ret_status="%(?:%{$fg_bold[green]%}➜%{$reset_color%}:%{$fg[red]%}➜%{$reset_color%})"
|
local ret_status="%(?:%{$fg_bold[green]%}➜%{$reset_color%}:%{$fg[red]%}➜%{$reset_color%})"
|
||||||
local user="%(#:root@:)"
|
local user="%(#:root@:)"
|
||||||
PROMPT='[%{$fg[red]%}${user}%M%{$reset_color%}][:%{$fg[green]%}%c%{$reset_color%}]$(git_prompt_info) ${ret_status} '
|
PROMPT='[%{$fg[red]%}${user}%M%{$reset_color%}][:%{$fg[green]%}%c%{$reset_color%}]$(git_prompt_info) ${ret_status} '
|
||||||
|
|
|
@ -18,10 +18,7 @@ function user_prompt(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function job_prompt() {
|
local job_prompt="%(1j.%B%K{202}%F{220} %j %k%b.)"
|
||||||
# Shows jobs number on an orange background if there are background jobs
|
|
||||||
echo "%(1j.%B%K{202}%F{220} %j %k%b.)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function shlvl_prompt() {
|
function shlvl_prompt() {
|
||||||
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
|
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
|
||||||
|
@ -32,14 +29,13 @@ function shlvl_prompt() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function path_prompt(){
|
# TODO: add truncation using
|
||||||
# Shows last 3 items in path if there are more than 4
|
# Shows last 3 items in path if there are more than 4
|
||||||
echo "[%F{green}%(4~:…/%3~:%~)%f]"
|
local path_prompt='[%F{green}%(4~:…/%3~:%~)%f]'
|
||||||
}
|
|
||||||
|
|
||||||
# PREFIX/SUFFIX are added before/after `git_prompt_info`
|
# PREFIX/SUFFIX are added before/after `git_prompt_info`
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="%f%{$fg[yellow]%} "
|
ZSH_THEME_GIT_PROMPT_PREFIX=" %f%{$fg[yellow]%} "
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} |"
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[white]%}%{$fg[red]%}x%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[white]%}%{$fg[red]%}x%{$reset_color%}"
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[white]%}%{$fg[green]%}√%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[white]%}%{$fg[green]%}√%{$reset_color%}"
|
||||||
|
@ -75,39 +71,24 @@ function virtualenv_info {
|
||||||
echo -n " $BOLD_PURPLE<$venv>$CLEAR "
|
echo -n " $BOLD_PURPLE<$venv>$CLEAR "
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt() {
|
|
||||||
# prints git info if in a git repo
|
|
||||||
if ! git rev-parse --git-dir &>/dev/null; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " $(git_prompt_info) |$(git_prompt_status)$(git_remote_status)"
|
local git_prompt='$(git_prompt_info)$(git_prompt_status)$(git_remote_status)'
|
||||||
}
|
|
||||||
|
|
||||||
|
local return_code_RPS1='%(?..%B%F{88}-$?-%f%b)'
|
||||||
|
|
||||||
function return_code_RPS1() {
|
local success="%B%F{28} →%f%b"
|
||||||
# red status code if last exit code is non-zero
|
local failure="%B%{$fg[red]%} x%b%{$reset_color%}"
|
||||||
echo "%(?..%B%F{88}-$?-%f%b)"
|
local prompt_with_previous_return_status="%(?:$success:$failure) "
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_with_previous_return_status() {
|
# prints a newline if more than $COLUMNS/2 characters have been printed, see end of `man zshmisc`
|
||||||
local success="%B%F{28} →%f%b"
|
local prompt_too_long='%-$((COLUMNS/2))(l..'$'\n'')'
|
||||||
local failure="%B%{$fg[red]%} x%b%{$reset_color%}"
|
|
||||||
echo "%(?:$success:$failure)"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function prompt_too_long(){
|
|
||||||
# prints a newline if more than $COLUMNS/2 characters have been printed
|
|
||||||
local newline=$'\n'
|
|
||||||
echo "%-$((COLUMNS/2))(l..${newline})"
|
|
||||||
}
|
|
||||||
|
|
||||||
## oh-my-zsh vi-mode plugins indicators:
|
## oh-my-zsh vi-mode plugins indicators:
|
||||||
export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
||||||
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
||||||
|
|
||||||
PROMPT='$(virtualenv_info)$(user_prompt)$(path_prompt)$(git_prompt)$(job_prompt)$(shlvl_prompt)$(prompt_too_long)$(prompt_with_previous_return_status) '
|
# put it all together
|
||||||
|
PROMPT='$(virtualenv_info)$(user_prompt)'"${path_prompt}${git_prompt}${job_prompt}"'$(shlvl_prompt)'"${prompt_too_long}${prompt_with_previous_return_status}"
|
||||||
|
|
||||||
# Right prompt is just return code and time
|
# Right prompt is just return code and time
|
||||||
RPS1='$(return_code_RPS1)$(vi_mode_prompt_info)[%*]'
|
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'
|
||||||
|
|
|
@ -69,6 +69,10 @@ set foldminlines=3
|
||||||
" Timeout for combined keymaps (half a sec)
|
" Timeout for combined keymaps (half a sec)
|
||||||
set timeoutlen=500
|
set timeoutlen=500
|
||||||
|
|
||||||
|
" keep history the last 1000 opened files, 200 commands and 50 search
|
||||||
|
" patterns. `h` persists bookmarks across sessions
|
||||||
|
set viminfo='1000,<200,s50,h
|
||||||
|
|
||||||
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
||||||
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
||||||
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
||||||
|
@ -83,6 +87,10 @@ syntax match jsonComment "\(/\*\)\|\(\*/\)"
|
||||||
hi def link jsonComment Comment
|
hi def link jsonComment Comment
|
||||||
|
|
||||||
|
|
||||||
|
augroup dotgit_diffs
|
||||||
|
au BufRead .git/*.diff let b:ale_fix_on_save=0
|
||||||
|
augroup END
|
||||||
|
|
||||||
augroup dvc
|
augroup dvc
|
||||||
au BufRead dvc.yaml let b:ale_fix_on_save=0
|
au BufRead dvc.yaml let b:ale_fix_on_save=0
|
||||||
au BufRead *.dvc let b:ale_fix_on_save=0
|
au BufRead *.dvc let b:ale_fix_on_save=0
|
||||||
|
|
Loading…
Reference in New Issue