Skip to content

Commit 997d6ca

Browse files
committed
Replace oh-my-zsh with custom plugins
1 parent 3199eed commit 997d6ca

File tree

13 files changed

+220
-111
lines changed

13 files changed

+220
-111
lines changed

bin/install

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#!/bin/sh
22

3-
ln -s $(readlink -f gemrc) ~/.gemrc
4-
ln -s $(readlink -f gitconfig) ~/.gitconfig
5-
ln -s $(readlink -f gitignore) ~/.gitignore
6-
ln -s $(readlink -f irbrc) ~/.irbrc
3+
ln -is $(readlink -f gemrc) ~/.gemrc
4+
ln -is $(readlink -f gitconfig) ~/.gitconfig
5+
ln -is $(readlink -f gitignore) ~/.gitignore
6+
ln -is $(readlink -f irbrc) ~/.irbrc
7+
ln -is $(readlink -f plugins) ~/.zsh-plugins
78

8-
cp -s $(readlink -f zshrc) ~/.zshrc
9+
cp -i $(readlink -f zshrc) ~/.zshrc
910

1011
read -p "Your Name for Git Commits: " git_name
11-
read -p "Your Email for Git Commits: " git_email
1212

13-
echo "export GIT_AUTHOR_NAME=\"$git_name\"" >> ~/.zshrc
14-
echo "export GIT_AUTHOR_EMAIL=\"$git_email\"" >> ~/.zshrc
15-
echo "export GIT_COMMITTER_NAME=\"$git_name\"" >> ~/.zshrc
16-
echo "export GIT_COMMITTER_EMAIL=\"$git_email\"" >> ~/.zshrc
13+
if [[ -n $git_name ]]; then
14+
read -p "Your Email for Git Commits: " git_email
1715

18-
echo "Git Name and Email have been appended to ~/.zshrc"
16+
echo "" >> ~/.zshrc
17+
echo "# GIT CONFIG" >> ~/.zshrc
18+
echo "export GIT_AUTHOR_NAME=\"$git_name\"" >> ~/.zshrc
19+
echo "export GIT_AUTHOR_EMAIL=\"$git_email\"" >> ~/.zshrc
20+
echo "export GIT_COMMITTER_NAME=\"$git_name\"" >> ~/.zshrc
21+
echo "export GIT_COMMITTER_EMAIL=\"$git_email\"" >> ~/.zshrc
22+
23+
echo "Git Name and Email have been appended to ~/.zshrc"
24+
fi

oh-my-zsh/custom/plugins/rbates/_cap

Lines changed: 0 additions & 8 deletions
This file was deleted.

oh-my-zsh/custom/plugins/rbates/_rake

Lines changed: 0 additions & 8 deletions
This file was deleted.

oh-my-zsh/custom/plugins/rbates/bin/subl

Lines changed: 0 additions & 1 deletion
This file was deleted.

oh-my-zsh/custom/plugins/rbates/bin/tagversions

Lines changed: 0 additions & 45 deletions
This file was deleted.

oh-my-zsh/custom/plugins/rbates/rbates.plugin.zsh

Lines changed: 0 additions & 18 deletions
This file was deleted.

oh-my-zsh/custom/rbates.zsh-theme

Lines changed: 0 additions & 8 deletions
This file was deleted.

plugins/bundler.zsh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This is based on https://github.com/ohmyzsh/ohmyzsh
2+
3+
## ALIASES
4+
5+
alias be="bundle exec"
6+
7+
8+
## GEM WRAPPER
9+
10+
bundled_commands=(
11+
cap
12+
capify
13+
cucumber
14+
guard
15+
hanami
16+
irb
17+
jekyll
18+
pry
19+
puma
20+
rackup
21+
rake
22+
rspec
23+
rubocop
24+
sidekiq
25+
spring
26+
thin
27+
unicorn
28+
unicorn_rails
29+
)
30+
31+
# Check if in the root or a subdirectory of a bundled project
32+
_within-bundled-project() {
33+
local check_dir="$PWD"
34+
while [[ "$check_dir" != "/" ]]; do
35+
if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
36+
return 0
37+
fi
38+
check_dir="${check_dir:h}"
39+
done
40+
return 1
41+
}
42+
43+
_run-with-bundler() {
44+
if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
45+
"$@"
46+
return $?
47+
fi
48+
49+
if [[ -f "./bin/${1}" ]]; then
50+
./bin/${^^@}
51+
else
52+
bundle exec "$@"
53+
fi
54+
}
55+
56+
for cmd in $bundled_commands; do
57+
# Create wrappers for bundled and unbundled execution
58+
eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
59+
eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
60+
alias "$cmd"="bundled_$cmd"
61+
62+
# Bind completion function to wrapped gem if available
63+
if (( $+functions[_$cmd] )); then
64+
compdef "_$cmd" "bundled_$cmd"="$cmd"
65+
fi
66+
done
67+
unset cmd bundled_commands

plugins/git.zsh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This is based on https://github.com/ohmyzsh/ohmyzsh
2+
3+
# ALIASES
4+
5+
alias ga='git add'
6+
alias gaa='git add --all'
7+
8+
alias gb='git branch --sort=committerdate'
9+
10+
alias gc='git commit --verbose'
11+
alias gca='git commit --verbose --all'
12+
alias gca!='git commit --verbose --all --amend'
13+
alias gcan!='git commit --verbose --all --no-edit --amend'
14+
alias gc!='git commit --verbose --amend'
15+
alias gcn!='git commit --verbose --no-edit --amend'
16+
17+
alias gd='git diff'
18+
alias gdca='git diff --cached'
19+
alias gds='git diff --staged'
20+
21+
alias grb='git rebase'
22+
alias grba='git rebase --abort'
23+
alias grbc='git rebase --continue'
24+
alias grbi='git rebase --interactive'
25+
26+
alias gpristine='git reset --hard && git clean --force -dfx'
27+
alias groh='git reset origin/$(git_current_branch) --hard'
28+
29+
alias gsh='git show'
30+
31+
alias gst='git status'
32+
33+
alias gstl='git stash list'
34+
alias gsta='git stash push'
35+
alias gstp='git stash pop'
36+
37+
alias gsw='git switch'
38+
alias gswc='git switch --create'
39+
40+
41+
# FUNCTIONS
42+
43+
# Outputs the name of the current branch
44+
# Usage example: git pull origin $(git_current_branch)
45+
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
46+
# it's not a symbolic ref, but in a Git repo.
47+
function git_current_branch() {
48+
local ref
49+
ref=$(git --no-optional-locks symbolic-ref --quiet HEAD 2> /dev/null)
50+
local ret=$?
51+
if [[ $ret != 0 ]]; then
52+
[[ $ret == 128 ]] && return # no git repo.
53+
ref=$(git --no-optional-locks rev-parse --short HEAD 2> /dev/null) || return
54+
fi
55+
echo ${ref#refs/heads/}
56+
}
57+
58+
# Pass the prefix and suffix as first and second argument
59+
# Example: git_prompt_info [ ]
60+
function git_prompt_info() {
61+
# If we are on a folder not tracked by git, get out.
62+
if !git --no-optional-locks rev-parse --git-dir &> /dev/null; then
63+
return 0
64+
fi
65+
66+
local ref
67+
ref=$(git --no-optional-locks symbolic-ref --short HEAD 2> /dev/null) \
68+
|| ref=$(git --no-optional-locks describe --tags --exact-match HEAD 2> /dev/null) \
69+
|| ref=$(git --no-optional-locks rev-parse --short HEAD 2> /dev/null) \
70+
|| return 0
71+
72+
echo "$1${ref:gs/%/%%}$(git_dirty_info "*")$2"
73+
}
74+
75+
# Checks if working tree is dirty
76+
# The argument passed in is printed when dirty
77+
# Example: git_dirty_info "*"
78+
function git_dirty_info() {
79+
local STATUS
80+
STATUS=$(git --no-optional-locks status --porcelain 2> /dev/null | tail -n 1)
81+
if [[ -n $STATUS ]]; then
82+
echo $1
83+
fi
84+
}

plugins/init.zsh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
autoload -U +X compinit && compinit
2+
autoload -U +X bashcompinit && bashcompinit
3+
4+
setopt PROMPT_SUBST

0 commit comments

Comments
 (0)