精华内容
下载资源
问答
  • Linuxroot权限安装ZSH
    2021-05-10 20:16:43

    #color{{{

    autoload colors

    colors

    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do

    eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}'

    eval $color='%{$fg[${(L)color}]%}'

    (( count = $count + 1 ))

    done

    FINISH="%{$terminfo[sgr0]%}"

    #}}}

    # If you come from bash you might have to change your $PATH.

    # export PATH=$HOME/bin:/usr/local/bin:$PATH

    # Path to your oh-my-zsh installation.

    export ZSH="/home/username/.oh-my-zsh"

    # Set name of the theme to load --- if set to "random", it will

    # load a random theme each time oh-my-zsh is loaded, in which case,

    # to know which specific one was loaded, run: echo $RANDOM_THEME

    # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

    ZSH_THEME="ys"

    # Set list of themes to pick from when loading at random

    # Setting this variable when ZSH_THEME=random will cause zsh to load

    # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/

    # If set to an empty array, this variable will have no effect.

    # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

    # Uncomment the following line to use case-sensitive completion.

    # CASE_SENSITIVE="true"

    # Uncomment the following line to use hyphen-insensitive completion.

    # Case-sensitive completion must be off. _ and - will be interchangeable.

    # HYPHEN_INSENSITIVE="true"

    # Uncomment the following line to disable bi-weekly auto-update checks.

    # DISABLE_AUTO_UPDATE="true"

    # Uncomment the following line to automatically update without prompting.

    # DISABLE_UPDATE_PROMPT="true"

    # Uncomment the following line to change how often to auto-update (in days).

    # export UPDATE_ZSH_DAYS=13

    # Uncomment the following line if pasting URLs and other text is messed up.

    # DISABLE_MAGIC_FUNCTIONS=true

    # Uncomment the following line to disable colors in ls.

    # DISABLE_LS_COLORS="true"

    # Uncomment the following line to disable auto-setting terminal title.

    # DISABLE_AUTO_TITLE="true"

    # Uncomment the following line to enable command auto-correction. 用The FUCK插件代替

    # ENABLE_CORRECTION="true"

    # Uncomment the following line to display red dots whilst waiting for completion.

    # COMPLETION_WAITING_DOTS="true"

    # Uncomment the following line if you want to disable marking untracked files

    # under VCS as dirty. This makes repository status check for large repositories

    # much, much faster.

    # DISABLE_UNTRACKED_FILES_DIRTY="true"

    # Uncomment the following line if you want to change the command execution time

    # stamp shown in the history command output.

    # You can set one of the optional three formats:

    # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"

    # or set a custom format using the strftime function format specifications,

    # see 'man strftime' for details.

    HIST_STAMPS="mm/dd/yyyy"

    # Would you like to use another custom folder than $ZSH/custom?

    # ZSH_CUSTOM=/path/to/new-custom-folder

    # Which plugins would you like to load?

    # Standard plugins can be found in ~/.oh-my-zsh/plugins/*

    # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/

    # Example format: plugins=(rails git textmate ruby lighthouse)

    # Add wisely, as too many plugins slow down shell startup.

    # z命令快速跳转目录 x命令解压一切文件

    plugins=(

    git

    z

    zsh-autosuggestions

    extract

    zsh-syntax-highlighting

    last-working-dir

    )

    source $ZSH/oh-my-zsh.sh

    # User configuration

    # export MANPATH="/usr/local/man:$MANPATH"

    # You may need to manually set your language environment

    # export LANG=en_US.UTF-8

    # Preferred editor for local and remote sessions

    # if [[ -n $SSH_CONNECTION ]]; then

    # export EDITOR='vim'

    # else

    # export EDITOR='mvim'

    # fi

    # Compilation flags

    # export ARCHFLAGS="-arch x86_64"

    # Set personal aliases, overriding those provided by oh-my-zsh libs,

    # plugins, and themes. Aliases can be placed here, though oh-my-zsh

    # users are encouraged to define aliases within the ZSH_CUSTOM folder.

    # For a full list of active aliases, run `alias`.

    #

    # Example aliases 别名

    # alias zshconfig="mate ~/.zshrc"

    # alias ohmyzsh="mate ~/.oh-my-zsh"

    alias check='nvidia-smi'

    alias ta='tmux attach'

    alias cp='cp -i'

    alias mv='mv -i'

    alias rm='rm -i'

    alias ls='ls -F --color=auto'

    alias ll='ls -al'

    alias grep='grep --color=auto'

    alias la='ls -a'

    #路径别名 {{{

    #进入相应的路径时只要 cd ~xxx

    hash -d H="/home"

    #}}}

    eval $(thefuck --alias)

    #命令提示符样式{{{

    RPROMPT=$(echo "$RED%D %T$FINISH")

    PROMPT=$(echo "$WHITE@SSH: $CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ")

    #}}}

    #标题栏、任务栏样式{{{

    case $TERM in (*xterm*|*rxvt*|(dt|k|E)term)

    precmd () { print -Pn "\e]0;%n@%M//%/\a" }

    preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" }

    ;;

    esac

    #}}}

    #编辑器

    export EDITOR=vim

    #关于历史纪录的配置 {{{

    #历史纪录条目数量

    export HISTSIZE=10000

    #注销后保存的历史纪录条目数量

    export SAVEHIST=10000

    #历史纪录文件

    export HISTFILE=~/.zsh_history

    #以附加的方式写入历史纪录

    setopt INC_APPEND_HISTORY

    #如果连续输入的命令相同,历史纪录中只保留一个

    setopt HIST_IGNORE_DUPS

    #为历史纪录中的命令添加时间戳

    setopt EXTENDED_HISTORY

    #启用 cd 命令的历史纪录,cd -[TAB]进入历史路径

    setopt AUTO_PUSHD

    #相同的历史路径只保留一个

    setopt PUSHD_IGNORE_DUPS

    #在命令前添加空格,不将此命令添加到纪录文件中

    #setopt HIST_IGNORE_SPACE

    #}}}

    ##空行(光标在行首)补全 "cd " {{{

    user-complete(){

    case $BUFFER in

    "" ) # 空行填入 "cd "

    BUFFER="cd "

    zle end-of-line

    zle expand-or-complete

    ;;

    "cd --" ) # "cd --" 替换为 "cd +"

    BUFFER="cd +"

    zle end-of-line

    zle expand-or-complete

    ;;

    "cd +-" ) # "cd +-" 替换为 "cd -"

    BUFFER="cd -"

    zle end-of-line

    zle expand-or-complete

    ;;

    * )

    zle expand-or-complete

    ;;

    esac

    }

    zle -N user-complete

    bindkey "\t" user-complete

    #}}}

    更多相关内容
  • Linux超炫的 ZSH 配置

    2021-12-12 11:15:07
    oh-my-zsh

    oh-my-zsh

    #1 环境

    macOS 
    Ubuntu 
    

    区别: macOS自带zsh, Ubuntu需要安装zsh

    #1.1 Ubuntu准备

    • Ubuntu安装zsh
    sudo apt update 
    sudo apt install zsh
    
    • 配置zsh
    chsh -s /bin/zsh
    

    #2 开始

    • 安装oh-my-zsh

    复制以下内容,运行;

    #!/bin/sh
    #
    # This script should be run via curl:
    #   sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    # or via wget:
    #   sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    # or via fetch:
    #   sh -c "$(fetch -o - 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
    # or:
    #   sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
    #
    set -e
    
    # Track if $ZSH was provided
    custom_zsh=${ZSH:+yes}
    
    # Default settings
    ZSH=${ZSH:-~/.oh-my-zsh}
    REPO=${REPO:-ohmyzsh/ohmyzsh}
    #REMOTE=${REMOTE:-https://github.com/${REPO}.git}
    REMOTE=${REMOTE:-https://gitee.com/Coxhuang/oh-my-zsh.git}
    BRANCH=${BRANCH:-master}
    
    # Other options
    CHSH=${CHSH:-yes}
    RUNZSH=${RUNZSH:-yes}
    KEEP_ZSHRC=${KEEP_ZSHRC:-no}
    
    
    command_exists() {
    	command -v "$@" >/dev/null 2>&1
    }
    
    fmt_error() {
      printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2
    }
    
    fmt_underline() {
      printf '\033[4m%s\033[24m\n' "$*"
    }
    
    fmt_code() {
      # shellcheck disable=SC2016 # backtic in single-quote
      printf '`\033[38;5;247m%s%s`\n' "$*" "$RESET"
    }
    
    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 || {
        fmt_error "git is not installed"
        exit 1
      }
    
      ostype=$(uname)
      if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -q msysgit; 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 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" || {
        fmt_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
            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 "${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 '%sDo you want to change your default shell to zsh? [Y/n]%s ' \
        "$YELLOW" "$RESET"
    #  read -r opt
      opt="y"
      echo "-----------> $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
          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 -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
    
      # 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 "^$USERNAME:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
      fi
    
      # Actually change the default shell to zsh
      if ! chsh -s "$zsh"; then
        fmt_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 not a tty
      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
        echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
        if [ "$custom_zsh" = yes ]; then
          cat <<EOF
    
    You ran the installer with the \$ZSH setting or the \$ZSH variable is
    exported. You have 3 options:
    
    1. Unset the ZSH variable when calling the installer:
       $(fmt_code "ZSH= sh install.sh")
    2. Install Oh My Zsh to a directory that doesn't exist yet:
       $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
    3. (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
    
      setup_ohmyzsh
      setup_zshrc
      setup_shell
    
      printf %s "$GREEN"
      cat <<'EOF'
             __                                     __
      ____  / /_     ____ ___  __  __   ____  _____/ /_
     / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
    / /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
    \____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                            /____/                       ....is now installed!
    
    
    EOF
      cat <<EOF
    Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
    
    • Follow us on Twitter: $(fmt_underline https://twitter.com/ohmyzsh)
    • Join our Discord server: $(fmt_underline https://discord.gg/ohmyzsh)
    • Get stickers, shirts, coffee mugs and other swag: $(fmt_underline https://shop.planetargon.com/collections/oh-my-zsh)
    
    EOF
      printf %s "$RESET"
    
      if [ $RUNZSH = no ]; then
        echo "${YELLOW}Run zsh to try it out.${RESET}"
        exit
      fi
    
      exec zsh -l
    }
    
    main "$@"
    
    • 自动补全
    git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
    
    • 高亮
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    
    • 添加插件
    vim ~/.zshrc
    plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
    
    • 刷新环境
    source ~/.zshrc
    

    至此,zsh和oh-my-zsh就全部装好啦~

    #3 其他

    打开终端异常提示

    [oh-my-zsh] Insecure completion-dependent directories detected:
    drwxrwxrwx  7   admin  224  4 24 18:12 /usr/local/share/zsh
    
    [oh-my-zsh] For safety, we will not load completions from these directories until
    [oh-my-zsh] you fix their permissions and ownership and restart zsh.
    [oh-my-zsh] See the above list for directories with group or other writability.
    
    [oh-my-zsh] To fix your permissions you can do so by disabling
    [oh-my-zsh] the write permission of "group" and "others" and making sure that the
    [oh-my-zsh] owner of these directories is either root or your current user.
    [oh-my-zsh] The following command may help:
    [oh-my-zsh]     compaudit | xargs chmod g-w,o-w
    
    [oh-my-zsh] If the above didn't help or you want to skip the verification of
    [oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
    [oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
    
    • 解决:
    vim ~/.zshrc
    # 最顶部加上
    ZSH_DISABLE_COMPFIX=true
    
    source .zshrc
    

    macOS去掉iterm警告

    chmod 755 /usr/local/share/zsh
    chmod 755 /usr/local/share/zsh/site-functions
    

    macOS安装brew

    /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
    
    展开全文
  • 本文将指导你完成在Linux系统上安装Zsh、Oh My Zsh,及为Zsh安装Oh My Zsh主题,并根据需求进行配置。在Linux上安装Zsh1、在Arch Linux和Manjaro上安装Zsh:sudo pacman -S zsh2、在Gentoo上安装Zsh:emerge --ask ...

    本文将指导你完成在Linux系统上安装Zsh、Oh My Zsh,及为Zsh安装Oh My Zsh主题,并根据需求进行配置。

    在Linux上安装Zsh

    1、在Arch Linux和Manjaro上安装Zsh:

    sudo pacman -S zsh

    2、在Gentoo上安装Zsh:

    emerge --ask zsh

    3、在Ubuntu和基于Debian的系统上安装Zsh:

    sudo apt-get install zsh

    4、在Fedora上安装Zsh:

    sudo dnf install zsh

    5、在CentOS和RHEL上安装Zsh

    yum install zsh

    检查并将shell更改为Zsh

    确认已安装并查看已安装的shell列表,在Linux上成功安装Zsh后,你应该看到显示的版本:

    zsh --version

    chsh -l

    安装完成后,我们需要将其设置为默认shell并对其进行自定义以获得额外的视觉效果,我们将为root用户帐户和标准用户帐户更改shell,非root帐户:

    usermod username -s /usr/bin/zsh

    或者:

    chsh -s /usr/bin/zsh username

    root账号:

    su -

    然后:

    chsh /usr/bin/zsh

    3215b0b5a81c75d6735cc7d2d36a12a9.png

    安装Oh My Zsh

    自定义zsh的最简单方法是安装Oh My Zsh来设置zsh主题,Oh My Zsh是一个开源的社区驱动框架,用于管理zsh配置,它配备了大量的插件和主题。

    先决条件:Wget、curl、git。

    确保在系统上安装了所有上述先决条件:

    sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

    安装完成后,将获得一系列随附的主题,位于~/.oh-my-zsh/themes/:

    ls -l ~/.oh-my-zsh/themes/

    184fd370f1a90ff763a19d10b96abb1d.png

    还可以查看插件目录以查看所有可用的插件:

    ls -lh ~/.oh-my-zsh/plugins

    4c77d1b8b9bc8a7e02f59eee0152bb57.png

    为Zsh安装Oh My Zsh主题

    我们将我最喜欢的主题安装到~/.oh-my-zsh/themes/并配置.zshrc来使用它:

    cd ~/.oh-my-zsh/themes/

    git clone https://github.com/oskarkrawczyk/honukai-iterm-zsh.git

    cp honukai-iterm-zsh/honukai.zsh-theme ~/.oh-my-zsh/themes/

    在~/.zshrc中将主题变量名称修改为ZSH_THEME=”honukai”:

    nano ~/.zshrc

    见下面的截图:

    8f276e333b2c1ebda28eb3cee7c9802b.png

    保存更改并退出,快捷键CTRL+X,然后输入Y。

    源~/.zshrc文件:

    source ~/.zshrc

    配置帮助命令

    运行:

    nano ~/.zshrc

    添加以下行到最后:

    autoload -U run-help

    autoload run-help-git

    autoload run-help-svn

    autoload run-help-svk

    alias help=run-help

    源:

    source ~/.zshrc

    Fish-like syntax高亮(可选)

    cd ~/.oh-my-zsh/plugins

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

    nano ~/.zshrc

    在最后添加下面的行:

    source ~/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

    然后源zshrc文件:

    source ~/.zshrc

    持久rehash:这允许compinit在$PATH中自动查找新的可执行文件:

    nano ~/.zshrc

    添加行:

    zstyle ':completion:*' rehash true

    e5087a07567ad55b3d7fc2c8a879abd0.png

    保存并退出,源:

    source ~/.zshrc

    配置适用于所有Linux系统的其他zsh-completions。

    我假设你已经安装了oh-my-zsh,如果不是的话:

    git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions

    然后在.zshrc中启用它:

    nano ~/.zshrc

    增加:

    plugins+=(zsh-completions)

    autoload -U compinit && compinit

    aaf12ce8645f4ab9e3ea56f0ab6f41b9.png

    zsh tab-completion系统

    要启用famous zsh tab-completion系统,需要添加上述命令(autoload -U compinit && compinit)。

    如果运行的是Arch Linux,则可以使用Pacman软件包管理器进行安装:

    pacman -S zsh-completions

    在Gentoo上安装zsh-completions:

    emerge --ask zsh-completions

    在Fedora/CentOS/RHEL/Scientific Linux上安装zsh-completions:

    cd /etc/yum.repos.d/

    wget https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/RHEL_7/shells:zsh-users:zsh-completions.repo

    yum install zsh-completions

    当使用Pacman并emerge时,它将在zshrc文件上自动启用它。

    附:卸载oh-my-zsh类型的方法

    rm -rf ~/.oh-my-zsh

    结语

    上面介绍了如何在Linux上安装Zsh以及如何在系统上配置Zsh环境,Zsh是我用过的最可定制的shell,它可以轻松安装和自定义超过100个主题,有很多插件可以通过像oh-my-zsh这样的框架来扩展它的功能。

    相关主题

    展开全文
  • 文章目录Archlinux中普通用户无法使用root设置zsh主题样式问题分析解决方法1.使用**git**到github上下载。_注意要在普通用户下_2.查看当前主题3.查看可用主题,选取下想用的主题4.编辑配置文件,更换你想用的主题5...

    问题分析

    1.由于Archlinux需要在root权限下使用pacman进行软件包的安装,所以对配置文件 ~/.zshrc 的主题设置也会只在root下才会起作用了

    2.由于你的终端设置的默认shell不是zsh,确保不出问题1的情况下,在终端中设置默认shell。比如你可以验证其他的终端是否一经打开就进入了主题。

    解决方法

    1.使用git到github上下载。注意要在普通用户下

    git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh	
    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    

    或者查看另一位大佬的git,已经为我们搭建好了框架,地址如下:
    oh-my-zsh

    2.查看当前主题

    cat .zshrc | grep THEME
    

    默认情况下是:

    ZSH_THEME="robbyrussell"
    

    注意等号后不要有空格

    3.查看可用主题,选取下想用的主题

    ls ~/.oh-my-zsh/themes
    

    4.编辑配置文件,更换你想用的主题

    #.zshrc是zsh的配置文件
    vim ~/.zshrc
    #记得把多余的语句注释掉
    ZSH_THEME="sunaku" #设置为sunaku主题
    #ZSH_THEME="random" #设置为随机主题,每次都会不一样
    #更新
    source ~/.zshrc
    

    5.到这里基本问题都解决了,如果你的普通用户还是不能使用主题,设置所使用终端的默认shell。可能用到的关于shell的指令:

    #查看可用shell
    cat /etc/shells 
    #查看当前使用的shell
    echo $0
    #查看用户的默认shell
    echo $SHELL
    #将普通用户下的zsh设为默认shell
    chsh -s /usr/bin/zsh 
    #切换bash
    bash
    #切换zsh
    sh
    

    设置终端默认shell以konsole为例,我就是其他的终端都可以,但是konsole不可以,才分析出需要改默认shell。步骤如下
    settings ----> edit current profile…更换Command的shell
    konsole

    展开全文
  • Linuxzsh

    2021-08-24 10:41:48
    现在好多 linux 发行版好像都自带 zsh 的,比如说 centos。 [root@master ~]# chsh -l /bin/sh /bin/bash /usr/bin/sh /usr/bin/bash /usr/bin/tmux /bin/zsh /usr/bin/fish 如果实在没有的话,就用 yum 安装一...
  • root权限的Linux服务器下安装zsh和oh-my-zsh 1.1.修改默认的shell为zsh 1.1.1.本地的WSL中的linux用户 1.1.2.服务器上的linux用户 1.2.修改zsh的主题 2.在~/.zshrc中的一些便捷配置 参考资料1:写的很好 参考博客1...
  • Linuxroot 权限安装 zsh

    千次阅读 2015-12-20 01:47:55
    下面介绍如何在无 root 权限的远程服务器上安装使用 zsh。 downloadmkdir ~/tmp cd ~/tmp wget http://sourceforge.net/projects/zsh/files/zsh/5.0.7/zsh-5.0.7.tar.gz/download 解压tar xzvf zsh-5.0.7.tar.gz ...
  • 安装 zshmkdir zsh && cd zsh # 新建文件夹wget https://sourceforge.net/projects/zsh/files/latest/download # 下载最新版本zshxz -d zsh-5.7.1.tar.xz # .tar.xz 文件需要解压两次tar -xvf zsh-5.7.1....
  • 设置zsh为默认的shell chsh -s /bin/zsh 确保在root权限下切换 二、安装git 一般情况下,如果是买的服务器,默认是会有git的,但是自己装虚拟机还是需要装一下git的 yum install -y git 三、安装oh-my
  • 安装zsh&oh-my-zsh(没有root权限)

    千次阅读 2022-03-16 17:23:54
    oh-my-zsh(没有root权限) 想要安装智能丝滑的oh-my-zsh,首先check是否安装了zshzsh --version 若zsh: command not found,则首先需要安装zsh,否则直接跳至step 2。 step 1 安装zsh # 下载最新的zsh安装包 ...
  • 现在,越来越多的人趋向使用zsh取代原本的bash作为自己的终端Shell。的确,Zsh才是适用于现代的Shell: 更丰富的命令提示 更鲜明的演示标记 更强大的插件支持 什么是zsh 和bash一样,zsh也是终端内的一个命令行...
  • 常用的Bash就是Shell的一种,也是Linux下默认Shell程序。这里介绍一种更强大的、更人性化的Shell——oh-my-zsh。默认 CentOS / Ubuntu / Mac 系统用的是 Bash,倒也不是说 Bash 不好,而是说我们有更好的选择。Zsh...
  • 前言现在,越来越多的人趋向使用zsh取代原本的bash作为自己的终端Shell。的确,Zsh才是适用于现代的Shell:更丰富的命令提示更鲜明的演示标记更强大的插件支持本文章同步发布在:什么是zsh和bash一样,zsh也是终端内...
  • 设置为默认 Shell chsh -s /bin/zsh # 可以通过 echo $SHELL 查看当前默认的 Shell,如果没有改为 /bin/zsh,那么需要重启 Shell。 # 安装完成后,直接用zsh指令就可以切换了 1.2 ...
  • 1.安装 在官网下载源码包:https://sourceforge.net/projects/zsh/ 需要用到源码编译安装,先安装依赖 centos:yum -y install make ncurses-devel ...安装zsh $ tar -zxvfzsh-5.7.1.tar.xz $ ./conf...
  • Linuxzsh(Z shell)

    2020-06-08 16:42:20
    几乎每一款Linux产品都包含有zsh,通常可以用apt-get、urpmi或yum进行安装。 Z shell(zsh[1])是 Linux 和类 Unix 系统中的一个命令解析器[2]。 它跟 sh (Bourne shell) 家族的其它解析器(如 bash 和 ksh)有着...
  • 由于学校或者公司服务器不会给普通用户开通root权限,因此每次新装服务器都需要从非root用户安装配置自己的环境。此篇记录一下linux常用的软件配置和安装。方便重装系统!!! 一、zsh和oh-my-zsh配置 安装zsh mkdir...
  • Linux 配置 oh-my-zsh 总结

    千次阅读 2019-10-29 20:14:48
    文章目录Linux 配置 oh-my-zsh 总结oh my zsh安装 zsh安装 oh my zsh配置 oh-my-zsh关于主题关于插件incrautojumpzsh-autosuggestionsautoswitch_virtualenvzsh-syntax-highlighting参考文章 Linux 配置 oh-my-zsh ...
  • Linux终极shell-zsh的完美配置方案!——oh-my-zsh

    万次阅读 多人点赞 2018-06-07 23:59:17
    Zsh 介绍Zsh 兼容 Bash,据传说 99% 的 Bash 操作 和 Zsh 是相同的Zsh 官网:http://www.zsh.org/先看下你的 Linux支持哪些 shell:cat /etc/shells,正常结果应该是这样的:/bin/sh /bin/bash /sbin/nologin /bin/...
  • windows下WSL基础配置
  • 安装screenroot用户可以直接用yum install screen命令安装screen,但对于非root用户或无网络连接的情况,我们需要使用源码来安装screen。screen下载地址在这里,可选择最新版的下载。这里我选择最新版的screen-4.6.2...
  • linux: 针对所有用户:/etc/profile 针对当前用户:$HOME/.profile 或者 ~/.profile mac: 针对所有用户:/etc/profile 针对当前用户: bash:$HOME/.bash_profile 或者 ~/.bash_profile zsh:$HOME/.zshrc...
  • Linux终极shell-zsh的完美配置方案!——oh-my-zsh 二、遇到的问题 因为配置时不是root用户,用chsh -s /bin/zsh切换到zsh时出现chsh: PAM认证失败的问题 则需要手动改 用sudo vim /etc/passwd找到自己的用户名,我...
  • 安装zsh并修改配置

    千次阅读 2021-04-13 20:01:48
    root 用户 Zsh 介绍 Zsh 兼容 Bash,据传说 99% 的 Bash 操作 和 Zsh 是相同的 Zsh 官网:http://www.zsh.org/ 先看下你的 CentOS 支持哪些 shell:cat /etc/shells,正常结果应该是这样的: /bin/sh ...
  • 对于经常使用终端的用户,我推荐大家都安装Zsh,因为体验更好。本文详细的介绍了macOS、Linux安装Zsh和Oh My Zsh教程。
  • 1.安装zsh: apt install zsh 2. 安装oh-my-zsh: sh -c “$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)” 3. 补充: oh-my-zsh GitHub库地址
  • Lunix简单配置: 换源: 备份原来的文件: sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 编辑/etc/apt/sources.list文件: vim /etc/apt/sources.list 清华源: # 默认注释了源码镜像以提高 apt update ...
  • zsh 介绍Linux ShellLinux/Unix提供了很多种Shell,常用的Shell有这么几种,sh、bash、csh等,想知道你的系统有几种shell,可以通过以下命令查看:[root@iZ216d96ogsz ~]# cat /etc/shells/bin/sh/bin/bash/sbin/...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 6,959
精华内容 2,783
关键字:

linux root配置 zsh