Qurxin is Termux banner or interface with parroto os shell and Wellcome robot like Jarvis in Iron Man movie created with love 16-oct-2020
apt update && upgrade -y
pkg install git python mpv figlet -y
pip install lolcat
git clone https://github.com/robyivanov/qurxin_ua
cd qurxin_ua
chmod +x *
sh install.sh
exit
apt update && upgrade -y && apt install git -y && pkg install mpv figlet python && pip install lolcat && git clone https://github.com/robyivanov/qurxin_ua && cd qurxin_ua && chmod +x * && ./install.sh
cd qurxin_ua
bash rvt.sh
#!/bin/sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
OVERWRITE_CONFIRMATION - 'no' means the installer will not ask for confirmation to overwrite the existing .zshrc (default: yes)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
set -e
USER=${USER:-$(id -u -n)}
HOME="${HOME:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
HOME="${HOME:-$(eval echo ~$USER)}"
custom_zsh=${ZSH:+yes}
zdot="${ZDOTDIR:-$HOME}"
if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then ZSH="${ZSH:-$ZDOTDIR/ohmyzsh}" fi ZSH="${ZSH:-$HOME/.oh-my-zsh}"
REPO=${REPO:-ohmyzsh/ohmyzsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-master}
CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} KEEP_ZSHRC=${KEEP_ZSHRC:-no} OVERWRITE_CONFIRMATION=${OVERWRITE_CONFIRMATION:-yes}
command_exists() { command -v "$@" >/dev/null 2>&1 }
user_can_sudo() {
command_exists sudo || return 1
case "$PREFIX" in com.termux) return 1 ;; esac
! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo" }
if [ -t 1 ]; then is_tty() { true } else is_tty() { false } fi
supports_hyperlinks() {
if [ -n "$FORCE_HYPERLINK" ]; then [ "$FORCE_HYPERLINK" != 0 ] return $? fi
is_tty || return 1
if [ -n "$DOMTERM" ]; then return 0 fi
if [ -n "$VTE_VERSION" ]; then
[
case "$TERM_PROGRAM" in Hyper|iTerm.app|terminology|WezTerm|vscode) return 0 ;; esac
case "$TERM" in xterm-kitty|alacritty|alacritty-direct) return 0 ;; esac
if [ "$COLORTERM" = "xfce4-terminal" ]; then return 0 fi
if [ -n "$WT_SESSION" ]; then return 0 fi
return 1 }
supports_truecolor() { case "$COLORTERM" in truecolor|24bit) return 0 ;; esac
case "$TERM" in
iterm |
tmux-truecolor |
linux-truecolor |
xterm-truecolor |
screen-truecolor) return 0 ;;
esac
return 1 }
fmt_link() {
if supports_hyperlinks; then printf '\033]8;;%s\033\%s\033]8;;\033\\n' "$2" "$1" return fi
case "$3" in --text) printf '%s\n' "$1" ;; --url|*) fmt_underline "$2" ;; esac }
fmt_underline() { is_tty && printf '\033[4m%s\033[24m\n' "$" || printf '%s\n' "$" }
fmt_code() {
is_tty && printf '\033[2m%s\033[22m\n' "$" || printf '%s\n' "$"
}
fmt_error() { printf '%sError: %s%s\n' "${FMT_BOLD}${FMT_RED}" "$*" "$FMT_RESET" >&2 }
setup_color() {
if ! is_tty; then FMT_RAINBOW="" FMT_RED="" FMT_GREEN="" FMT_YELLOW="" FMT_BLUE="" FMT_BOLD="" FMT_RESET="" return fi
if supports_truecolor; then
FMT_RAINBOW="
FMT_RED=$(printf '\033[31m') FMT_GREEN=$(printf '\033[32m') FMT_YELLOW=$(printf '\033[33m') FMT_BLUE=$(printf '\033[34m') FMT_BOLD=$(printf '\033[1m') FMT_RESET=$(printf '\033[0m') }
setup_ohmyzsh() {
umask g-w,o-w
echo "${FMT_BLUE}Cloning Oh My Zsh...${FMT_RESET}"
command_exists git || { fmt_error "git is not installed" exit 1 }
ostype=$(uname) if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -Eq 'msysgit|windows'; then fmt_error "Windows/MSYS Git is not supported on Cygwin" fmt_error "Make sure the Cygwin git package is installed and is first on the $PATH" exit 1 fi
git init --quiet "$ZSH" && cd "$ZSH"
&& git config core.eol lf
&& git config core.autocrlf false
&& git config fsck.zeroPaddedFilemode ignore
&& git config fetch.fsck.zeroPaddedFilemode ignore
&& git config receive.fsck.zeroPaddedFilemode ignore
&& git config oh-my-zsh.remote origin
&& git config oh-my-zsh.branch "$BRANCH"
&& git remote add origin "$REMOTE"
&& git fetch --depth=1 origin
&& git checkout -b "$BRANCH" "origin/$BRANCH" || {
[ ! -d "$ZSH" ] || {
cd -
rm -rf "$ZSH" 2>/dev/null
}
fmt_error "git clone of oh-my-zsh repo failed"
exit 1
}
cd -
echo }
setup_zshrc() {
echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}"
OLD_ZSHRC="$zdot/.zshrc.pre-oh-my-zsh" if [ -f "$zdot/.zshrc" ] || [ -h "$zdot/.zshrc" ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ "$KEEP_ZSHRC" = yes ]; then echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}" return fi
if [ $OVERWRITE_CONFIRMATION != "no" ]; then
# Ask user for confirmation before backing up and overwriting
echo "${FMT_YELLOW}Found ${zdot}/.zshrc."
echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten."
echo "Make sure your .zshrc contains the following minimal configuration if you choose not to overwrite it:${FMT_RESET}"
echo "----------------------------------------"
cat "$ZSH/templates/minimal.zshrc"
echo "----------------------------------------"
printf '%sDo you want to overwrite it with the Oh My Zsh template? [Y/n]%s ' \
"$FMT_YELLOW" "$FMT_RESET"
read -r opt
case $opt in
[Yy]*|"") ;;
[Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;;
*) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;;
esac
fi
if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then
fmt_error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
fmt_error "re-run the installer again in a couple of seconds"
exit 1
fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \
"${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}"
fi
echo "${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
mv "$zdot/.zshrc" "$OLD_ZSHRC"
fi
echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to
omz="$ZSH" if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|$ZDOTDIR/|") fi omz=$(echo "$omz" | sed "s|^$HOME/|$HOME/|")
sed "s|^export ZSH=.*$|export ZSH="${omz}"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc"
echo }
setup_shell() {
if [ "$CHSH" = no ]; then return fi
if [ "$(basename -- "$SHELL")" = "zsh" ]; then return fi
if ! command_exists chsh; then cat <<EOF I can't change your shell automatically because this system does not have chsh. ${FMT_BLUE}Please manually change your default shell to zsh${FMT_RESET} EOF return fi
echo "${FMT_BLUE}Time to change your default shell to zsh:${FMT_RESET}"
printf '%sDo you want to change your default shell to zsh? [Y/n]%s '
"$FMT_YELLOW" "$FMT_RESET"
read -r opt
case $opt in
[Yy]|"") ;;
[Nn]) echo "Shell change skipped."; return ;;
*) echo "Invalid choice. Shell change skipped."; return ;;
esac
case "$PREFIX" in com.termux) termux=true; zsh=zsh ;; *) termux=false ;; esac
if [ "$termux" != true ]; then # Test for the right location of the "shells" file if [ -f /etc/shells ]; then shells_file=/etc/shells elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS shells_file=/usr/share/defaults/etc/shells else fmt_error "could not find /etc/shells file. Change your default shell manually." return fi
# Get the path to the right zsh binary
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -n 1) || [ ! -f "$zsh" ]; then
fmt_error "no zsh binary found or not present in '$shells_file'"
fmt_error "change your default shell manually."
return
fi
fi
fi
if [ -n "$SHELL" ]; then echo "$SHELL" > "$zdot/.shell.pre-oh-my-zsh" else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > "$zdot/.shell.pre-oh-my-zsh" fi
echo "Changing your shell to $zsh..."
if user_can_sudo; then sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt else chsh -s "$zsh" "$USER" # run chsh normally fi
if [ $? -ne 0 ]; then fmt_error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${FMT_GREEN}Shell successfully changed to '$zsh'.${FMT_RESET}" fi
echo }
shellcheck disable=SC2183 # printf string has more %s than arguments ($FMT_RAINBOW expands to multiple arguments)
print_success() {
printf '%s %s__ %s %s %s %s %s__ %s\n' $FMT_RAINBOW $FMT_RESET
printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $FMT_RAINBOW $FMT_RESET
printf '%s / __ \%s/ __ \ %s / __ `__ \%s/ / / / %s /_ / %s/ /%s __ \ %s\n' $FMT_RAINBOW $FMT_RESET
printf '%s/ // /%s / / / %s / / / / / /%s // / %s / /%s(__ )%s / / / %s\n' $FMT_RAINBOW $FMT_RESET
printf '%s\/%s/ // %s // // //%s\, / %s //%s____/%s_/ // %s\n' $FMT_RAINBOW $FMT_RESET
printf '%s %s %s %s /___/ %s %s %s %s....is now installed!%s\n' $FMT_RAINBOW $FMT_GREEN
"$(fmt_code "$(fmt_link ".zshrc" "file://$zdot/.zshrc" --text)")"
"file to select plugins, themes, and options."
printf '\n'
printf '%s\n' "• Follow us on X: $(fmt_link @ohmyzsh https://x.com/ohmyzsh)"
printf '%s\n' "• Join our Discord community: $(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
printf '%s\n' "• Get stickers, t-shirts, coffee mugs and more: $(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
printf '%s\n' $FMT_RESET
}
test_custom_zsh_environment_variable() {
local test_dir=$(mktemp -d) local custom_zsh_dir="$test_dir/custom-oh-my-zsh"
export ZSH="$custom_zsh_dir" export HOME="$test_dir" export USER="testuser" export ZDOTDIR=""
. ./install.sh
assertEquals "yes" "$custom_zsh"
assertEquals "$custom_zsh_dir" "$ZSH"
assertEquals "$test_dir" "$zdot"
export ZDOTDIR="$test_dir" . ./install.sh assertEquals "$custom_zsh_dir" "$ZSH"
local custom_zdot="$test_dir/custom-zdot" export ZDOTDIR="$custom_zdot" unset ZSH . ./install.sh assertEquals "$custom_zdot/ohmyzsh" "$ZSH"
rm -rf "$test_dir" unset ZSH ZDOTDIR }
main() {
if [ ! -t 0 ]; then RUNZSH=no CHSH=no OVERWRITE_CONFIRMATION=no fi
while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no; OVERWRITE_CONFIRMATION=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done
setup_color
if ! command_exists zsh; then echo "${FMT_YELLOW}Zsh is not installed.${FMT_RESET} Please install zsh first." exit 1 fi
if [ -d "$ZSH" ]; then
echo "${FMT_YELLOW}The $ZSH folder already exists (
You ran the installer with the $ZSH setting or the $ZSH variable is exported. You have 3 options:
- Unset the ZSH variable when calling the installer: $(fmt_code "ZSH= sh install.sh")
- Install Oh My Zsh to a directory that doesn't exist yet: $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
- (Caution) If the folder doesn't contain important information, you can just remove it with $(fmt_code "rm -r $ZSH")
EOF else echo "You'll need to remove it if you want to reinstall." fi exit 1 fi
if [ -n "$ZDOTDIR" ]; then mkdir -p "$ZDOTDIR" fi
setup_ohmyzsh setup_zshrc setup_shell
print_success
if [
exec zsh -l }
main "$@" sert_file_not_exists "$HOME/.zshrc.pre-oh-my-zsh" }
main() {
if [ ! -t 0 ]; then RUNZSH=no CHSH=no OVERWRITE_CONFIRMATION=no fi
while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no; OVERWRITE_CONFIRMATION=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done
setup_color
if ! command_exists zsh; then echo "${FMT_YELLOW}Zsh is not installed.${FMT_RESET} Please install zsh first." exit 1 fi
if [ -d "$ZSH" ]; then
echo "${FMT_YELLOW}The $ZSH folder already exists (
You ran the installer with the $ZSH setting or the $ZSH variable is exported. You have 3 options:
- Unset the ZSH variable when calling the installer: $(fmt_code "ZSH= sh install.sh")
- Install Oh My Zsh to a directory that doesn't exist yet: $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
- (Caution) If the folder doesn't contain important information, you can just remove it with $(fmt_code "rm -r $ZSH")
EOF else echo "You'll need to remove it if you want to reinstall." fi exit 1 fi
if [ -n "$ZDOTDIR" ]; then mkdir -p "$ZDOTDIR" fi
setup_ohmyzsh setup_zshrc setup_shell
print_success
if [
exec zsh -l }
main "$@" test_successful_installation_with_defaults() {
setup_test_environment
mock_command "zsh" "echo '/usr/bin/zsh'" mock_command "git" " case $1 in init) mkdir -p "$2" ;; config) ;; remote) ;; fetch) ;; checkout) ;; --version) echo 'git version 2.30.0' ;; esac " mock_command "uname" "echo 'Linux'" mock_command "command" "return 0" mock_command "chsh" "return 0"
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
export USER="testuser" export HOME="$TEST_HOME" export SHELL="/bin/bash" unset ZDOTDIR unset ZSH unset REPO unset REMOTE unset BRANCH unset CHSH unset RUNZSH unset KEEP_ZSHRC unset OVERWRITE_CONFIRMATION
exec 0</dev/null
( cd "$TEST_DIR" echo "Y" | timeout 10s sh "$INSTALL_SCRIPT" --unattended )
assert_dir_exists "$HOME/.oh-my-zsh" assert_file_exists "$HOME/.zshrc" assert_file_contains "$HOME/.zshrc" 'export ZSH="$HOME/.oh-my-zsh"'
assert_dir_exists "$HOME/.oh-my-zsh/.git"
assert_file_not_exists "$HOME/.zshrc.pre-oh-my-zsh" }
test_custom_zsh_environment_variable() {
local test_dir=$(mktemp -d) local custom_zsh_dir="$test_dir/custom-oh-my-zsh"
export ZSH="$custom_zsh_dir" export HOME="$test_dir" export USER="testuser" export ZDOTDIR=""
. ./install.sh
assertEquals "yes" "$custom_zsh"
assertEquals "$custom_zsh_dir" "$ZSH"
assertEquals "$test_dir" "$zdot"
export ZDOTDIR="$test_dir" . ./install.sh assertEquals "$custom_zsh_dir" "$ZSH"
local custom_zdot="$test_dir/custom-zdot" export ZDOTDIR="$custom_zdot" unset ZSH . ./install.sh assertEquals "$custom_zdot/ohmyzsh" "$ZSH"
rm -rf "$test_dir" unset ZSH ZDOTDIR }
test_unattended_installation_with_flag() {
setup_test_environment
mock_command "zsh" "echo '/usr/bin/zsh'" mock_command "git" " case $1 in init) mkdir -p "$2" ;; config) ;; remote) ;; fetch) ;; checkout) ;; --version) echo 'git version 2.30.0' ;; esac " mock_command "uname" "echo 'Linux'" mock_command "command" "return 0" mock_command "chsh" "return 0"
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
export USER="testuser" export HOME="$TEST_HOME" export SHELL="/bin/bash" unset ZDOTDIR unset ZSH unset REPO unset REMOTE unset BRANCH unset CHSH unset RUNZSH unset KEEP_ZSHRC unset OVERWRITE_CONFIRMATION
( cd "$TEST_DIR" timeout 10s sh "$INSTALL_SCRIPT" --unattended )
assert_dir_exists "$HOME/.oh-my-zsh" assert_file_exists "$HOME/.zshrc" assert_file_contains "$HOME/.zshrc" 'export ZSH="$HOME/.oh-my-zsh"'
assert_dir_exists "$HOME/.oh-my-zsh/.git"
assert_file_not_exists "$HOME/.shell.pre-oh-my-zsh"
assert_equals "$SHELL" "/bin/bash" }
test_skip_chsh_argument() {
setup_test_environment
mock_command "zsh" "echo '/usr/bin/zsh'" mock_command "git" " case $1 in init) mkdir -p "$2" ;; config) ;; remote) ;; fetch) ;; checkout) ;; --version) echo 'git version 2.30.0' ;; esac " mock_command "uname" "echo 'Linux'" mock_command "command" "return 0" mock_command "chsh" "echo 'ERROR: chsh should not be called'; exit 1"
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
export USER="testuser" export HOME="$TEST_HOME" export SHELL="/bin/bash" unset ZDOTDIR unset ZSH
( cd "$TEST_DIR" timeout 10s sh "$INSTALL_SCRIPT" --skip-chsh --unattended )
assert_dir_exists "$HOME/.oh-my-zsh" assert_file_exists "$HOME/.zshrc"
assert_file_not_exists "$HOME/.shell.pre-oh-my-zsh" }
test_preserve_existing_zshrc_with_keep_flag() {
setup_test_environment
echo "# Existing zsh configuration" > "$TEST_HOME/.zshrc" echo "export CUSTOM_VAR=value" >> "$TEST_HOME/.zshrc"
mock_command "zsh" "echo '/usr/bin/zsh'" mock_command "git" " case $1 in init) mkdir -p "$2" ;; config) ;; remote) ;; fetch) ;; checkout) ;; --version) echo 'git version 2.30.0' ;; esac " mock_command "uname" "echo 'Linux'" mock_command "command" "return 0" mock_command "chsh" "return 0"
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
export USER="testuser" export HOME="$TEST_HOME" export SHELL="/bin/bash" unset ZDOTDIR unset ZSH
( cd "$TEST_DIR" sh "$INSTALL_SCRIPT" --keep-zshrc --unattended )
assert_file_exists "$HOME/.zshrc" assert_file_contains "$HOME/.zshrc" "# Existing zsh configuration" assert_file_contains "$HOME/.zshrc" "export CUSTOM_VAR=value"
assert_file_not_exists "$HOME/.zshrc.pre-oh-my-zsh"
assert_dir_exists "$HOME/.oh-my-zsh" }
test_git_not_installed_fails_gracefully() {
local test_dir=$(mktemp -d) export HOME="$test_dir" export USER="testuser" export ZSH="$test_dir/.oh-my-zsh" unset ZDOTDIR
command_exists() { case "$1" in git) return 1 ;; zsh) return 0 ;; *) return 0 ;; esac }
. ./install.sh
local output local exit_code
output=$(setup_ohmyzsh 2>&1 || echo "EXIT_CODE:$?") exit_code=$(echo "$output" | grep "EXIT_CODE:" | cut -d: -f2)
echo "$output" | grep -q "Error: git is not installed" assertTrue "Should display git not installed error" $?
assertEquals "1" "$exit_code"
assert_dir_not_exists "$ZSH"
rm -rf "$test_dir" unset ZSH }
test_zdotdir_environment_variable_differs_from_home() {
local test_dir=$(mktemp -d) local test_home="$test_dir/home" local custom_zdot="$test_dir/custom-zdot"
mkdir -p "$test_home" mkdir -p "$custom_zdot"
export HOME="$test_home" export ZDOTDIR="$custom_zdot" export USER="testuser" unset ZSH
. ./install.sh
assertEquals "$custom_zdot" "$zdot"
assertEquals "$custom_zdot/ohmyzsh" "$ZSH"
assertNotEquals "yes" "$custom_zsh"
rm -rf "$test_dir" unset HOME ZDOTDIR ZSH }
test_termux_environment_handling() {
setup_test_environment
export PREFIX="/data/data/com.termux/files/usr" export USER="u0_a123" export HOME="$TEST_HOME" export SHELL="/data/data/com.termux/files/usr/bin/bash" unset ZDOTDIR unset ZSH
mock_command "zsh" "echo '/data/data/com.termux/files/usr/bin/zsh'" mock_command "git" " case $1 in init) mkdir -p "$2" ;; config) ;; remote) ;; fetch) ;; checkout) ;; --version) echo 'git version 2.30.0' ;; esac " mock_command "uname" "echo 'Linux'" mock_command "command" " case $1 in -v) case $2 in sudo) return 1 ;; # sudo not available in Termux chsh) return 1 ;; # chsh not available in Termux zsh) echo '/data/data/com.termux/files/usr/bin/zsh' ;; git) echo '/data/data/com.termux/files/usr/bin/git' ;; *) return 0 ;; esac ;; esac "
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
( cd "$TEST_DIR" . "$INSTALL_SCRIPT"
# Should return 1 (false) in Termux environment
if user_can_sudo; then
echo "FAIL: user_can_sudo should return false in Termux"
exit 1
fi
)
( cd "$TEST_DIR" timeout 10s sh "$INSTALL_SCRIPT" --unattended )
assert_dir_exists "$HOME/.oh-my-zsh" assert_file_exists "$HOME/.zshrc" assert_file_contains "$HOME/.zshrc" 'export ZSH="$HOME/.oh-my-zsh"' assert_file_not_exists "$HOME/.shell.pre-oh-my-zsh" }
test_backup_existing_zshrc_with_timestamps() {
setup_test_environment
echo "original zshrc content" > "$TEST_HOME/.zshrc"
echo "first backup content" > "$TEST_HOME/.zshrc.pre-oh-my-zsh"
mock_command "date" "echo '2023-12-01_10-30-45'"
mkdir -p "$TEST_ZSH/templates" echo 'export ZSH="$HOME/.oh-my-zsh"' > "$TEST_ZSH/templates/zshrc.zsh-template" echo 'minimal config' > "$TEST_ZSH/templates/minimal.zshrc"
export USER="testuser" export HOME="$TEST_HOME" export ZSH="$TEST_ZSH" export ZDOTDIR="" export KEEP_ZSHRC="no" export OVERWRITE_CONFIRMATION="no"
. "$INSTALL_SCRIPT" setup_color setup_zshrc
assert_file_exists "$HOME/.zshrc.pre-oh-my-zsh" assert_file_contains "$HOME/.zshrc.pre-oh-my-zsh" "original zshrc content"
assert_file_exists "$HOME/.zshrc.pre-oh-my-zsh-2023-12-01_10-30-45" assert_file_contains "$HOME/.zshrc.pre-oh-my-zsh-2023-12-01_10-30-45" "first backup content"
assert_file_exists "$HOME/.zshrc" assert_file_contains "$HOME/.zshrc" 'export ZSH="$HOME/.oh-my-zsh"' }
test_exit_error_when_zsh_directory_exists_and_custom_zsh_set() {
local test_dir=$(mktemp -d) local custom_zsh_dir="$test_dir/custom-oh-my-zsh"
mkdir -p "$custom_zsh_dir"
export ZSH="$custom_zsh_dir" export HOME="$test_dir" export USER="testuser" export ZDOTDIR=""
mock_command "zsh" "echo '/usr/bin/zsh'" mock_command "command" "return 0"
local test_script="$test_dir/test_install.sh" cat > "$test_script" << 'EOF' #!/bin/sh set -e
. ./install.sh
main --unattended EOF
chmod +x "$test_script"
local exit_code=0 (cd "$TEST_DIR" && "$test_script") || exit_code=$?
assertEquals "1" "$exit_code"
assert_dir_exists "$custom_zsh_dir"
rm -rf "$test_dir" unset ZSH ZDOTDIR }

