mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Merge dd29f4b4a2 into 167f84dacd
This commit is contained in:
commit
b795b786b7
5 changed files with 131 additions and 47 deletions
10
tools/check_for_upgrade.sh
Normal file → Executable file
10
tools/check_for_upgrade.sh
Normal file → Executable file
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
source ./common
|
||||||
|
|
||||||
function _current_epoch() {
|
function _current_epoch() {
|
||||||
echo $(($(date +%s) / 60 / 60 / 24))
|
echo $(($(date +%s) / 60 / 60 / 24))
|
||||||
}
|
}
|
||||||
|
|
@ -19,15 +21,17 @@ then
|
||||||
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
||||||
if [ $epoch_diff -gt 6 ]
|
if [ $epoch_diff -gt 6 ]
|
||||||
then
|
then
|
||||||
echo "[Oh My Zsh] Would you like to check for updates?"
|
note '[Oh My Zsh] Would you like to check for updates?'
|
||||||
echo "Type Y to update oh-my-zsh: \c"
|
query 'Type Y to update oh-my-zsh:'
|
||||||
read line
|
read line
|
||||||
if [ "$line" = Y ] || [ "$line" = y ]
|
if [ "$line" = Y ] || [ "$line" = y ]
|
||||||
then
|
then
|
||||||
/bin/sh $ZSH/tools/upgrade.sh
|
./upgrade.sh
|
||||||
# update the zsh file
|
# update the zsh file
|
||||||
_update_zsh_update
|
_update_zsh_update
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
proclaim 'Updated recently.'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# create the zsh file
|
# create the zsh file
|
||||||
|
|
|
||||||
30
tools/common
Normal file
30
tools/common
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
COLOR_DEFAULT='\033[0m'
|
||||||
|
COLOR_LIGHTRED='\033[1;31m'
|
||||||
|
COLOR_GREEN='\033[0;32m'
|
||||||
|
COLOR_LIGHTGREEN='\033[1;32m'
|
||||||
|
COLOR_BROWN='\033[0;33m'
|
||||||
|
COLOR_PINK='\033[1;35m'
|
||||||
|
COLOR_YELLOW='\033[1;33m'
|
||||||
|
COLOR_WHITE='\033[1;37m'
|
||||||
|
|
||||||
|
function echo_color {
|
||||||
|
for i in "${@:3}"
|
||||||
|
do
|
||||||
|
eval printf "\$COLOR_${1}"
|
||||||
|
printf "$2$i\n"
|
||||||
|
done
|
||||||
|
printf $COLOR_DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
|
function query { echo_color 'BROWN' ' ' "$@"; printf ' > '; }
|
||||||
|
function text { echo_color 'WHITE' '' "$@"; }
|
||||||
|
function proclaim { echo_color 'PINK' \ "$@"; }
|
||||||
|
function info { echo_color 'BROWN' \ "$@"; }
|
||||||
|
function note { echo_color 'YELLOW' \ "$@"; }
|
||||||
|
function shell_example {
|
||||||
|
printf '\n';
|
||||||
|
echo_color 'LIGHTGREEN' "\t>${COLOR_GREEN} " "$@"
|
||||||
|
printf '\n'
|
||||||
|
}
|
||||||
|
function warn { echo_color 'LIGHTRED' \ "$@"; }
|
||||||
|
|
||||||
|
|
@ -1,36 +1,47 @@
|
||||||
|
|
||||||
|
################
|
||||||
|
# install.sh #
|
||||||
|
################
|
||||||
|
|
||||||
|
source ./common
|
||||||
|
|
||||||
if [ -d ~/.oh-my-zsh ]
|
if [ -d ~/.oh-my-zsh ]
|
||||||
then
|
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"
|
proclaim 'You already have Oh My Zsh installed'
|
||||||
exit
|
note 'You\47ll need to remove ~/.oh-my-zsh if you want to install'
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
|
proclaim 'Installing Oh-My-Zsh'
|
||||||
/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
|
info 'Cloning Oh My Zsh...'
|
||||||
|
/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh \
|
||||||
|
|| ( warn 'Couldn\47t clone repository.'; exit 2)
|
||||||
|
|
||||||
echo "\033[0;34mLooking for an existing zsh config...\033[0m"
|
info 'Looking for an existing zsh config...'
|
||||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
|
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
|
||||||
then
|
then
|
||||||
echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m";
|
info 'Found ~/.zshrc.'
|
||||||
cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
|
info 'Backing up to ~/.zshrc.pre-oh-my-zsh'
|
||||||
rm ~/.zshrc;
|
cp -n ~/.zshrc ~/.zshrc.pre-oh-my-zsh && rm ~/.zshrc \
|
||||||
|
|| ( warn 'Couldn\47t backup .zshrc!'; exit 3)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
|
info 'Using the Oh My Zsh template file and adding it to ~/.zshrc'
|
||||||
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
cp -n ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc || exit 4
|
||||||
|
|
||||||
echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
|
info 'Copying your current PATH and adding it to the end of ~/.zshrc for you.'
|
||||||
echo "export PATH=$PATH" >> ~/.zshrc
|
echo "export PATH=$PATH" >> ~/.zshrc
|
||||||
|
|
||||||
echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
|
note 'You might need to change your default shell to zsh:'
|
||||||
chsh -s `which zsh`
|
shell_example 'chsh -s $(which zsh)'
|
||||||
|
|
||||||
echo "\033[0;32m"' __ __ '"\033[0m"
|
proclaim ' __ __ '
|
||||||
echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
|
proclaim ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||||
echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
|
proclaim ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
|
||||||
echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
|
proclaim '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
|
||||||
echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
|
proclaim '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
|
||||||
echo "\033[0;32m"' /____/ '"\033[0m"
|
proclaim ' /____/ '
|
||||||
|
proclaim ' is now installed.'
|
||||||
|
|
||||||
|
/usr/bin/env zsh && source ~/.zshrc;
|
||||||
|
|
||||||
echo "\n\n \033[0;32m....is now installed.\033[0m"
|
|
||||||
/usr/bin/env zsh
|
|
||||||
source ~/.zshrc
|
|
||||||
|
|
|
||||||
45
tools/uninstall.sh
Normal file → Executable file
45
tools/uninstall.sh
Normal file → Executable file
|
|
@ -1,20 +1,41 @@
|
||||||
echo "Removing ~/.oh-my-zsh"
|
|
||||||
if [[ -d ~/.oh-my-zsh ]]
|
##################
|
||||||
then
|
# uninstall.sh #
|
||||||
rm -rf ~/.oh-my-zsh
|
##################
|
||||||
|
|
||||||
|
source ./common
|
||||||
|
proclaim 'Uninstalling Oh-My-Zsh'
|
||||||
|
|
||||||
|
if [[ -d ~/.oh-my-zsh ]]; then
|
||||||
|
changes=`diff --unchanged-group-format='' --suppress-common-lines ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc`
|
||||||
|
changes=`echo "$changes" | grep -v "^export PATH=$PATH$"`
|
||||||
|
if [ ! -z "$changes" ]; then
|
||||||
|
info 'Appending changes to ~/.zshrc to ~/.zshrc.changes:'
|
||||||
|
text "$changes"
|
||||||
|
echo "$changes" >> ~/.zshrc.changes \
|
||||||
|
|| ( warn 'Cannot append to ~/.zshrc.changes!'; exit 1 )
|
||||||
|
fi
|
||||||
|
info 'Removing ~/.zshrc'
|
||||||
|
rm ~/.zshrc
|
||||||
|
info 'Removing ~/.oh-my-zsh'
|
||||||
|
rm -rf ~/.oh-my-zsh;
|
||||||
|
else
|
||||||
|
warn 'Cannot find ~/.oh-my-zsh'
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Looking for an existing zsh config..."
|
|
||||||
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
|
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
|
||||||
then
|
then
|
||||||
echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh";
|
info 'Found ~/.zshrc.pre-oh-my-zsh, Restoring to ~/.zshrc'
|
||||||
rm ~/.zshrc;
|
mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc \
|
||||||
cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
|
|| ( warn 'Cannot restore ~/.zshrc!'; exit 3 )
|
||||||
source ~/.zshrc;
|
source ~/.zshrc;
|
||||||
else
|
else
|
||||||
echo "Switching back to bash"
|
note 'You might want to switch back to bash:'
|
||||||
chsh -s /bin/bash
|
shell_example \
|
||||||
source /etc/profile
|
'chsh -s /bin/bash' \
|
||||||
|
'source /etc/profile'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
proclaim 'Thanks for trying out \47Oh My Zsh\47, It is no longer installed'
|
||||||
|
|
||||||
|
|
|
||||||
38
tools/upgrade.sh
Normal file → Executable file
38
tools/upgrade.sh
Normal file → Executable file
|
|
@ -1,12 +1,30 @@
|
||||||
|
|
||||||
|
source ./common
|
||||||
|
|
||||||
|
if [ ! -d ~/.oh-my-zsh ]; then
|
||||||
|
warn 'Cannot find ~/.oh-my-zsh'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
proclaim 'Upgrading Oh My Zsh'
|
||||||
|
|
||||||
|
# I think pushd/popd might be cleaner,
|
||||||
|
# but more of a risk if they are over-ridden?
|
||||||
current_path=`pwd`
|
current_path=`pwd`
|
||||||
echo -e "\033[0;34mUpgrading Oh My Zsh\033[0m"
|
|
||||||
( cd $ZSH && git pull origin master )
|
# Is there a better way to ensure $ZSH is passed?
|
||||||
echo -e "\033[0;32m"' __ __ '"\033[0m"
|
cd "${ZSH:-$HOME/.oh-my-zsh}" \
|
||||||
echo -e "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
|
&& git pull origin master \
|
||||||
echo -e "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
|
|| ( warn 'Cannot upgrade Zsh!'; cd "$current_path"; exit 1 )
|
||||||
echo -e "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
|
|
||||||
echo -e "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
|
proclaim ' __ __ '
|
||||||
echo -e "\033[0;32m"' /____/ '"\033[0m"
|
proclaim ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||||
echo -e "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m"
|
proclaim ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
|
||||||
echo -e "\033[0;34mTo keep up on the latest, be sure to follow Oh My Zsh on twitter: \033[1mhttp://twitter.com/ohmyzsh\033[0m"
|
proclaim '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
|
||||||
|
proclaim '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
|
||||||
|
proclaim ' /____/ '
|
||||||
|
proclaim 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
|
||||||
|
proclaim 'To keep up on the latest, be sure to follow Oh My Zsh on twitter:'
|
||||||
|
proclaim "${COLOR_WHITE}http://twitter.com/ohmyzsh"
|
||||||
|
|
||||||
cd "$current_path"
|
cd "$current_path"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue