1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-03-18 18:07:45 +01:00

157 lines
5.0 KiB
Bash
Raw Normal View History

# Disable ctrl-s and ctrl-q.
stty -ixon
2023-11-12 06:07:58 +01:00
setopt autocd autopushd
2019-10-06 14:11:35 +02:00
2019-12-23 17:13:59 +01:00
# Enable autosuggestions
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
2019-12-23 17:13:59 +01:00
bindkey '^ ' autosuggest-accept
# Enable colors and change prompt
autoload -U colors && colors
2019-12-22 14:23:46 +01:00
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*:*' get-revision true
zstyle ':vcs_info:git*:*' check-for-changes true
2019-12-23 17:13:59 +01:00
zstyle ':vcs_info:git*' formats "(%s) %c%u %b%m"
2019-12-22 14:23:46 +01:00
zstyle ':vcs_info:git*' actionformats "(%s|%a) %12.12i %c%u %b%m"
setopt prompt_subst
# Show remote ref name and number of commits ahead-of or behind
function +vi-git-st() {
local ahead behind remote
local -a gitstatus
# Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
# for git prior to 1.7
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
2019-12-23 17:13:59 +01:00
(( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" )
2019-12-22 14:23:46 +01:00
# for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" )
2019-12-23 17:13:59 +01:00
hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]"
2019-12-22 14:23:46 +01:00
fi
}
# Show count of stashed changes
function +vi-git-stash() {
local -a stashes
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" (${stashes} stashed)"
fi
}
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
PS1='%B%{$fg[blue]%}[%{$fg[blue]%}%n%{$fg[blue]%}@%{$fg[blue]%}%M %{$fg[blue]%}%~%{$fg[blue]%}]%{$reset_color%}\$%b '
RPROMPT='%B%{$fg[blue]%}$vcs_info_msg_0_%{$reset_color%}%b'
2023-10-21 07:11:33 +02:00
source /usr/share/zsh/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh
bindkey '\t' menu-select "$terminfo[kcbt]" menu-select
bindkey -M menuselect '\t' menu-complete "$terminfo[kcbt]" reverse-menu-complete
bindkey -M menuselect '^ ' autosuggest-accept
zstyle ':autocomplete:*' list-lines 100
2023-10-21 07:11:33 +02:00
zstyle ':autocomplete:*' widget-style menu-select
zle -A {.,}history-incremental-search-forward
zle -A {.,}history-incremental-search-backward
zstyle ':autocomplete:*' fzf-completion yes
zstyle ':autocomplete:*' recent-dirs zsh-z
zstyle ':autocomplete:*' menu select
zstyle ':autocomplete:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' # Case insensitive completion
zstyle ':autocomplete:*' insert-unambiguous yes
2019-10-04 01:16:45 +02:00
# Enable vi mode
bindkey -v
export KEYTIMEOUT=1
2019-10-04 01:16:45 +02:00
# Vim bindings in tab mode
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
2019-10-04 01:16:45 +02:00
# Vim Cursor shape
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} == '' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q'
preexec() { echo -ne '\e[5 q' ;}
2019-10-13 20:51:38 +02:00
# Vim copy and paste fix in terminal
function x11-clip-wrap-widgets() {
local copy_or_paste=$1
shift
for widget in $@; do
if [[ $copy_or_paste == "copy" ]]; then
eval "
function _x11-clip-wrapped-$widget() {
zle .$widget
xclip -in -selection clipboard <<<\$CUTBUFFER
}
"
else
eval "
function _x11-clip-wrapped-$widget() {
CUTBUFFER=\$(xclip -out -selection clipboard)
zle .$widget
}
"
fi
zle -N $widget _x11-clip-wrapped-$widget
done
}
local copy_widgets=(
vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line
)
local paste_widgets=(
vi-put-{before,after}
)
# NB: can atm. only wrap native widgets
x11-clip-wrap-widgets copy $copy_widgets
x11-clip-wrap-widgets paste $paste_widgets
# starts one or multiple args in background
background() {
for ((i=2;i<=$#;i++)); do
${@[1]} ${@[$i]} &> /dev/null &|
done
}
2019-10-03 18:05:54 +02:00
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" # Load aliases
# Load command-not-found-handler
source /usr/share/doc/pkgfile/command-not-found.zsh
2023-10-21 07:11:33 +02:00
# Load fast-syntax-highlighting; should be last.
source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
2020-11-29 13:19:28 +00:00
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
tmux attack-session -t $USER || tmux new-session -s $USER
fi
2021-09-12 22:42:55 +02:00
# python
#eval "$(pyenv init -)"
# set up thefuck
eval $(thefuck --alias)
2019-10-03 23:31:14 +02:00
pfetch