Ubuntu miniconda3環境でコマンドラインを調整する方法は?

Ubuntu miniconda3環境でコマンドラインを調整する方法は?

Ubuntu(WSL2)でminiconda3環境を有効にすると、コマンドラインも変更されます。有効にする前に、私のコマンドラインはファイルに変数を定義したようですPS1.bashrc

username@workingdirectory$

起動後のコマンドラインは次のようになります。

(base)username@pc:/path/working/directory$

色の変更が含まれます。

コマンドラインがオリジナル(カラーを含む)と似ているようにしたいと思います。コマンドラインの最後に現在のconda環境の名前を追加するだけです。たとえば、 username@workingdirectory (base)$

changeps1で設定しましたが、falseコマンド.condarcラインからconda環境のみを削除し、残りのコマンドライン(色付き)は引き続き変更します。

私が望むようにconda環境でコマンドラインを調整する方法を知っている人はいますか?

@ Edgar Magallanの回答に従うように編集されました$HOME/miniconda3/bin/activate

#!/bin/sh
_CONDA_ROOT="/home/username/miniconda3"
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$@"

conda.sh編集2:私のファイルにはPS1が言及されている2つの場所があります。

__conda_activate() {
if [ -n "${CONDA_PS1_BACKUP:+x}" ]; then
    # Handle transition from shell activated with conda <= 4.3 to a subsequent activation
    # after conda updated to >= 4.4. See issue #6173.
    PS1="$CONDA_PS1_BACKUP"
    \unset CONDA_PS1_BACKUP
fi
\local ask_conda
ask_conda="$(PS1="${PS1:-}" __conda_exe shell.posix "$@")" || \return
\eval "$ask_conda"
__conda_hashr
}

そして:

if [ -z "${CONDA_SHLVL+x}" ]; then
   \export CONDA_SHLVL=0
   # In dev-mode CONDA_EXE is python.exe and on Windows
   # it is in a different relative location to condabin.
   if [ -n "${_CE_CONDA:+x}" ] && [ -n "${WINDIR+x}" ]; then
       PATH="$(\dirname "$CONDA_EXE")/condabin${PATH:+":${PATH}"}"
   else
       PATH="$(\dirname "$(\dirname "$CONDA_EXE")")/condabin${PATH:+":${PATH}"}"
   fi
   \export PATH

   # We're not allowing PS1 to be unbound. It must at least be set.
   # However, we're not exporting it, which can cause problems when starting a second shell
   # via a first shell (i.e. starting zsh from bash).
   if [ -z "${PS1+x}" ]; then
       PS1=
   fi
fi

ベストアンサー1

おすすめ記事