mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
installer: allow chsh to work in termux
This commit is contained in:
parent
f9e133b88a
commit
fd4571d1b0
1 changed files with 25 additions and 17 deletions
|
@ -165,29 +165,37 @@ setup_shell() {
|
||||||
*) echo "Invalid choice. Shell change skipped."; return ;;
|
*) echo "Invalid choice. Shell change skipped."; return ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Test for the right location of the "shells" file
|
# Check if we're running on Termux
|
||||||
if [ -f /etc/shells ]; then
|
case "$PREFIX" in
|
||||||
shells_file=/etc/shells
|
*com.termux*) termux=true; zsh=zsh ;;
|
||||||
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
|
*) termux=false ;;
|
||||||
shells_file=/usr/share/defaults/etc/shells
|
esac
|
||||||
else
|
|
||||||
error "could not find /etc/shells file. Change your default shell manually."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the path to the right zsh binary
|
if [ "$termux" != true ]; then
|
||||||
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
|
# Test for the right location of the "shells" file
|
||||||
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
|
if [ -f /etc/shells ]; then
|
||||||
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
shells_file=/etc/shells
|
||||||
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
|
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
|
||||||
error "no zsh binary found or not present in '$shells_file'"
|
shells_file=/usr/share/defaults/etc/shells
|
||||||
error "change your default shell manually."
|
else
|
||||||
|
error "could not find /etc/shells file. Change your default shell manually."
|
||||||
return
|
return
|
||||||
fi
|
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=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
||||||
|
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
|
||||||
|
error "no zsh binary found or not present in '$shells_file'"
|
||||||
|
error "change your default shell manually."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We're going to change the default shell, so back up the current one
|
# We're going to change the default shell, so back up the current one
|
||||||
if [ -n $SHELL ]; then
|
if [ -n "$SHELL" ]; then
|
||||||
echo $SHELL > ~/.shell.pre-oh-my-zsh
|
echo $SHELL > ~/.shell.pre-oh-my-zsh
|
||||||
else
|
else
|
||||||
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
|
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
|
||||||
|
|
Loading…
Reference in a new issue