From 9590b96b3f0dc8e2f4a87b632ff59eab28a0081e Mon Sep 17 00:00:00 2001 From: Adam Luikart Date: Mon, 6 Feb 2012 12:22:07 -0600 Subject: Write the update file even if `CLOBBER` is unset. --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 0f8c9c391..5c8ce3a50 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -5,7 +5,7 @@ function _current_epoch() { } function _update_zsh_update() { - echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update + echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update } function _upgrade_zsh() { -- cgit v1.2.3-70-g09d2 From 8d976e02b1da43ec74c1ca6f50584eed566ff73a Mon Sep 17 00:00:00 2001 From: Mark Feltner Date: Tue, 14 Jan 2014 23:13:49 -0600 Subject: fix(tools/check_for_upgrade): Don't source profile Reverts #2296, but mostly #1883. There is no need to source ~/.profile when this script is read. oh-my-zsh writes no configuration data in ~/.profile. If the user wishes to use data within ~/.profile, then they should source it in another place. Fixes #2315 --- tools/check_for_upgrade.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 5c8ce3a50..c5fd0cce1 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -20,8 +20,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -[ -f ~/.profile ] && source ~/.profile - if [ -f ~/.zsh-update ] then . ~/.zsh-update -- cgit v1.2.3-70-g09d2 From a9e1d9aa890c18ea3c3250442e7d9de555633237 Mon Sep 17 00:00:00 2001 From: "n.st" Date: Wed, 4 Jun 2014 19:26:46 +0200 Subject: Cancel upgrade if $ZSH is not writable from #2360 --- tools/check_for_upgrade.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index c5fd0cce1..8b8ecae03 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -20,6 +20,12 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi +[ -f ~/.profile ] && source ~/.profile + +# Cancel upgrade if the current user doesn't have write permissions for the +# oh-my-zsh directory. +[[ -w "$ZSH" ]] || return 0 + if [ -f ~/.zsh-update ] then . ~/.zsh-update -- cgit v1.2.3-70-g09d2 From 5e328e3a9c0784521ae4170f7958183c352bae83 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Fri, 11 Jul 2014 18:41:49 +0530 Subject: Solaris portability tweaks. --- lib/completion.zsh | 7 ++++++- oh-my-zsh.sh | 1 + plugins/colored-man/colored-man.plugin.zsh | 21 +++++++++++++++++++++ tools/check_for_upgrade.sh | 8 +++++++- 4 files changed, 35 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/lib/completion.zsh b/lib/completion.zsh index fa1d97f48..faea36118 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,12 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +if [ "$PLAT" = "SunOS" ] +then + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" +else + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +fi # disable named-directories autocompletion zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91bb..4683c2bc0 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,3 +1,4 @@ +PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 56056284a..4956f4346 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,3 +1,21 @@ +if [ "${PLAT}" = "SunOS" ] +then + if [ ! -x ${HOME}/bin/nroff ] + then + mkdir -p ${HOME}/bin + cat > ${HOME}/bin/nroff < Date: Wed, 20 Aug 2014 23:52:05 +0200 Subject: Replace /usr/bin/env with env Some environments (such as Android) does not have /usr/bin. --- lib/functions.zsh | 4 ++-- oh-my-zsh.sh | 2 +- tools/check_for_upgrade.sh | 2 +- tools/install.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/lib/functions.zsh b/lib/functions.zsh index fda84a953..17f5f9cbf 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -3,11 +3,11 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh + 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 + env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh } function take() { diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91bb..a90b3e98a 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,6 @@ # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh + env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 8b8ecae03..35e074297 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -9,7 +9,7 @@ function _update_zsh_update() { } function _upgrade_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh # update the zsh file _update_zsh_update } diff --git a/tools/install.sh b/tools/install.sh index fc7ad70cf..7efab10b9 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -10,7 +10,7 @@ if [ -d "$ZSH" ]; then fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null 2>&1 && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { +hash git >/dev/null 2>&1 && env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" exit } @@ -43,5 +43,5 @@ echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" -/usr/bin/env zsh +env zsh . ~/.zshrc -- cgit v1.2.3-70-g09d2 From 91ba6d98875c70d0736fd3eecd0ee4aae52cdc74 Mon Sep 17 00:00:00 2001 From: Mathieu Comandon Date: Thu, 21 Aug 2014 12:47:48 +0200 Subject: Don't try running chsh if user already runs zsh --- tools/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/install.sh b/tools/install.sh index fc7ad70cf..fc0a9fa64 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -32,8 +32,10 @@ sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc -echo "\033[0;34mTime to change your default shell to zsh!\033[0m" -chsh -s `which zsh` +if [ "$SHELL" != "$(which zsh)" ]; then + echo "\033[0;34mTime to change your default shell to zsh!\033[0m" + chsh -s `which zsh` +fi echo "\033[0;32m"' __ __ '"\033[0m" echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" -- cgit v1.2.3-70-g09d2 From 9f8d7d85c2cacce54a5839d90b93e90b22228624 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 31 Aug 2014 11:30:30 -0700 Subject: Adding link to the store for swag in upgrade process --- tools/upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 9a8497d96..5f0a81f1d 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -9,8 +9,8 @@ then 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' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' fi - -- cgit v1.2.3-70-g09d2 From 671bd0cf4f0face60883a2b476e75e6364d0154e Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 31 Aug 2014 11:32:07 -0700 Subject: Link to swag in installer... shameless profiting --- tools/install.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/install.sh b/tools/install.sh index 7efab10b9..3ff897a01 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -43,5 +43,6 @@ echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" +echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m" env zsh . ~/.zshrc -- cgit v1.2.3-70-g09d2 From 5f38a537cef0d79c9d53c01e8f88d150e985c70a Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 16 Sep 2014 22:29:52 +0530 Subject: Update Solaris changes to use OSTYPE and zsh datetime module. --- lib/completion.zsh | 2 +- oh-my-zsh.sh | 1 - plugins/colored-man/colored-man.plugin.zsh | 2 +- tools/check_for_upgrade.sh | 12 ++++-------- 4 files changed, 6 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/lib/completion.zsh b/lib/completion.zsh index faea36118..83b6efb66 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,7 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$PLAT" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" else diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 4683c2bc0..c217b91bb 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,4 +1,3 @@ -PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 4956f4346..5c613f49d 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,4 +1,4 @@ -if [ "${PLAT}" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then if [ ! -x ${HOME}/bin/nroff ] then diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1aba9a272..0e8845ab4 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -1,13 +1,9 @@ -#!/bin/sh +#!/usr/bin/env zsh + +zmodload zsh/datetime -PLAT=`uname -s` function _current_epoch() { - if [ "$PLAT" = "SunOS" ] - then - echo $(($(perl -e 'print time') / 60 / 60 / 24)) - else - echo $(($(date +%s) / 60 / 60 / 24)) - fi + echo $EPOCHSECONDS } function _update_zsh_update() { -- cgit v1.2.3-70-g09d2 From 90762eee49efcdfd6b92ad5d5d9e5f43d113ae0b Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 17 Sep 2014 11:11:48 +0530 Subject: Convert epoch_target from days to seconds. --- tools/check_for_upgrade.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 0e8845ab4..f49bb151f 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -22,6 +22,8 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi +epoch_target_seconds=$((epoch_target * 86400)) + [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -37,7 +39,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] + if [ $epoch_diff -gt $epoch_target_seconds ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then -- cgit v1.2.3-70-g09d2 From 3a3973284534c318e2cb987a0db1121302d04e10 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 14 Oct 2014 12:05:01 +0530 Subject: Change to epoch target in days instead of seconds. --- tools/check_for_upgrade.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index f49bb151f..a8ba4820c 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -3,7 +3,7 @@ zmodload zsh/datetime function _current_epoch() { - echo $EPOCHSECONDS + echo $(( $EPOCHSECONDS / 60 / 60 / 24 )) } function _update_zsh_update() { @@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -epoch_target_seconds=$((epoch_target * 86400)) - [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -39,7 +37,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target_seconds ] + if [ $epoch_diff -gt $epoch_target ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then -- cgit v1.2.3-70-g09d2 From c6a8b2ea6d80e33716ce5590f4c4aff96776f06e Mon Sep 17 00:00:00 2001 From: mizabrik Date: Fri, 28 Nov 2014 19:40:56 +0300 Subject: Save ZSH path in newly created .zshrc --- tools/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/install.sh b/tools/install.sh index a53ac48ab..35548005a 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -23,8 +23,8 @@ fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc -sed -i -e "/^ZSH=/ c\\ -ZSH=$ZSH +sed -i -e "/^export ZSH=/ c\\ +export ZSH=$ZSH " ~/.zshrc echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" -- cgit v1.2.3-70-g09d2 From 83553597a1430e2f3459de74de1cf33ae4ce67be Mon Sep 17 00:00:00 2001 From: Mark Feltner Date: Tue, 14 Jan 2014 23:13:49 -0600 Subject: fix(tools/check_for_upgrade): Don't source profile Reverts #2296, but mostly #1883. There is no need to source ~/.profile when this script is read. oh-my-zsh writes no configuration data in ~/.profile. If the user wishes to use data within ~/.profile, then they should source it in another place. Fixes #2315 --- tools/check_for_upgrade.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 4a0803210..b2b356e0c 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -[ -f ~/.profile ] && source ~/.profile - # Cancel upgrade if the current user doesn't have write permissions for the # oh-my-zsh directory. [[ -w "$ZSH" ]] || return 0 -- cgit v1.2.3-70-g09d2 From 5cb0ed98d1e5f0119e7871e21948a6b931f14a78 Mon Sep 17 00:00:00 2001 From: "Nicholas T." Date: Thu, 15 Jan 2015 09:09:41 +1000 Subject: Fast installation time by shallow copying git repo Use `--depth=1` to clone just the lastest version rather than every version in git. --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/install.sh b/tools/install.sh index a53ac48ab..69213d4a3 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -10,7 +10,7 @@ if [ -d "$ZSH" ]; then fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null 2>&1 && env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { +hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" exit } -- cgit v1.2.3-70-g09d2 From 03b8c199e591de73de3824fc6b366138964c1ba6 Mon Sep 17 00:00:00 2001 From: Pablo Tamarit Date: Tue, 5 May 2015 19:49:19 +0200 Subject: Fix 'chsh' by checking '/etc/shells' instead of using 'which' fix test for chsh in install in case $SHELL is zsh but not the last one in /etc/shells fixes #3026 fixes #3779 fixes #3780 --- tools/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/install.sh b/tools/install.sh index bd4c55749..c83a6f23d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -32,10 +32,12 @@ sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc -if [ "$SHELL" != "$(which zsh)" ]; then +TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') +if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then echo "\033[0;34mTime to change your default shell to zsh!\033[0m" - chsh -s `which zsh` + chsh -s $(grep /zsh$ /etc/shells | tail -1) fi +unset TEST_CURRENT_SHELL echo "\033[0;32m"' __ __ '"\033[0m" echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" -- cgit v1.2.3-70-g09d2 From 6a1b8320fe9f087179c9ebf092bd17a782127d96 Mon Sep 17 00:00:00 2001 From: HeroCC Date: Mon, 20 Apr 2015 11:24:05 -0400 Subject: No input for Update Check defaults to Yes --- tools/check_for_upgrade.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index b2b356e0c..5afd83c1e 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -41,10 +41,9 @@ then then _upgrade_zsh else - echo "[Oh My Zsh] Would you like to check for updates?" - echo "Type Y to update oh-my-zsh: \c" + echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c" read line - if [ "$line" = Y ] || [ "$line" = y ]; then + if [ "$line" = Y ] || [ "$line" = y ] || [ -z "$line" ]; then _upgrade_zsh else _update_zsh_update -- cgit v1.2.3-70-g09d2