mirror of
https://github.com/tiyn/dotfiles.git
synced 2026-03-09 18:54:47 +01:00
Compare commits
4 Commits
e9d5b3ecd4
...
f2c8b6d8e5
| Author | SHA1 | Date | |
|---|---|---|---|
| f2c8b6d8e5 | |||
| f33b4e49f0 | |||
| 87e4a1966e | |||
| 8c4b6d593d |
@@ -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"
|
||||
|
||||
@@ -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 #
|
||||
###############
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user