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
|
||||
|
||||
source ./common
|
||||
|
||||
function _current_epoch() {
|
||||
echo $(($(date +%s) / 60 / 60 / 24))
|
||||
}
|
||||
|
|
@ -19,15 +21,17 @@ then
|
|||
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
||||
if [ $epoch_diff -gt 6 ]
|
||||
then
|
||||
echo "[Oh My Zsh] Would you like to check for updates?"
|
||||
echo "Type Y to update oh-my-zsh: \c"
|
||||
note '[Oh My Zsh] Would you like to check for updates?'
|
||||
query 'Type Y to update oh-my-zsh:'
|
||||
read line
|
||||
if [ "$line" = Y ] || [ "$line" = y ]
|
||||
then
|
||||
/bin/sh $ZSH/tools/upgrade.sh
|
||||
./upgrade.sh
|
||||
# update the zsh file
|
||||
_update_zsh_update
|
||||
fi
|
||||
else
|
||||
proclaim 'Updated recently.'
|
||||
fi
|
||||
else
|
||||
# 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 ]
|
||||
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
|
||||
proclaim 'You already have Oh My Zsh installed'
|
||||
note 'You\47ll need to remove ~/.oh-my-zsh if you want to install'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "\033[0;34mCloning Oh My Zsh...\033[0m"
|
||||
/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
|
||||
proclaim 'Installing 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 ]
|
||||
then
|
||||
echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m";
|
||||
cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
|
||||
rm ~/.zshrc;
|
||||
info 'Found ~/.zshrc.'
|
||||
info 'Backing up to ~/.zshrc.pre-oh-my-zsh'
|
||||
cp -n ~/.zshrc ~/.zshrc.pre-oh-my-zsh && rm ~/.zshrc \
|
||||
|| ( warn 'Couldn\47t backup .zshrc!'; exit 3)
|
||||
fi
|
||||
|
||||
echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
|
||||
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
||||
info 'Using the Oh My Zsh template file and adding it to ~/.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 "\033[0;34mTime to change your default shell to zsh!\033[0m"
|
||||
chsh -s `which zsh`
|
||||
note 'You might need to change your default shell to zsh:'
|
||||
shell_example '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"
|
||||
proclaim ' __ __ '
|
||||
proclaim ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||
proclaim ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
|
||||
proclaim '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '
|
||||
proclaim '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '
|
||||
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
|
||||
rm -rf ~/.oh-my-zsh
|
||||
|
||||
##################
|
||||
# uninstall.sh #
|
||||
##################
|
||||
|
||||
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
|
||||
|
||||
echo "Looking for an existing zsh config..."
|
||||
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]
|
||||
then
|
||||
echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh";
|
||||
rm ~/.zshrc;
|
||||
cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc;
|
||||
info 'Found ~/.zshrc.pre-oh-my-zsh, Restoring to ~/.zshrc'
|
||||
mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc \
|
||||
|| ( warn 'Cannot restore ~/.zshrc!'; exit 3 )
|
||||
source ~/.zshrc;
|
||||
else
|
||||
echo "Switching back to bash"
|
||||
chsh -s /bin/bash
|
||||
source /etc/profile
|
||||
note 'You might want to switch back to bash:'
|
||||
shell_example \
|
||||
'chsh -s /bin/bash' \
|
||||
'source /etc/profile'
|
||||
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`
|
||||
echo -e "\033[0;34mUpgrading Oh My Zsh\033[0m"
|
||||
( cd $ZSH && git pull origin master )
|
||||
echo -e "\033[0;32m"' __ __ '"\033[0m"
|
||||
echo -e "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
|
||||
echo -e "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
|
||||
echo -e "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
|
||||
echo -e "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
|
||||
echo -e "\033[0;32m"' /____/ '"\033[0m"
|
||||
echo -e "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m"
|
||||
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"
|
||||
|
||||
# Is there a better way to ensure $ZSH is passed?
|
||||
cd "${ZSH:-$HOME/.oh-my-zsh}" \
|
||||
&& git pull origin master \
|
||||
|| ( warn 'Cannot upgrade Zsh!'; cd "$current_path"; exit 1 )
|
||||
|
||||
proclaim ' __ __ '
|
||||
proclaim ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||
proclaim ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
|
||||
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"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue