Manjaro记录

文章不完整,继续记录。一来方便后人,二来方便自己以后再用~

screenfetch

如果出现下面的提示, 则需要更新一下 pacman, 然后再安装软件包.

  1. 错误:无法从 mirrors.163.com : The requested URL returned error: 404 获取文件 'jre7-openjdk-headless-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirror.bjtu.edu.cn : The requested URL returned error: 404 获取文件 'jre7-openjdk-headless-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirror6.bjtu.edu.cn : Failed to connect to 2001:da8:205::58: 网络不可达 获取文件 'jre7-openjdk-headless-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirrors.ustc.edu.cn : Given file does not exist 获取文件 'jre7-openjdk-headless-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirrors.ustc.edu.cn : The requested URL returned error: 404 获取文件 'jre7-openjdk-headless-7.b147_2.1-3-x86_64.pkg.tar.xz'警告:无法从 extra 获取某些文件错误:无法从 mirrors.163.com : The requested URL returned error: 404 获取文件 'jre7-openjdk-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirror.bjtu.edu.cn : The requested URL returned error: 404 获取文件 'jre7-openjdk-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirror6.bjtu.edu.cn : Failed to connect to 2001:da8:205::58: 网络不可达 获取文件 'jre7-openjdk-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirrors.ustc.edu.cn : Given file does not exist 获取文件 'jre7-openjdk-7.b147_2.1-3-x86_64.pkg.tar.xz'错误:无法从 mirrors.ustc.edu.cn : The requested URL returned error: 404 获取文件 'jre7-openjdk-7.b147_2.1-3-x86_64.pkg.tar.xz'警告:无法从 extra 获取某些文件错误:无法提交处理 (下载函数库出错)
  2. 发生错误,没有软件包被更新。

原因在于本地数据库 core.db, extra.db, community.db 中的软件包信息已经与服务器上的不一致, 主要是软件包的版本不一致导致的. 一般不是服务器连接不上的原因.

执行下面的命令即可.

  1. sudo pacman -Sy

Typora

Markdown编辑器:Typora:

yaourt typora

强大的全平台Git客户端GitKraken:

yaourt GitKraken

图像编辑器Gimp:

sudo pacman -S gimp

强大的PDF阅读器Foxit:

yaourt foxit

我这个安装失败,3个源全不能用

网易云音乐非官方客户端electron-netease-cloud-music:

sudo pacman -S electron-netease-cloud-music

网易云命令行播放器(很赞)NetEase-MusicBox:

yaourt musicbox

,使用方法点击查看

https://github.com/darknessomi/musicbox/blob/master/README.md#%E9%94%AE%E7%9B%98%E5%BF%AB%E6%8D%B7%E9%94%AE

功能特性

  1. 320kbps的高品质音乐

  2. 歌曲,艺术家,专辑检索

  3. 网易22个歌曲排行榜

  4. 网易新碟推荐

  5. 网易精选歌单

  6. 网易主播电台

  7. 私人歌单,每日推荐

  8. 随心打碟

  9. 本地收藏,随时加

  10. 播放进度及播放模式显示

  11. 现在播放及桌面歌词显示

  12. 歌曲评论显示

  13. 一键进入歌曲专辑

  14. 定时退出

  15. Vimer式快捷键让操作丝般顺滑

  16. 可使用数字快捷键

  17. 可使用自定义全局快捷键

键盘快捷键

Key Effect
j Down 下移
k Up 上移
h Back 后退
l Forword 前进
u Prev page 上一页
d Next page 下一页
f Search 快速搜索
[ Prev song 上一曲
] Next song 下一曲
= Volume + 音量增加
- Volume - 音量减少
Space Play/Pause 播放/暂停
? Shuffle 手气不错
m Menu 主菜单
p Present/History 当前/历史播放列表
i Music Info 当前音乐信息
⇧+p Playing Mode 播放模式切换
a Add 添加曲目到打碟
⇧+a Enter album 进入专辑
g To the first 跳至首项
⇧+g To the end 跳至尾项
z DJ list 打碟列表
s Star 添加到收藏
c Collection 收藏列表
r Remove 删除当前条目
⇧+j Move Down 向下移动当前项目
⇧+k Move Up 向上移动当前项目
⇧+c Cache 缓存歌曲到本地
, Like 喜爱
. Trash FM 删除 FM
/ Next FM 下一FM
q Quit 退出
t Timing Exit 定时退出
w Quit&Clear 退出并清除用户信息

OneDrive Linux

onedrive Linux客户端:

https://github.com/skilion/onedrive

安装:

sudo pacman -S curl sqlite dlang # 安装依赖git clone https://github.com/skilion/onedrive.gitcd onedrivemakesudo make install

**注意:**首次运行时,必须在命令行中运行并进行授权,运行之前进行配置,否则会自动下载onedrive中所有文件

配置:

mkdir -p ~/.config/onedrivecp ./config ~/.config/onedrive/confignano ~/.config/onedrive/config

默认可以不改变,对于需要同步的文件夹,推荐使用sync_list,更加简单明了。

在~/.config/onedrive新建sync_list文件,文件的每一行代表sync_dir的相对路径。在所有操作期间,将跳过与文件的任何行不匹配的所有文件和目录。如:

BackupDocuments/latest_report.docxWork/ProjectXnotes.txt

当添加新文件或改动文件时,需手动上传同步:onedrive --resync --verbose

当然也可以自动同步:

systemctl --user enable onedrivesystemctl --user start onedrive

强大的命令行下载工具aria2:

sudo pacman -S aria2
https://github.com/aria2/aria2

强大的Web内容(视频,音频,图片)下载工具you-get:

sudo pacman -S you-get
https://github.com/soimort/you-get

目录跳转神奇autojump:

sudo pacman -S autojump
https://github.com/wting/autojump

安装完成后需进行简单配置:

在~/.zshrc中添加:

source /usr/share/autojump/autojump.zsh

如果默认Shell是bash的话,在~/.bashrc中添加:source /usr/share/autojump/autojump.bash

模糊搜素神奇fzf:

sudo pacman -S fzf

,具体配置查看文档,我的配置是添加alias:alias fzf="fzf --height 40%",可在oh-my-zsh配置文件中添加fzf插件。

个人认为通过vim **再按Tab键更好地利用了fzf命令,类似的还有kill **等。

https://github.com/junegunn/fzf

一个速度极快的类似ack的代码搜索工具ag:

sudo pacman -S the_silver_searcher

自动纠正上一个控制台命令thefuck:

sudo pacman -S thefuckhttps://github.com/nvbn/thefuck

强大的终端复用工具tmux:

sudo pacman -S tmuxhttps://github.com/tmux/tmux

字符模式下交互查看git项目tig:

sudo pacman -S tig
https://github.com/jonas/ti

终端美化

sudo pacman -S zsh

配置zsh

chsh -s /bin/zsh

如果想换回bash,运行

chsh -s /bin/bash

安装oh-my-zsh

运行命令(需要在zsh下运行)

如果没安装git需要运行以下命令,否则跳过

肯定有git

sudo pacman -S git

不要带sudo,否则会导致用户界面无法达到预期效果。

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

如果提示timed out可以复制以下脚本

别想了,整。肯定timeout

#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN=""#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@"#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@"#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi
#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@" # Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@"
# Check if we're running on Termux 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#!/bin/sh## This script should be run via curl:# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or wget:# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"## As an alternative, you can first download the install script and run it afterwards:# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh# sh install.sh## You can tweak the install behavior by setting variables when running the script. For# example, to change the path to the Oh My Zsh repository:# ZSH=~/.zsh sh install.sh## Respects the following environment variables:# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)# BRANCH - branch to check out immediately after install (default: master)## Other options:# CHSH - 'no' means the installer will not change the default shell (default: yes)# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)## You can also pass some arguments to the install script to set some these options:# --skip-chsh: has the same behavior as setting CHSH to 'no'# --unattended: sets both CHSH and RUNZSH to 'no'# --keep-zshrc: sets KEEP_ZSHRC to 'yes'# For example:# sh install.sh --unattended#set -e

# Default settingsZSH=${ZSH:-~/.oh-my-zsh}REPO=${REPO:-ohmyzsh/ohmyzsh}REMOTE=${REMOTE:-https://github.com/${REPO}.git}BRANCH=${BRANCH:-master}

# Other optionsCHSH=${CHSH:-yes}RUNZSH=${RUNZSH:-yes}KEEP_ZSHRC=${KEEP_ZSHRC:-no}



command_exists() { command -v "$@" >/dev/null 2>&1}

error() { echo ${RED}"Error: $@"${RESET} >&2}

setup_color() { # Only use colors if connected to a terminal if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi}

setup_ohmyzsh() { # Prevent the cloned repository from having insecure permissions. Failing to do # so causes compinit() calls to fail with "command not found: compdef" errors # for users with insecure umasks (e.g., "002", allowing group writability). Note # that this will be ignored under Cygwin by default, as Windows ACLs take # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w

echo "${BLUE}Cloning Oh My Zsh...${RESET}"

command_exists git || { error "git is not installed" exit 1 }

if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi

git clone -c core.eol=lf -c core.autocrlf=false \ -c fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \ --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 }

echo}

setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc echo "${BLUE}Looking for an existing zsh config...${RESET}"

# Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi

echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

sed "/^export ZSH=/ c\\export ZSH=\"$ZSH\"" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc

echo}

setup_shell() { # Skip setup if the user wants or stdin is closed (not running interactively). if [ $CHSH = no ]; then return fi

# If this user's login shell is already "zsh", do not attempt to switch. if [ "$(basename "$SHELL")" = "zsh" ]; then return fi

# If this platform doesn't provide a "chsh" command, bail out. if ! command_exists chsh; then cat <<-EOF I can't change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi

echo "${BLUE}Time to change your default shell to zsh:${RESET}"

# Prompt for user choice on changing the default login shell printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac

# Check if we're running on Termux 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 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}

main "$@" 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=$(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

# We're going to change the default shell, so back up the current one if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi

# Actually change the default shell to zsh if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi

echo}

main() { # Run as unattended if stdin is closed if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi

# Parse arguments while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done

setup_color

if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi

if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You'll need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi

setup_ohmyzsh setup_zshrc setup_shell

printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us on https://twitter.com/ohmyzsh p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh EOF printf "$RESET"

if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi

exec zsh -l}main "$@"

然后执行

sh install.sh

我没有写完啊,但是浏览器一卡一卡的。

(0)

相关推荐