sh 安装zsh git,比安装zprezto并配置它,并将它们更改为powerlevel9k,在ubuntu上完成

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 安装zsh git,比安装zprezto并配置它,并将它们更改为powerlevel9k,在ubuntu上完成相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash
#sudo sh installzprezto.sh $(whoami)
apt-get -y install git zsh
wget -O /usr/local/share/fonts/sourcecodepro.ttf https://github.com/Falkor/dotfiles/blob/master/fonts/SourceCodePro+Powerline+Awesome+Regular.ttf?raw=true
fc-cache -f -v

different_user=$1


echo "Current user: $(whoami)"
echo "Current directory: $(pwd)"
echo

echo "Switching user to $different_user"
sudo -u "$different_user" -i /bin/bash - <<-'EOF'
    echo "Current user: $(id)"
    echo "Current directory: $(pwd)"
    git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
    ln -s ~/.zprezto/runcoms/zlogin ~/.zlogin
	ln -s ~/.zprezto/runcoms/zlogout ~/.zlogout
	ln -s ~/.zprezto/runcoms/zpreztorc ~/.zpreztorc
	ln -s ~/.zprezto/runcoms/zprofile ~/.zprofile
	ln -s ~/.zprezto/runcoms/zshenv ~/.zshenv
	ln -s ~/.zprezto/runcoms/zshrc ~/.zshrc
	curl -fLo ~/.zprezto/modules/completion/external/src/_docker https://raw.github.com/felixr/docker-zsh-completion/master/_docker
	cat <<EOT >> .zshrc
	export TERM="xterm-256color"
	POWERLEVEL9K_MODE='awesome-patched'
	# Source Prezto.
	if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
	  source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
	fi

	#will show the context in the tab title
	case $TERM in
	    xterm*)
	        precmd () {print -Pn "\e]0;%n@%m\a"}
	        ;;
	esac

	#powerlevel9k customization
	POWERLEVEL9K_PROMPT_ON_NEWLINE=true
	POWERLEVEL9K_CUSTOM_INTERNET_STATUS_BACKGROUND="black"
	POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( os_icon context dir )
	POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( 'vcs' 'load' 'ram_joined')
	EOT
	rm .zpreztorc
	cat <<EOT >> .zpreztorc
	#test
	# Sets Prezto options.
	#
	# Authors:
	#   Sorin Ionescu <sorin.ionescu@gmail.com>
	#

	#
	# General
	#

	# Set case-sensitivity for completion, history lookup, etc.
	# zstyle ':prezto:*:*' case-sensitive 'yes'

	# Color output (auto set to 'no' on dumb terminals).
	zstyle ':prezto:*:*' color 'yes'

	# Set the Zsh modules to load (man zshmodules).
	# zstyle ':prezto:load' zmodule 'attr' 'stat'

	# Set the Zsh functions to load (man zshcontrib).
	# zstyle ':prezto:load' zfunction 'zargs' 'zmv'

	# Set the Prezto modules to load (browse modules).
	# The order matters.
	zstyle ':prezto:load' pmodule \
	  'environment' \
	  'terminal' \
	  'editor' \
	  'history' \
	  'directory' \
	  'spectrum' \
	  'utility' \
	  'ssh' \
	  'completion' \
	  'homebrew' \
	  'osx' \
	  'ruby' \
	  'rails' \
	  'git' \
	  'syntax-highlighting' \
	  'history-substring-search' \
	  'prompt'

	#
	# Autosuggestions
	#

	# Set the query found color.
	# zstyle ':prezto:module:autosuggestions:color' found ''

	#
	# Editor
	#

	# Set the key mapping style to 'emacs' or 'vi'.
	zstyle ':prezto:module:editor' key-bindings 'emacs'

	# Auto convert .... to ../..
	# zstyle ':prezto:module:editor' dot-expansion 'yes'

	#
	# Git
	#

	# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
	# zstyle ':prezto:module:git:status:ignore' submodules 'all'

	#
	# GNU Utility
	#

	# Set the command prefix on non-GNU systems.
	# zstyle ':prezto:module:gnu-utility' prefix 'g'

	#
	# History Substring Search
	#

	# Set the query found color.
	# zstyle ':prezto:module:history-substring-search:color' found ''

	# Set the query not found color.
	# zstyle ':prezto:module:history-substring-search:color' not-found ''

	# Set the search globbing flags.
	# zstyle ':prezto:module:history-substring-search' globbing-flags ''

	#
	# Pacman
	#

	# Set the Pacman frontend.
	# zstyle ':prezto:module:pacman' frontend 'yaourt'

	#
	# Prompt
	#

	# Set the prompt theme to load.
	# Setting it to 'random' loads a random theme.
	# Auto set to 'off' on dumb terminals.
	zstyle ':prezto:module:prompt' theme 'powerlevel9k'

	#
	# Ruby
	#

	# Auto switch the Ruby version on directory change.
	# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'

	#
	# Screen
	#

	# Auto start a session when Zsh is launched in a local terminal.
	# zstyle ':prezto:module:screen:auto-start' local 'yes'

	# Auto start a session when Zsh is launched in a SSH connection.
	# zstyle ':prezto:module:screen:auto-start' remote 'yes'

	#
	# SSH
	#

	# Set the SSH identities to load into the agent.
	# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'

	#
	# Syntax Highlighting
	#

	# Set syntax highlighters.
	# By default, only the main highlighter is enabled.
	# zstyle ':prezto:module:syntax-highlighting' highlighters \
	#   'main' \
	#   'brackets' \
	#   'pattern' \
	#   'line' \
	#   'cursor' \
	#   'root'
	#
	# Set syntax highlighting styles.
	# zstyle ':prezto:module:syntax-highlighting' styles \
	#   'builtin' 'bg=blue' \
	#   'command' 'bg=blue' \
	#   'function' 'bg=blue'

	#
	# Terminal
	#

	# Auto set the tab and window titles.
	# zstyle ':prezto:module:terminal' auto-title 'yes'

	# Set the window title format.
	# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'

	# Set the tab title format.
	# zstyle ':prezto:module:terminal:tab-title' format '%m: %s'

	#
	# Tmux
	#

	# Auto start a session when Zsh is launched in a local terminal.
	# zstyle ':prezto:module:tmux:auto-start' local 'yes'

	# Auto start a session when Zsh is launched in a SSH connection.
	# zstyle ':prezto:module:tmux:auto-start' remote 'yes'

	# Integrate with iTerm2.
	# zstyle ':prezto:module:tmux:iterm' integrate 'yes'
	EOT
EOF
echo

echo "Switched back to $(whoami)"

different_user_home="$(eval echo ~"$different_user")"
echo "$different_user home directory: $different_user_home"

以上是关于sh 安装zsh git,比安装zprezto并配置它,并将它们更改为powerlevel9k,在ubuntu上完成的主要内容,如果未能解决你的问题,请参考以下文章

sh 在ubuntu上安装zprezto

zprezto配置

Mac之安装zsh

在 zsh 中安装 npm 后找不到命令

centos 7里安装zsh来提升shell的高逼格

CentOS7.5安装配置Oh-My-Zsh