小编Avn*_*arr的帖子

从 bash_profile 在后台获取长时间运行的脚本

.bash_profile每次打开终端时,我的脚本都需要几秒钟才能运行,因此这变得非常烦人。

我的测试表明某些命令需要很长时间,因此我将它们移出到.bash_profile新脚本中.bash_profile_load_in_background

.bash_profile我正在尝试在后台寻找来源。

.bash_profile

# fast stuff here

#.....

# slow stuff here

source .bash_profile_load_in_background & # notice the &

Run Code Online (Sandbox Code Playgroud)

我正在设置一些变量,但当发送到后台.bash_profile_load_in_background时它们没有正确传播。source&

这是我的“慢”脚本的删节版本:

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

if type brew &>/dev/null; then
  HOMEBREW_PREFIX="$(brew --prefix)"
  if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
    source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
  else
    for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*; do
      [[ -r "$COMPLETION" ]] && …
Run Code Online (Sandbox Code Playgroud)

bash background-process

3
推荐指数
1
解决办法
1601
查看次数

标签 统计

background-process ×1

bash ×1