diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-08-01 17:29:55 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-08-01 17:29:55 +0200 |
| commit | b61387adc936dc51f1d9e84136aa9972ea8480e7 (patch) | |
| tree | 9e613f01d2e381855bfdc452596d83f89e37e25e /zsh/zshrc | |
| parent | 428beb1c921ce09bf269560ee67afeb628b5c247 (diff) | |
| download | dotfiles-b61387adc936dc51f1d9e84136aa9972ea8480e7.tar.gz dotfiles-b61387adc936dc51f1d9e84136aa9972ea8480e7.tar.bz2 dotfiles-b61387adc936dc51f1d9e84136aa9972ea8480e7.zip | |
zsh: Schreibweise für Funktionen und 'source' vereinheitlicht
Diffstat (limited to 'zsh/zshrc')
| -rw-r--r-- | zsh/zshrc | 27 |
1 files changed, 16 insertions, 11 deletions
| @@ -1,7 +1,7 @@ | |||
| 1 | # vim: filetype=zsh | 1 | # vim: filetype=zsh |
| 2 | 2 | ||
| 3 | # Hooks | 3 | # Hooks |
| 4 | function chpwd() { | 4 | chpwd() { |
| 5 | if [[ -n "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then | 5 | if [[ -n "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then |
| 6 | local venv_dir="${VIRTUAL_ENV:h}" | 6 | local venv_dir="${VIRTUAL_ENV:h}" |
| 7 | if [[ "$PWD" != "$venv_dir"* ]] && (( $+functions[deactivate] )); then | 7 | if [[ "$PWD" != "$venv_dir"* ]] && (( $+functions[deactivate] )); then |
| @@ -11,15 +11,17 @@ function chpwd() { | |||
| 11 | 11 | ||
| 12 | for v in .venv venv .env; do | 12 | for v in .venv venv .env; do |
| 13 | if [[ -f "$v/bin/activate" ]]; then | 13 | if [[ -f "$v/bin/activate" ]]; then |
| 14 | source "$v/bin/activate" | 14 | . "$v/bin/activate" |
| 15 | break | 15 | break |
| 16 | fi | 16 | fi |
| 17 | done | 17 | done |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | # Funktionen | 20 | # Funktionen |
| 21 | function source_file() { | 21 | source_if_exists() { |
| 22 | [[ ! -r "$1" ]] || source "$1" | 22 | if [[ -r "$1" ]]; then |
| 23 | . "$1" | ||
| 24 | fi | ||
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | # Optionen | 27 | # Optionen |
| @@ -31,16 +33,16 @@ setopt SHARE_HISTORY | |||
| 31 | setopt HIST_IGNORE_ALL_DUPS | 33 | setopt HIST_IGNORE_ALL_DUPS |
| 32 | setopt HIST_IGNORE_SPACE | 34 | setopt HIST_IGNORE_SPACE |
| 33 | 35 | ||
| 34 | source_file "$HOME/.opam/opam-init/init.zsh" | 36 | source_if_exists "$HOME/.opam/opam-init/init.zsh" |
| 35 | 37 | ||
| 36 | case "$OSTYPE" in | 38 | case "$OSTYPE" in |
| 37 | darwin*) | 39 | darwin*) |
| 38 | source_file "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | 40 | source_if_exists "/opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" |
| 39 | source_file "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" | 41 | source_if_exists "/opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" |
| 40 | ;; | 42 | ;; |
| 41 | freebsd*) | 43 | freebsd*) |
| 42 | source_file "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | 44 | source_if_exists "/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" |
| 43 | source_file "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" | 45 | source_if_exists "/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh" |
| 44 | ;; | 46 | ;; |
| 45 | esac | 47 | esac |
| 46 | 48 | ||
| @@ -86,12 +88,13 @@ nvim-update() { | |||
| 86 | } | 88 | } |
| 87 | 89 | ||
| 88 | # Command completion | 90 | # Command completion |
| 89 | autoload -U compinit; compinit | 91 | autoload -U compinit |
| 92 | compinit | ||
| 90 | _comp_options+=(globdots) # With hidden files | 93 | _comp_options+=(globdots) # With hidden files |
| 91 | 94 | ||
| 92 | # ... Angular CLI | 95 | # ... Angular CLI |
| 93 | if (( $+commands[ng] )); then | 96 | if (( $+commands[ng] )); then |
| 94 | source <(ng completion script) | 97 | . <(ng completion script) |
| 95 | fi | 98 | fi |
| 96 | 99 | ||
| 97 | zstyle ':completion:*' completer _extensions _complete _approximate | 100 | zstyle ':completion:*' completer _extensions _complete _approximate |
| @@ -119,3 +122,5 @@ zstyle ':vcs_info:*' check-for-changes true | |||
| 119 | zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%a%u%c%F{3}|%F{1}%a%F{5}]%f' | 122 | zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%a%u%c%F{3}|%F{1}%a%F{5}]%f' |
| 120 | zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%u%c%F{5}]%f' | 123 | zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%u%c%F{5}]%f' |
| 121 | zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' | 124 | zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' |
| 125 | |||
| 126 | unfunction source_if_exists | ||
