Compare commits

...

8 Commits

Author SHA1 Message Date
bretello bef37c3601
vim: add <leader>q shortcut (closes windows) 2022-03-26 16:43:46 +01:00
bretello 0ed9e5373c
zsh: add asciinema-switch
helps switch different asciinema profiles
2022-03-26 16:43:46 +01:00
bretello d1be12fa3e
zsh: add UNDERLINE to colors 2022-03-26 16:43:46 +01:00
bretello 492205e86b
zsh: add mkvenv function 2022-03-26 16:43:36 +01:00
bretello 41b97a1be3
zsh: refactor aliases/functions sourcing 2022-03-26 16:43:36 +01:00
bretello 9b6494c94d
zsh: fix `color` function 2022-03-26 16:43:35 +01:00
bretello 2841fada0a
zsh: use zsh-users/zsh-syntax-highlight instead of zdharma's 2022-03-26 11:30:16 +01:00
bretello 6235cfb737
ansible: add tmux symlink 2022-03-25 09:26:27 +01:00
10 changed files with 97 additions and 13 deletions

View File

@ -0,0 +1,4 @@
# aliases
Place custom alias definitions in this folder, with a `.zsh` extension.
These files will be sourced on startup

View File

@ -70,6 +70,7 @@
loop: '{{ files | dict2items }}'
vars:
files:
'tmux.conf': '~/.tmux.conf'
'vim/vimrc': '~/.vimrc'
'pdbrc.py': '~/.pdbrc.py'
# "ipython": "~/.ipython" # FIXME: ipython config is more complex

View File

@ -20,8 +20,8 @@ robbyrussell/oh-my-zsh path:plugins/pylint
robbyrussell/oh-my-zsh path:plugins/sudo
robbyrussell/oh-my-zsh path:plugins/vagrant
robbyrussell/oh-my-zsh path:plugins/vi-mode
zdharma-continuum/fast-syntax-highlighting
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-syntax-highlighting
joshskidmore/zsh-fzf-history-search
ryutok/rust-zsh-completions

View File

@ -26,6 +26,8 @@ elif [[ "$(command -v apt-get)" ]]; then
antibody bundle robbyrussell/oh-my-zsh path:plugins/debian
fi
ZSH_HIGHLIGHT_STYLES[comment]='fg=gray,bg=white,bold'
# Setup oh-my-zsh path
export ZSH="$(antibody path robbyrussell/oh-my-zsh)"
@ -85,15 +87,19 @@ alias esource='$EDITOR $HOME/.zshrc'
alias resource='source $HOME/.zshrc'
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
# Custom definitions files
alias funedit='$EDITOR ~/.dotfiles_functions.sh'
alias aledit='$EDITOR ~/.dotfiles_aliases.sh'
alias funedit='$EDITOR ~/.dotfiles_functions'
alias aledit='$EDITOR ~/.dotfiles_aliases'
export p="${HOME}/projects"
export g="${HOME}/git"
export w="${HOME}/work"
source $DOTFILES/functions.zsh
source $DOTFILES/aliases.zsh
for defname in aliases functions ; do
for def in $DOTFILES/$defname/*zsh ; do
source $def
done
done
unset def defname
# Extras
functions_file=~/.dotfiles_functions

View File

@ -23,6 +23,9 @@ BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White
# Underline
if command -v tput &>/dev/null; then
UNDERLINE="$(tput smul)"
fi
UBlack='\e[4;30m' # Black
URed='\e[4;31m' # Red
UGreen='\e[4;32m' # Green

View File

@ -0,0 +1,4 @@
# functions
Place custom functions definitions in this folder, with a `.zsh` extension.
These files will be sourced on startup

View File

@ -0,0 +1,55 @@
function warning {
echo -e "$(color $YELLOW Warning:) $@" >&2
}
function error {
echo -e "$(color $RED Error:) $@" >&2
}
function info {
echo -e "$(color $GREEN Info:) $@"
}
function switch-asciinema-user
{
local conf_dir="$HOME/.config/asciinema"
local current_id=$(basename $(readlink -f ${conf_dir}/install-id ))
function get_ids {
find ${conf_dir} -name 'install-id-*' -exec basename {} \;
}
if [[ $1 == "-l" || $1 == "--list" ]]; then
echo "$(color $BOLD Available ids): (current = $(color $UNDERLINE ${current_id}))"
for _id in $(get_ids); do
echo " $(green ➡️) ${_id}"
done
return
fi
local ids=$(get_ids)
local query
local new_id
if [[ -n "$@" ]]; then
query="-q $@"
fi
new_id=$(echo $ids| fzf --height=$(($(wc -l <<< $ids)+2)) ${query} )
if [[ -z $new_id ]]; then
warning "Keeping curent id ($(color $UNDERLINE ${current_id}))"
return
fi
if [[ "$new_id" == "$current_id" ]]; then
warning "id $new_id is already set."
return
fi
local id_file="${conf_dir}/${new_id}"
if [[ ! -f ${id_file} ]]; then
error "${id_file} does not exist"
return
fi
ln -sf "${id_file}" "${conf_dir}/install-id" && \
info "Set \"$new_id\"." || \
error "Could not set id \"$new_id\". (run with -l for a list of available profiles)"
}

View File

@ -50,14 +50,12 @@ function ppath
echo "$PWD/$1"
}
## Color string with given color. Usage: color $colorname "string", available colors in colors.sh
## Color string with given color. Usage: `color $NAME "string"`, available colors in `colors.sh`
function color
{
color=$1
set -x
shift 1
echo -e "$"$color"$@${CLEAR}\n"
set +x
echo -e "${color}$@${CLEAR}"
}
@ -277,6 +275,19 @@ __git_completion_wrapper() {
__completion_wrapper $1 _git
}
# sort branches by latest commit
function git-sort-branch-by-usage(){
git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short)'
}
# switch to a recent branch
function git-switch-recent-branch(){
git switch $1
}
# compdef git-sort-branch-by-usage git-switch-recent-branch
compdef "__git_completion_wrapper __git_recent_branches" git-switch-recent-branch
# Runs git log with fzf with preview
function fgitlog() {
git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60%
@ -284,7 +295,7 @@ function fgitlog() {
compdef _git fgitlog=git-log
git-commit-show() {
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" |
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" $@ |
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
'f() {
set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}")
@ -342,7 +353,7 @@ make_backup() {
echo "done"
}
make_venv(){
mkvenv(){
python -m venv .venv && echo "created venv: .venv"
read -q source_venv

View File

@ -51,7 +51,7 @@ map <leader>ss :setlocal spell!<CR>
nnoremap <leader>M :bel copen<bar>silent make <bar>redraw!<CR>
nnoremap <leader>wz :call WinZoomToggle()<CR>
nnoremap <leader>C :close<CR>
nnoremap <leader>q :close<CR>
nnoremap <leader>B :Bclose<CR>
nnoremap <leader>k :Rg<CR>