MacOS OSXインストールoh-my-zsh autojump

5918 ワード

[TOC]

zsh+oh-my-zsh


oh-my-zsh紹介


oh-my-zshはzshの機能に基づいて拡張され、便利なプラグイン管理、テーマのカスタマイズ、およびきれいな自動完成効果です.

まずzshを取り付けます

brew info zsh
brew install zsh

oh-my-zshの再インストール

curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

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

zshバージョンの表示

zsh --version

現在のデフォルトbash

echo $SHELL

zshが/etc/shelsリストでデフォルトshellを変更していることを確認します。


現在のshellをチェックします
cat /etc/shells
chsh -s /bin/zsh
、すでにzshであることを確認すればいいです

ヒントchsh:no changes made解決方法

chsh -s /bin/zsh
dscl . -read /Users/$USER/ UserShell
exec su - $USER

zsh互換bash_profile


zshはユーザーディレクトリの下の.bash_profile.bashrc を読み取らず、~/.bash_profileでやるべきことを~/.zshrcに書きます.
あるいは、~/.zshrcに手動でsourceコマンドを使用して~/.bash_profileを実行することもできます.

エラーの可能性があるErrorのインストール


.zshrc:3: command not found: ^M


The temporary solution to that is changing your core.autocrlf git config setting to use input, given that you are on OSX. See #4402 (comment).
cd $ZSH
git config core.autocrlf input
git rm --cached -r .
git reset --hard

oh-my-zsh.sh: : parse error near ~/.zshrc after Upgrade

vi the ~/.gitconfig file and set the autocrlf = false. then it works

Git clone errors if .gitconfig specifies autocrlf = true #4069

PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set


PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set
Add RVM set at source ~/.bash_profile
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

一般的なalias構成

# alias base
alias free='top -l 1 | head -n 10 | grep PhysMem'
alias ls='ls -hG'
alias ll='ls -l'
alias la='ls -a'
alias l='ls -CF'
alias cls='clear'
alias gs='git status'
alias gc='git commit'
alias gqa='git add .'

# alias docker
alias dkst="docker stats"
alias dkps="docker ps"
alias dkpsa="docker ps -a"
alias dkimgs="docker images"
alias dkcpup="docker-compose up -d"
alias dkcpdown="docker-compose down"
alias dkcpstart="docker-compose start"
alias dkcpstop="docker-compose stop"

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

zshプラグイン設定

||ファイルの~/.zshrcという部分を修正します.
これは私のプラグインです.
plugins=(
  zsh_reload
  git
  osx
  brew
  colored-man-pages
  sudo
  autojump
  zsh-autosuggestions
)

プラグインのリストの表示
ls ~/.oh-my-zsh/plugins | grep [pluginsName]

再プラグインは、最も前に~/.zshrcを追加してプラグインを無効にすることができます.
  • osx OSXでプラグインを有効にするには、必ずこの構成
  • に参加してください.
  • zsh_reload、これはsrcのaliasを追加して、再びreload zshをreloadすることができて、特に1つの新しいプログラムがインストールする時、zshはbashのようにすぐに新しいコマンド
  • を識別することができません
  • autojumpはautojumpと協力してjコマンドを使用して直接あるディレクトリ
  • に入ります.
  • zsh-syntax-highlighting、これはあなたがコマンドを入力している間に、緑を表示して、このコマンドが有効な存在であることを示して、赤を表示してこのコマンドがシステムの中で存在しないことを示して、もちろんこれらだけではありません.
  • brewこの2つはOS Xのbrewに補完を加えたものである.このシステム以外は書いてください!brew-cask !brew
  • cored-man-pagesはその名の通り、カラーのmanが素晴らしい!
  • sudoコマンドを入力するとroot権限が必要で、通常は方向にキーを押すしかなく、カーソルを頭に移動してsudoに参加しますが、このプラグインがあれば、カーソルを頭に移動する必要はありません.直接ESCを2回押すと、sudoは自動的に一番前に参加します.

  • 自動プロンプトコマンドzsh-autosuggestions


    コマンドを入力すると、端末は次に入力するコマンドを自動的にプロンプトします.
  • クローニング倉庫からローカルplugins=(git)へのパス
  • git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
    
    !に追加
    plugins=(
      zsh-autosuggestions
    )
    

    変化が見えないかもしれませんが、フォントの色が薄いかもしれません.
    vim ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
    

    修正~/.oh-my-zsh/custom/plugins

    構文ハイライト


    zsh-syntax-highlightingインストールソースコードと管理ツールインストール
    # if use brew install
    brew install zsh-syntax-highlighting
    echo "source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
    
    # use git install
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
    echo "source \$ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
    

    プラグインの推奨

  • rsyncはいくつかのrsyncのaliasを増加させ、操作を簡略化した
  • zsh美化


    テーマのプレビュー
    https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes
    テーマ~/.zshrc ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10' robbyrussell dst agnoster試してみてください

    Autojump構成

    duelljにのみプラグインが配置されています
    plugins=(
      git
      zsh_reload
      autojump
    )
    

    Autojumpがインストールされていないと使用できません
    brew install autojump
    

    インストールが完了すると、zshが使用されているため、次の構成をzshに追加します.
    # env of autojump
    [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
    

    設定が完了すると、構成~/.bash_profileがロードされ、source ~/.bash_profileを使用してジャンプできます.
    Autojumpはcdに基づいて行った経路であり,行ったことのない経路では短書きジャンプができない
    パスジャンプエラーは、j [ ]を使用してエラーパスをクリーンアップできます.