0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

はじめに

この記事は、Qiita Advent Calendar 15日目の記事です。
以下の記事より、すべての記事をご覧になれます。

筆者について

  • 現在高校2年生
  • 水泳部マネージャー
  • 生徒会長
  • とある団体の代表

本編

本日はターミナル関連の年末大整理を実施したいと思います。

~/.zshrc

~/.zshrc
PROMPT="%F{green}%n%f%F{cyan}($(arch))%f:%F{blue}%c"$"%# "%f
export PATH=/Users/koki/tools/firebase-tools-maxos:$PATH
eval export PATH="/Users/koki/.nodenv/shims:${PATH}"
export NODENV_SHELL=zsh
eval "$(rbenv init - zsh)"
source '/opt/homebrew/Cellar/nodenv/1.4.1/libexec/../completions/nodenv.zsh'
command nodenv rehash 2>/dev/null
nodenv() {
  local command
  command="${1:-}"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval "$(nodenv "sh-$command" "$@")";;
  *)
    command nodenv "$command" "$@";;
  esac
}
eval "$(anyenv init -)"
 export PATH="$PATH":"$HOME/.pub-cache/bin"
export PATH="$HOME/.nodenv/bin:$PATH"
eval "$(nodenv init -)"
alias nswitch="source ~/.switch_proxy"
nswitch
export MODULAR_HOME="/Users/koki/.modular"
export PATH="/Users/koki/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
export MOJO_PYTHON_LIBRARY="/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib"
source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"

# bun completions
[ -s "/Users/koki/.bun/_bun" ] && source "/Users/koki/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

色々ごちゃごちゃなってて分かりません。とりあえず、整理しますか。

~/.zshrc
#PROMPT Configure
PROMPT="%F{green}%n%f%F{cyan}($(arch))%f:%F{blue}%c"$"%# "%f

# PATH
export PATH=/Users/koki/tools/firebase-tools-maxos:$PATH
export PATH="$PATH":"$HOME/.pub-cache/bin"
export PATH="$HOME/.nodenv/bin:$PATH"
eval export PATH="/Users/koki/.nodenv/shims:${PATH}"

export NODENV_SHELL=zsh
eval "$(rbenv init - zsh)"
source '/opt/homebrew/Cellar/nodenv/1.4.1/libexec/../completions/nodenv.zsh'
command nodenv rehash 2>/dev/null
nodenv() {
  local command
  command="${1:-}"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval "$(nodenv "sh-$command" "$@")";;
  *)
    command nodenv "$command" "$@";;
  esac
}
eval "$(anyenv init -)"
eval "$(nodenv init -)"

#Mojo
export MODULAR_HOME="/Users/koki/.modular"
export PATH="/Users/koki/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
export MOJO_PYTHON_LIBRARY="/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib"

# bun completions
[ -s "/Users/koki/.bun/_bun" ] && source "/Users/koki/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

#GCP
source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"

#Other
alias nswitch="source ~/.switch_proxy"
nswitch

ここで少しだけそれぞれの意味を若干。

  • exportは環境変数の設定をします
  • evalは引数に指定されたプログラムの実施をします

ということで、これらの再配置とPATHを一番最後に持ってきました。

~/.zshrc
# PATH
#PROMPT Configure
PROMPT="%F{green}%n%f%F{cyan}($(arch))%f:%F{blue}%c"$"%# "%f

#Nodenv Connfigure
export NODENV_SHELL=zsh
eval "$(rbenv init - zsh)"
source '/opt/homebrew/Cellar/nodenv/1.4.1/libexec/../completions/nodenv.zsh'
command nodenv rehash 2>/dev/null
nodenv() {
  local command
  command="${1:-}"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval "$(nodenv "sh-$command" "$@")";;
  *)
    command nodenv "$command" "$@";;
  esac
}
eval "$(nodenv init -)"

#Anyenv Configure
eval "$(anyenv init -)"

#Mojo
export MODULAR_HOME="/Users/koki/.modular"
export MOJO_PYTHON_LIBRARY="/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib"

# bun completions
[ -s "/Users/koki/.bun/_bun" ] && source "/Users/koki/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"

#GCP
source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"

#Other
alias nswitch="source ~/.switch_proxy"
nswitch

# PATH
export PATH=/Users/koki/tools/firebase-tools-maxos:$PATH
export PATH="$HOME/.pub-cache/bin:$PATH"
export PATH="$HOME/.nodenv/bin:$PATH"
export PATH="/Users/koki/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
export PATH="$BUN_INSTALL/bin:$PATH"
export PATH="/Users/koki/.nodenv/shims:${PATH}"

プラグインのインストール

zsh-autosuggestionsとzsh-completionsをインストールします。

shell
brew install zsh-completion; brew install zsh-autosuggestions;

そして、インストール時に出てきたメッセージ通りに~/.zshrcに追記します。

最終的には以下の通りになりました。

~/.zshrc
#PROMPT Configure
PROMPT="%F{green}%n%f%F{cyan}($(arch))%f:%F{blue}%c"$"%# "%f

#Nodenv Connfigure
export NODENV_SHELL=zsh
eval "$(rbenv init - zsh)"
source '/opt/homebrew/Cellar/nodenv/1.4.1/libexec/../completions/nodenv.zsh'
command nodenv rehash 2>/dev/null
nodenv() {
  local command
  command="${1:-}"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval "$(nodenv "sh-$command" "$@")";;
  *)
    command nodenv "$command" "$@";;
  esac
}
eval "$(nodenv init -)"

#Anyenv Configure
eval "$(anyenv init -)"

#Mojo
export MODULAR_HOME="/Users/koki/.modular"
export MOJO_PYTHON_LIBRARY="/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib"

# bun completions
[ -s "/Users/koki/.bun/_bun" ] && source "/Users/koki/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"

#GCP
source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc"
source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc"

#Other
alias nswitch="source ~/.switch_proxy"
nswitch

#zsh-completions
if type brew &>/dev/null; then
    FPATH=$(brew --prefix)/share/zsh-completions:$FPATH

    autoload -Uz compinit
    compinit
fi

#zsh-autosuggestions
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# PATH
export PATH=/Users/koki/tools/firebase-tools-maxos:$PATH
export PATH="$HOME/.pub-cache/bin:$PATH"
export PATH="$HOME/.nodenv/bin:$PATH"
export PATH="/Users/koki/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
export PATH="$BUN_INSTALL/bin:$PATH"
export PATH="/Users/koki/.nodenv/shims:${PATH}"

とりあえずターミナルの整理は完了です!

最後に

もうそろそろ来月以降の活動の用意ということで、今後はパソコンの整理の記事がいくつか続くと思いますが、少々お付き合いください。ということで、今後のアドカレ 23 の記事をお楽しみにしてください。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?