mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-01 04:30:37 +02:00
Stripping out anything unused in .oh-my-zsh
This commit is contained in:
parent
28d16ade90
commit
ed2ef5a2b0
22 changed files with 22 additions and 595 deletions
|
|
@ -1,3 +0,0 @@
|
|||
alias figlet="nocorrect figlet"
|
||||
alias rake="noglob rake"
|
||||
alias ...="noglob ..."
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# Add yourself some shortcuts to projects you often work on
|
||||
# Example:
|
||||
#
|
||||
# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr
|
||||
#
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# Add your own custom plugins in the custom/plugins directory. Plugins placed
|
||||
# here will override ones with the same name in the main plugins directory.
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
if [[ "$DISABLE_CORRECTION" == "true" ]]; then
|
||||
return
|
||||
else
|
||||
setopt correct_all
|
||||
alias man='nocorrect man'
|
||||
alias mv='nocorrect mv'
|
||||
alias mysql='nocorrect mysql'
|
||||
alias mkdir='nocorrect mkdir'
|
||||
alias gist='nocorrect gist'
|
||||
alias heroku='nocorrect heroku'
|
||||
alias ebuild='nocorrect ebuild'
|
||||
alias hpodder='nocorrect hpodder'
|
||||
alias sudo='nocorrect sudo'
|
||||
fi
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '\C-x\C-e' edit-command-line
|
||||
|
|
@ -2,16 +2,7 @@ function zsh_stats() {
|
|||
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
||||
}
|
||||
|
||||
function uninstall_oh_my_zsh() {
|
||||
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
|
||||
}
|
||||
|
||||
function upgrade_oh_my_zsh() {
|
||||
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
|
||||
}
|
||||
|
||||
function take() {
|
||||
mkdir -p $1
|
||||
cd $1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,22 +29,3 @@ bindkey '^?' backward-delete-char
|
|||
bindkey "^[[3~" delete-char
|
||||
bindkey "^[3;5~" delete-char
|
||||
bindkey "\e[3~" delete-char
|
||||
|
||||
# consider emacs keybindings:
|
||||
|
||||
#bindkey -e ## emacs key bindings
|
||||
#
|
||||
#bindkey '^[[A' up-line-or-search
|
||||
#bindkey '^[[B' down-line-or-search
|
||||
#bindkey '^[^[[C' emacs-forward-word
|
||||
#bindkey '^[^[[D' emacs-backward-word
|
||||
#
|
||||
#bindkey -s '^X^Z' '%-^M'
|
||||
#bindkey '^[e' expand-cmd-path
|
||||
#bindkey '^[^I' reverse-menu-complete
|
||||
#bindkey '^X^N' accept-and-infer-next-history
|
||||
#bindkey '^W' kill-region
|
||||
#bindkey '^I' complete-word
|
||||
## Fix weird sequence that rxvt produces
|
||||
#bindkey -s '^[[Z' '\t'
|
||||
#
|
||||
|
|
|
|||
15
lib/misc.zsh
15
lib/misc.zsh
|
|
@ -1,15 +0,0 @@
|
|||
## smart urls
|
||||
autoload -U url-quote-magic
|
||||
zle -N self-insert url-quote-magic
|
||||
|
||||
## file rename magick
|
||||
bindkey "^[m" copy-prev-shell-word
|
||||
|
||||
## jobs
|
||||
setopt long_list_jobs
|
||||
|
||||
## pager
|
||||
export PAGER="less"
|
||||
export LESS="-R"
|
||||
|
||||
export LC_CTYPE=$LANG
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# using the rbenv plugin will override this with a real implementation
|
||||
function rbenv_prompt_info() {}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# get the name of the ruby version
|
||||
function rvm_prompt_info() {
|
||||
[ -f $HOME/.rvm/bin/rvm-prompt ] || return
|
||||
local rvm_prompt
|
||||
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
|
||||
[[ "${rvm_prompt}x" == "x" ]] && return
|
||||
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
|
||||
}
|
||||
|
|
@ -1,21 +1,9 @@
|
|||
#!/usr/bin/env zsh
|
||||
# ls colors
|
||||
autoload colors; colors;
|
||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||
#export LS_COLORS
|
||||
|
||||
# Enable ls colors
|
||||
if [ "$DISABLE_LS_COLORS" != "true" ]
|
||||
then
|
||||
# Find the option for using colors in ls, depending on the version: Linux or BSD
|
||||
if [[ "$(uname -s)" == "NetBSD" ]]; then
|
||||
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
|
||||
else
|
||||
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
|
||||
fi
|
||||
fi
|
||||
|
||||
#setopt no_beep
|
||||
setopt auto_cd
|
||||
setopt multios
|
||||
|
|
@ -39,4 +27,3 @@ ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is c
|
|||
|
||||
# Setup the prompt with pretty colors
|
||||
setopt prompt_subst
|
||||
|
||||
|
|
|
|||
61
oh-my-zsh.sh
61
oh-my-zsh.sh
|
|
@ -1,12 +1,7 @@
|
|||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
|
||||
fi
|
||||
|
||||
# Initializes Oh My Zsh
|
||||
# Puppet Lair
|
||||
|
||||
# add a function path
|
||||
fpath=($ZSH/functions $ZSH/completions $fpath)
|
||||
fpath=($ZSH/functions $fpath)
|
||||
|
||||
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
||||
# TIP: Add files you don't want in git to .gitignore
|
||||
|
|
@ -14,13 +9,6 @@ for config_file ($ZSH/lib/*.zsh); do
|
|||
source $config_file
|
||||
done
|
||||
|
||||
# Set ZSH_CUSTOM to the path where your custom config files
|
||||
# and plugins exists, or else we will use the default custom/
|
||||
if [[ -z "$ZSH_CUSTOM" ]]; then
|
||||
ZSH_CUSTOM="$ZSH/custom"
|
||||
fi
|
||||
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
|
|
@ -30,9 +18,7 @@ is_plugin() {
|
|||
# Add all defined plugins to fpath. This must be done
|
||||
# before running compinit.
|
||||
for plugin ($plugins); do
|
||||
if is_plugin $ZSH_CUSTOM $plugin; then
|
||||
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
|
||||
elif is_plugin $ZSH $plugin; then
|
||||
if is_plugin $ZSH $plugin; then
|
||||
fpath=($ZSH/plugins/$plugin $fpath)
|
||||
fi
|
||||
done
|
||||
|
|
@ -53,36 +39,13 @@ autoload -U compinit
|
|||
compinit -i -d "${ZSH_COMPDUMP}"
|
||||
|
||||
# Load all of the plugins that were defined in ~/.zshrc
|
||||
for plugin ($plugins); do
|
||||
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
|
||||
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||
fi
|
||||
done
|
||||
# for plugin ($plugins); do
|
||||
# if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
# source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
|
||||
# elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
# source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||
# fi
|
||||
# done
|
||||
|
||||
# Load all of your custom configurations from custom/
|
||||
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
|
||||
source $config_file
|
||||
done
|
||||
unset config_file
|
||||
|
||||
# Load the theme
|
||||
if [ "$ZSH_THEME" = "random" ]; then
|
||||
themes=($ZSH/themes/*zsh-theme)
|
||||
N=${#themes[@]}
|
||||
((N=(RANDOM%N)+1))
|
||||
RANDOM_THEME=${themes[$N]}
|
||||
source "$RANDOM_THEME"
|
||||
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
||||
else
|
||||
if [ ! "$ZSH_THEME" = "" ]; then
|
||||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
|
||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
|
||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
||||
else
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# load theme
|
||||
test -f "$ZSH/themes/$THEME" && source "$ZSH/themes/$THEME"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ function atlas_usage {
|
|||
list show what host configs exist
|
||||
show show which config is linked
|
||||
|
||||
|
||||
USAGE
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ function atlas_map {
|
|||
}
|
||||
|
||||
function atlas_show {
|
||||
if [ -d "/Users/nstilwell/.hosts" ] && [ -e "/Users/nstilwell/.hosts/$1" ]; then
|
||||
if [ -d "/Users/nstilwell/.hosts" ] && [ -e "/Users/nstilwell/.hosts/" ]; then
|
||||
head -n 4 /etc/hosts;
|
||||
else
|
||||
echo "Atlas not initialized";
|
||||
|
|
@ -55,7 +54,7 @@ function atlas_show {
|
|||
}
|
||||
|
||||
function atlas_list {
|
||||
if [ -d "/Users/nstilwell/.hosts" ] && [ -e "/Users/nstilwell/.hosts/$1" ]; then
|
||||
if [ -d "/Users/nstilwell/.hosts" ] && [ -e "/Users/nstilwell/.hosts/" ]; then
|
||||
ls -F ~/.hosts | grep -v /$;
|
||||
else
|
||||
echo "Atlas not initialized";
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ function ace_prompt () {
|
|||
local spade="♤ ";
|
||||
local fill_spade="♠︎ ";
|
||||
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null);
|
||||
branch=${ref#refs/heads/};
|
||||
local ref=$(git symbolic-ref HEAD 2> /dev/null);
|
||||
local branch=${ref#refs/heads/};
|
||||
|
||||
if [[ ! -z $branch ]]; then
|
||||
if [[ $branch == "master" ]]; then
|
||||
|
|
@ -44,6 +44,8 @@ function ace_prompt () {
|
|||
unset prompt;
|
||||
unset red;
|
||||
unset blue;
|
||||
unset branch;
|
||||
unset ref;
|
||||
unset stop;
|
||||
}
|
||||
|
||||
|
|
@ -53,4 +55,3 @@ function directory () {
|
|||
|
||||
PROMPT=' $(ace_prompt) $(collapse_pwd)
|
||||
> '
|
||||
|
||||
|
|
@ -42,13 +42,10 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$BG[008]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
|||
#
|
||||
# Convert the home directory to "~"
|
||||
# (Courtesy of Mr. Steve Losh)
|
||||
#෴
|
||||
#
|
||||
|
||||
function collapse_pwd {
|
||||
echo $(pwd | sed -e "s,^$HOME,~,")
|
||||
}
|
||||
|
||||
#
|
||||
# Some Special Characters if you want to swap out the prompts
|
||||
# -----------------------------------------------------------
|
||||
# ✰ ✼ ✪ ✙ ♔ ♘ ♜ ♛ ♚ ♞ ♬ ⏀ ⌦ ⌘ ≫ ⇪ ☩ ☀ ☂ ★ ⚓ Ө β δ Σ Ω μ Δ ↪
|
||||
# ✰ ✼ ✪ ✙ ♔ ♘ ☩ ★
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
#
|
||||
# Available Color Options are :
|
||||
#
|
||||
# red, green, blue, cyan, magenta, yellow, white, black
|
||||
#
|
||||
# Reference to what stuff in the Prompt is:
|
||||
# %n = username
|
||||
# %~ = pwd
|
||||
# %m = machine name
|
||||
#
|
||||
|
||||
# $FG[025] - dark blue
|
||||
# $FG[050] - cyan
|
||||
# $FG[075] - light blue
|
||||
# $FG[100] - muddy yellow
|
||||
# $FG[125] - strawberry
|
||||
# $FG[145] - white
|
||||
|
||||
PROMPT='%{$BG[237]%}%{$fg[white]%} $(hostname) \
|
||||
%{$BG[008]%}%{$fg[white]%} $(collapse_pwd) \
|
||||
%{$BG[056]%}%{$fg[white]%}$(git_prompt_short_sha)\
|
||||
%{$BG[093]%}%{$fg[white]%}$(git_prompt_info)\
|
||||
%{$reset_color%}$(git_prompt_status)
|
||||
%{$reset_color%}> '
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" "
|
||||
ZSH_THEME_GIT_PROMPT_SHA_AFTER=" "
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ⑀ "
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$bg[yellow]%}%{$fg[black]%} ⸭ "
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[white]%} ☩ "
|
||||
|
||||
# RPROMPT='$(git_prompt_status) %{$reset_color%}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$BG[010]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$BG[012]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$BG[009]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$BG[011]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$BG[014]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$BG[008]%}%{$fg[black]%} ✰ %{$reset_color%}"
|
||||
|
||||
#
|
||||
# Convert the home directory to "~"
|
||||
# (Courtesy of Mr. Steve Losh)
|
||||
#෴
|
||||
|
||||
function collapse_pwd {
|
||||
echo $(pwd | sed -e "s,^$HOME,~,")
|
||||
}
|
||||
|
||||
#
|
||||
# Some Special Characters if you want to swap out the prompts
|
||||
# -----------------------------------------------------------
|
||||
# ✰ ✼ ✪ ✙ ♔ ♘ ♜ ♛ ♚ ♞ ♬ ⏀ ⌦ ⌘ ≫ ⇪ ☩ ☀ ☂ ★ ⚓ Ө β δ Σ Ω μ Δ ↪
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
function _current_epoch() {
|
||||
echo $(($(date +%s) / 60 / 60 / 24))
|
||||
}
|
||||
|
||||
function _update_zsh_update() {
|
||||
echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update
|
||||
}
|
||||
|
||||
function _upgrade_zsh() {
|
||||
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
|
||||
# update the zsh file
|
||||
_update_zsh_update
|
||||
}
|
||||
|
||||
epoch_target=$UPDATE_ZSH_DAYS
|
||||
if [[ -z "$epoch_target" ]]; then
|
||||
# Default to old behavior
|
||||
epoch_target=13
|
||||
fi
|
||||
|
||||
if [ -f ~/.zsh-update ]
|
||||
then
|
||||
. ~/.zsh-update
|
||||
|
||||
if [[ -z "$LAST_EPOCH" ]]; then
|
||||
_update_zsh_update && return 0;
|
||||
fi
|
||||
|
||||
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
||||
if [ $epoch_diff -gt $epoch_target ]
|
||||
then
|
||||
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]
|
||||
then
|
||||
_upgrade_zsh
|
||||
else
|
||||
echo "[Oh My Zsh] Would you like to check for updates?"
|
||||
echo "Type Y to update oh-my-zsh: \c"
|
||||
read line
|
||||
if [ "$line" = Y ] || [ "$line" = y ]; then
|
||||
_upgrade_zsh
|
||||
else
|
||||
_update_zsh_update
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# create the zsh file
|
||||
_update_zsh_update
|
||||
fi
|
||||
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
if [ -d ~/.oh-my-zsh ]
|
||||
then
|
||||
echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
|
||||
hash git >/dev/null && /usr/bin/env git clone git@github.com:nathanstilwell/oh-my-zsh.git ~/.oh-my-zsh || {
|
||||
echo "git not installed"
|
||||
exit
|
||||
}
|
||||
|
||||
echo "\033[0;34mLooking for an existing zsh config...\033[0m"
|
||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
|
||||
then
|
||||
echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m";
|
||||
mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
|
||||
fi
|
||||
|
||||
echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
|
||||
chsh -s `which zsh`
|
||||
|
||||
echo "\033[0;32m"' __ __ '"\033[0m"
|
||||
echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
|
||||
echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
|
||||
echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
|
||||
echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
|
||||
echo "\033[0;32m"' /____/ '"\033[0m"
|
||||
|
||||
echo "\n\n \033[0;32m....is now installed.\033[0m"
|
||||
/usr/bin/env zsh
|
||||
source ~/.zshrc
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
__require_tool_version_compare ()
|
||||
{
|
||||
(
|
||||
# Locally ignore failures, otherwise we'll exit whenever $1 and $2
|
||||
# are not equal!
|
||||
set +e
|
||||
|
||||
awk_strverscmp='
|
||||
# Use only awk features that work with 7th edition Unix awk (1978).
|
||||
# My, what an old awk you have, Mr. Solaris!
|
||||
END {
|
||||
while (length(v1) || length(v2)) {
|
||||
# Set d1 to be the next thing to compare from v1, and likewise for d2.
|
||||
# Normally this is a single character, but if v1 and v2 contain digits,
|
||||
# compare them as integers and fractions as strverscmp does.
|
||||
if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
|
||||
# Split v1 and v2 into their leading digit string components d1 and d2,
|
||||
# and advance v1 and v2 past the leading digit strings.
|
||||
for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
|
||||
for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
|
||||
d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
|
||||
d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
|
||||
if (d1 ~ /^0/) {
|
||||
if (d2 ~ /^0/) {
|
||||
# Compare two fractions.
|
||||
while (d1 ~ /^0/ && d2 ~ /^0/) {
|
||||
d1 = substr(d1, 2); len1--
|
||||
d2 = substr(d2, 2); len2--
|
||||
}
|
||||
if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
|
||||
# The two components differ in length, and the common prefix
|
||||
# contains only leading zeros. Consider the longer to be less.
|
||||
d1 = -len1
|
||||
d2 = -len2
|
||||
} else {
|
||||
# Otherwise, compare as strings.
|
||||
d1 = "x" d1
|
||||
d2 = "x" d2
|
||||
}
|
||||
} else {
|
||||
# A fraction is less than an integer.
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
if (d2 ~ /^0/) {
|
||||
# An integer is greater than a fraction.
|
||||
exit 2
|
||||
} else {
|
||||
# Compare two integers.
|
||||
d1 += 0
|
||||
d2 += 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# The normal case, without worrying about digits.
|
||||
if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) }
|
||||
if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) }
|
||||
}
|
||||
if (d1 < d2) exit 1
|
||||
if (d1 > d2) exit 2
|
||||
}
|
||||
}
|
||||
'
|
||||
awk "$awk_strverscmp" v1="$1" v2="$2" /dev/null
|
||||
case $? in
|
||||
1) echo '<';;
|
||||
0) echo '=';;
|
||||
2) echo '>';;
|
||||
esac
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
__require_tool_fatal ()
|
||||
{
|
||||
echo $@ >/dev/stderr
|
||||
return 1
|
||||
}
|
||||
|
||||
# Usage: require_tool program version
|
||||
# Returns: 0 if $1 version if greater equals than $2, 1 otherwise.
|
||||
# In case of error, message is written on error output.
|
||||
#
|
||||
# Example: require_tool gcc 4.6
|
||||
# Use GCC environment variable if defined instead of lookup for the tool
|
||||
# in the environment.
|
||||
require_tool ()
|
||||
{
|
||||
envvar_name=$(echo $1 | tr '[:lower:]' '[:upper:]')
|
||||
tool=$(printenv $envvar_name || echo $1)
|
||||
local version=$($tool --version 2>/dev/null| \
|
||||
sed -n 's/.*[^0-9.]\([0-9]*\.[0-9.]*\).*/\1/p;q')
|
||||
if test x"$version" = x ; then
|
||||
echo "$tool is required" >/dev/stderr
|
||||
return 1
|
||||
fi
|
||||
case $(__require_tool_version_compare "$2" "$version") in
|
||||
'>')
|
||||
echo "$1 $2 or better is required: this is $tool $version" >/dev/stderr
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
NAME
|
||||
require_tool.sh - Ensure version of a tool is greater than the one expected
|
||||
|
||||
SYNOPSYS
|
||||
require_tool.sh [ -h ]
|
||||
[ --help ]
|
||||
[ TOOL MIN_VERSION ]
|
||||
|
||||
DESCRIPTION
|
||||
TOOL is the name or path of the program to check. If the name is specified, its
|
||||
path is deduced from PATH environment variable. If environment variable TOOL
|
||||
(in upper-case characters) is defined, considers its value as path to the tool.
|
||||
|
||||
MIN_VERSION is a string representing the minimum required version.
|
||||
|
||||
BEHAVIOR
|
||||
* locate path to the program.
|
||||
* execute $ TOOL_PATH --version
|
||||
* extract version from standard output.
|
||||
* compare this version to the expected one.
|
||||
|
||||
OPTIONS
|
||||
-h --help
|
||||
Display this message and exit 0
|
||||
|
||||
ERRORS
|
||||
if program is not found or its version is prior to expected version,
|
||||
a message is written to error output.
|
||||
|
||||
EXIT VALUE
|
||||
returns 0 if program version if greater equals than expected version,
|
||||
returns 1 otherwise.
|
||||
|
||||
EXAMPLE
|
||||
$ require_tool.sh emacs 23
|
||||
$ CC=g++ require_tool.sh cc 4.6
|
||||
$ require_tool.sh zsh 4.5
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
for arg in $@; do
|
||||
case $arg in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ $# -gt 2 ] ; then
|
||||
echo "ERROR: expecting 2 parameters. Please see option --help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
require_tool $@
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
#!/bin/zsh
|
||||
|
||||
# Zsh Theme Chooser by fox (fox91 at anche dot no)
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
THEMES_DIR="$ZSH/themes"
|
||||
FAVLIST="${HOME}/.zsh_favlist"
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
function noyes() {
|
||||
read "a?$1 [y/N] "
|
||||
if [[ $a == "N" || $a == "n" || $a = "" ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function theme_preview() {
|
||||
THEME=$1
|
||||
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
||||
print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
|
||||
source "$THEMES_DIR/$THEME"
|
||||
cols=$(tput cols)
|
||||
print -P "$PROMPT $RPROMPT"
|
||||
}
|
||||
|
||||
function banner() {
|
||||
echo
|
||||
echo "[0;1;35;95m╺━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m╻[0m [0;1;36;96m╻[0m [0;1;35;95m╺┳[0;1;31;91m╸╻[0m [0;1;33;93m╻[0;1;32;92m┏━[0;1;36;96m╸┏[0;1;34;94m┳┓[0;1;35;95m┏━[0;1;31;91m╸[0m [0;1;32;92m┏━[0;1;36;96m╸╻[0m [0;1;34;94m╻[0;1;35;95m┏━[0;1;31;91m┓┏[0;1;33;93m━┓[0;1;32;92m┏━[0;1;36;96m┓┏[0;1;34;94m━╸[0;1;35;95m┏━[0;1;31;91m┓[0m"
|
||||
echo "[0;1;31;91m┏━[0;1;33;93m┛┗[0;1;32;92m━┓[0;1;36;96m┣━[0;1;34;94m┫[0m [0;1;31;91m┃[0m [0;1;33;93m┣[0;1;32;92m━┫[0;1;36;96m┣╸[0m [0;1;34;94m┃[0;1;35;95m┃┃[0;1;31;91m┣╸[0m [0;1;36;96m┃[0m [0;1;34;94m┣[0;1;35;95m━┫[0;1;31;91m┃[0m [0;1;33;93m┃┃[0m [0;1;32;92m┃[0;1;36;96m┗━[0;1;34;94m┓┣[0;1;35;95m╸[0m [0;1;31;91m┣┳[0;1;33;93m┛[0m"
|
||||
echo "[0;1;33;93m┗━[0;1;32;92m╸┗[0;1;36;96m━┛[0;1;34;94m╹[0m [0;1;35;95m╹[0m [0;1;33;93m╹[0m [0;1;32;92m╹[0m [0;1;36;96m╹[0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m╸[0m [0;1;34;94m┗━[0;1;35;95m╸╹[0m [0;1;31;91m╹[0;1;33;93m┗━[0;1;32;92m┛┗[0;1;36;96m━┛[0;1;34;94m┗━[0;1;35;95m┛┗[0;1;31;91m━╸[0;1;33;93m╹┗[0;1;32;92m╸[0m"
|
||||
echo
|
||||
}
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 [options] [theme]"
|
||||
echo
|
||||
echo "Options"
|
||||
echo " -l List available themes"
|
||||
echo " -s Show all themes"
|
||||
echo " -h Get this help message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function list_themes() {
|
||||
for THEME in $(ls $THEMES_DIR); do
|
||||
THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
|
||||
echo $THEME_NAME
|
||||
done
|
||||
}
|
||||
|
||||
function insert_favlist() {
|
||||
if grep -q "$THEME_NAME" $FAVLIST 2> /dev/null ; then
|
||||
echo "Already in favlist"
|
||||
else
|
||||
echo $THEME_NAME >> $FAVLIST
|
||||
echo "Saved to favlist"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function theme_chooser() {
|
||||
for THEME in $(ls $THEMES_DIR); do
|
||||
echo
|
||||
theme_preview $THEME
|
||||
echo
|
||||
if [[ -z $1 ]]; then
|
||||
noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
|
||||
insert_favlist $THEME_NAME
|
||||
echo
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while getopts ":lhs" Option
|
||||
do
|
||||
case $Option in
|
||||
l ) list_themes ;;
|
||||
s ) theme_chooser 0 ;;
|
||||
h ) usage ;;
|
||||
* ) usage ;; # Default.
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $Option ]]; then
|
||||
if [[ -z $1 ]]; then
|
||||
banner
|
||||
echo
|
||||
theme_chooser
|
||||
else
|
||||
theme_preview $1".zsh-theme"
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
echo "Removing ~/.oh-my-zsh"
|
||||
if [[ -d ~/.oh-my-zsh ]]
|
||||
then
|
||||
rm -rf ~/.oh-my-zsh
|
||||
fi
|
||||
|
||||
echo "Looking for original zsh config..."
|
||||
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
|
||||
then
|
||||
echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";
|
||||
|
||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
|
||||
then
|
||||
ZSHRC_SAVE=".zshrc.omz-uninstalled-`date +%Y%m%d%H%M%S`";
|
||||
echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
|
||||
mv ~/.zshrc ~/${ZSHRC_SAVE};
|
||||
fi
|
||||
|
||||
mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
|
||||
|
||||
source ~/.zshrc;
|
||||
else
|
||||
echo "Switching back to bash"
|
||||
chsh -s /bin/bash
|
||||
source /etc/profile
|
||||
fi
|
||||
|
||||
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
|
||||
cd "$ZSH"
|
||||
if git pull --rebase origin master
|
||||
then
|
||||
printf '\033[0;32m%s\033[0m\n' ' __ __ '
|
||||
printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||
printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
|
||||
printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
|
||||
printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
|
||||
printf '\033[0;32m%s\033[0m\n' ' /____/ '
|
||||
printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
|
||||
printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh'
|
||||
else
|
||||
printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue