1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2026-03-09 18:54:47 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
f2c8b6d8e5 git: added (mostly) safe force push alias 2026-03-01 10:40:20 +01:00
f33b4e49f0 git: added amend as alias 2026-03-01 09:21:12 +01:00
87e4a1966e zsh: add auto-venv and remote git push support 2026-03-01 07:57:10 +01:00
8c4b6d593d zsh: enable smart search back- and forwards 2026-03-01 06:05:46 +01:00
3 changed files with 58 additions and 8 deletions

View File

@@ -75,10 +75,10 @@ alias contacts="khard"
alias paint="kolourpaint"
# ls(d)
alias l="exa --group-directories-first"
alias la="exa -la --group-directories-first"
alias ll="exa -l --group-directories-first"
alias tree="exa --tree --group-directories-first"
alias l="exa --group-directories-first --icons"
alias la="exa -la --group-directories-first --icons --git"
alias ll="exa -l --group-directories-first --icons --git"
alias tree="exa --tree --group-directories-first --icons"
# mkdir
alias mkdir="mkdir -p"

View File

@@ -85,7 +85,51 @@ function +vi-git-stash() {
# CUSTOM WIDGETS #
##################
_git_intercept() {
_find_venv_upwards() {
local dir="$PWD"
while [[ "$dir" != "/" ]]; do
if [[ -f "$dir/pyvenv.cfg" ]]; then
echo "$dir"
return
fi
dir=$(dirname "$dir")
done
}
_auto_venv() {
local venv_dir
venv_dir=$(_find_venv_upwards)
# Falls wir eine andere venv aktiv haben → deaktivieren
if [[ -n "$VIRTUAL_ENV" && "$VIRTUAL_ENV" != "$venv_dir" ]]; then
deactivate 2>/dev/null
fi
# Falls passende venv gefunden → aktivieren
if [[ -n "$venv_dir" && "$VIRTUAL_ENV" != "$venv_dir" ]]; then
source "$venv_dir/bin/activate"
fi
}
autoload -U add-zsh-hook
add-zsh-hook chpwd _auto_venv
_auto_venv
_accept_line() {
# automatically push to remote
if [[ "$BUFFER" == "git push" ]]; then
local branch
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [[ -n "$branch" ]]; then
git rev-parse --abbrev-ref --symbolic-full-name @{u} &>/dev/null
if [[ $? -ne 0 ]]; then
BUFFER="git push -u origin $branch"
fi
fi
fi
# use keifu instead of git log --graph
if [[ "$BUFFER" =~ ^([a-zA-Z0-9_-]+)[[:space:]]+([a-zA-Z0-9_-]+)(.*)$ ]]; then
@@ -159,8 +203,8 @@ _git_intercept() {
zle accept-line
}
zle -N _git_intercept
bindkey "^M" _git_intercept
zle -N _accept_line
bindkey "^M" _accept_line
#########
# STYLE #
@@ -213,6 +257,10 @@ autoload -U colors && colors
# Enable git info in prompt
autoload -Uz vcs_info
# Enable smart history search
bindkey -M vicmd 'j' history-beginning-search-forward
bindkey -M vicmd 'k' history-beginning-search-backward
###############
# KEYBINDINGS #
###############

View File

@@ -25,4 +25,6 @@
[credential]
helper = store
[alias]
graph = log --graph
graph = log --graph
amend = commit --amend --no-edit
fpush = push --force-with-lease --force-if-includes