Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Allow for Oh My Zsh integration
Browse files Browse the repository at this point in the history
Start replacing $ZSH variable with $DOTFILES in a backward-compatible
way, so that existing users have a chance to migrate.

Cherry-picked from holman#272.
Fixed conflicts.
  • Loading branch information
anpol authored and Adrien-LUDWIG committed Apr 19, 2023
1 parent 9201ec2 commit 979400e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions git/gitconfig.symlink
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
protocol = https
[alias]
co = checkout
promote = !$ZSH/bin/git-promote
wtf = !$ZSH/bin/git-wtf
rank-contributors = !$ZSH/bin/git-rank-contributors
promote = !$DOTFILES/bin/git-promote
wtf = !$DOTFILES/bin/git-wtf
rank-contributors = !$DOTFILES/bin/git-rank-contributors
count = !git shortlog -sn
[color]
diff = auto
Expand Down
2 changes: 1 addition & 1 deletion zsh/prompt.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ battery_status() {

if [[ $(sysctl -n hw.model) == *"Book"* ]]
then
$ZSH/bin/battery-status
$DOTFILES/bin/battery-status
fi
}

Expand Down
29 changes: 23 additions & 6 deletions zsh/zshrc.symlink
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Fig pre block. Keep at the top of this file.
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && . "$HOME/.fig/shell/zshrc.pre.zsh"
# shortcut to this dotfiles path is $ZSH
export ZSH=$HOME/.dotfiles
# shortcut to this dotfiles path is $DOTFILES
export DOTFILES=$HOME/.dotfiles

# $ZSH variable is deprecated, use $DOTFILES instead
export ZSH="$DOTFILES"

# your project folder that we can `c [tab]` to
export PROJECTS=~/Code
Expand All @@ -16,7 +19,7 @@ fi

# all of our zsh files
typeset -U config_files
config_files=($ZSH/**/*.zsh)
config_files=($DOTFILES/**/*.zsh)

# load the path files
for file in ${(M)config_files:#*/path.zsh}
Expand All @@ -30,9 +33,20 @@ do
source $file
done

# initialize autocomplete here, otherwise functions won't be loaded
autoload -U compinit
compinit
# Oh My Zsh could be installed somewhere out of dotfiles directory tree, e.g.
# into ~/.oh-my-zsh; the configuration file created by Oh My Zsh installer
# should be moved as follows: {.zshrc => $DOTFILES/zsh/oh-my-zshrc}.
if [[ -f $DOTFILES/zsh/oh-my-zshrc ]]; then
() {
local ZSH="$HOME/.oh-my-zsh"
source $DOTFILES/zsh/oh-my-zshrc
export OHMYZSH="$ZSH"
}
else
# initialize autocomplete here, otherwise functions won't be loaded
autoload -U compinit
compinit
fi

# load every completion after autocomplete loads
for file in ${(M)config_files:#*/completion.zsh}
Expand All @@ -51,5 +65,8 @@ zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search # Up
bindkey "^[[B" down-line-or-beginning-search # Down

# Notify existing users that they should migrate to another variable.
export ZSH='$ZSH is deprecated, use either $DOTFILES or $OHMYZSH instead.'

# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && . "$HOME/.fig/shell/zshrc.post.zsh"

0 comments on commit 979400e

Please sign in to comment.