mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
To activate conda on **nix, we provide a path to `active` script and a path to the env directory. Terminal shell integration scripts then "source" `activate` providing an env path as an argument. The latter is called `JEDITERM_SOURCE` env var, the former is `JEDITERM_SOURCE_ARGS`. The problem is those integration scripts treat `JEDITERM_SOURCE_ARGS` as a list, so they use shell magic to break it into several arguments, so `/path/foo bar/` effectively presented as `['/path/foo', 'bar/']`. To fix it, we introduce the ` JEDITERM_SOURCE_SINGLE_ARG ` key which means "do not explode argument." (cherry picked from commit a0a7c7a7bc8789078dd6cf109f4fd4386c9b7da6) IJ-MR-159065 PY-78762: Activate conda in Powershell. We used to use `Invoke-Expression` but then migrated to `&`. However, a conda activation script is a command (code block), not a file, so we need to use `Invoke-Expression` as '&' doesn't support it. We check if a file exists, and if it does -- we use '&' which is safe and fast. We use `Invoke-Expression` otherwise. Merge-request: IJ-MR-158505 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> PY-78762 (partially): Conda activation for PS cleanup: 1. Use a conda path from SDK 2. report error using echo Merge-request: IJ-MR-160629 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> GitOrigin-RevId: b16bd0b1babb1ea3b685daa5697426418356d089
106 lines
2.8 KiB
Bash
106 lines
2.8 KiB
Bash
#!/bin/bash
|
|
|
|
if [ -n "$LOGIN_SHELL" ]; then
|
|
unset LOGIN_SHELL
|
|
|
|
# When bash is invoked as an interactive login shell, or as a non-interac-
|
|
# tive shell with the --login option, it first reads and executes commands
|
|
# from the file /etc/profile, if that file exists. After reading that
|
|
# file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in
|
|
# that order, and reads and executes commands from the first one that
|
|
# exists and is readable.
|
|
|
|
if [ -f /etc/profile ]; then
|
|
source /etc/profile
|
|
fi
|
|
|
|
if [ -f ~/.bash_profile ]; then
|
|
source ~/.bash_profile
|
|
else
|
|
if [ -f ~/.bash_login ]; then
|
|
source ~/.bash_login
|
|
else
|
|
if [ -f ~/.profile ]; then
|
|
source ~/.profile
|
|
fi
|
|
fi
|
|
fi
|
|
else
|
|
if [ -f ~/.bashrc ]; then
|
|
source ~/.bashrc
|
|
fi
|
|
fi
|
|
|
|
function override_jb_variables {
|
|
while read VARIABLE
|
|
do
|
|
NAME=${VARIABLE%%=*}
|
|
if [[ $NAME = '_INTELLIJ_FORCE_SET_'* ]]
|
|
then
|
|
NEW_NAME=${NAME:20}
|
|
if [ -n "$NEW_NAME" ]
|
|
then
|
|
VALUE=${VARIABLE#*=}
|
|
export "$NEW_NAME"="$VALUE"
|
|
fi
|
|
fi
|
|
if [[ $NAME = '_INTELLIJ_FORCE_PREPEND_'* ]]
|
|
then
|
|
NEW_NAME=${NAME:24}
|
|
if [ -n "$NEW_NAME" ]
|
|
then
|
|
VALUE=${VARIABLE#*=}
|
|
export "$NEW_NAME"="$VALUE${!NEW_NAME}"
|
|
fi
|
|
fi
|
|
done < <(env)
|
|
}
|
|
|
|
override_jb_variables
|
|
|
|
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
|
|
bind '"\e\e[C":forward-word'
|
|
bind '"\e\e[D": backward-word'
|
|
bind '"\e\O[C":forward-word'
|
|
bind '"\e\O[D": backward-word'
|
|
|
|
if [ -n "${JEDITERM_USER_RCFILE-}" ]
|
|
then
|
|
source "$JEDITERM_USER_RCFILE"
|
|
unset JEDITERM_USER_RCFILE
|
|
fi
|
|
|
|
if [ -n "${JEDITERM_SOURCE-}" ]
|
|
then # JEDITERM_SOURCE_ARGS might be either list of args or one arg depending on JEDITERM_SOURCE_SINGLE_ARG
|
|
if [ -n "${JEDITERM_SOURCE_SINGLE_ARG}" ]; then
|
|
source "$JEDITERM_SOURCE" "${JEDITERM_SOURCE_ARGS}"
|
|
else
|
|
source "$JEDITERM_SOURCE" ${JEDITERM_SOURCE_ARGS-}
|
|
fi
|
|
unset JEDITERM_SOURCE
|
|
unset JEDITERM_SOURCE_ARGS
|
|
fi
|
|
|
|
function configureCommandHistory {
|
|
local commandHistoryFile="$__INTELLIJ_COMMAND_HISTFILE__"
|
|
unset __INTELLIJ_COMMAND_HISTFILE__
|
|
if [ -n "$commandHistoryFile" ] && [ -z "`trap -p EXIT`" ]
|
|
then
|
|
trap "$(builtin printf 'history -w %q; HISTFILE=%q' "$commandHistoryFile" "$HISTFILE")" EXIT
|
|
if [ -s "$commandHistoryFile" ]
|
|
then
|
|
HISTFILE="$commandHistoryFile"
|
|
fi
|
|
fi
|
|
}
|
|
configureCommandHistory
|
|
|
|
JETBRAINS_INTELLIJ_BASH_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
|
if [ -r "${JETBRAINS_INTELLIJ_BASH_DIR}/command-block-support.bash" ]; then
|
|
source "${JETBRAINS_INTELLIJ_BASH_DIR}/command-block-support.bash"
|
|
fi
|
|
if [ -r "${JETBRAINS_INTELLIJ_BASH_DIR}/command-block-support-reworked.bash" ]; then
|
|
source "${JETBRAINS_INTELLIJ_BASH_DIR}/command-block-support-reworked.bash"
|
|
fi
|
|
unset JETBRAINS_INTELLIJ_BASH_DIR
|