romkatv / powerlevel10k

A Zsh theme
MIT License
44.4k stars 2.12k forks source link

some source is not working when I enable instant prompt #2488

Closed zhuzy-2018 closed 7 months ago

zhuzy-2018 commented 7 months ago

some of my source action is not working when I enable instrant prompt, such like, source /etc/grc.zsh and source setup.zsh of ros in a function.

Strangely, source works when I source .zshrc in the terminal.

below is my .zshrc

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/home/zhuzy/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git
    zsh-syntax-highlighting
    zsh-autosuggestions
#   zsh-autocomplete
    autojump
    grc)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
[[ -s "/etc/grc.zsh" ]] && source /etc/grc.zsh
source ~/.oh-my-zsh/plugins/incr/incr-0.2.zsh 
source ~/.bash_profile
# added by Anaconda3 5.3.1 installer#not actually is by me 
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/zhuzy/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/home/zhuzy/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/zhuzy/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/home/zhuzy/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

eval $(thefuck --alias)

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# set plugin auto-suggestion key bind
bindkey '^H' autosuggest-clear
#bindkey '^n' expand-or-complete
#bindkey '^p' reverse-menu-complete

#zsh-autocomplete settings
#bindkey '\t' menu-complete "$terminfo[kcbt]" reverse-menu-complete
#bindkey '\t' menu-select "$terminfo[kcbt]" menu-select
#bindkey -M menuselect '\t' menu-complete "$terminfo[kcbt]" reverse-menu-complete
#bindkey '^I'   complete-word       # tab          | complete
#bindkey '^[[Z' autosuggest-accept  # shift + tab  | autosuggest

#ros setup
function sourceROS1(){
source /opt/ros/noetic/setup.zsh
#source /home/zhuzy/localization_ws/devel/setup.zsh 
#source /home/zhuzy/turtlebot_sim_ws/devel/setup.zsh 
export ROS_MASTER_URI=http://localhost:11311
export ROS_IP=127.0.0.1
#source ~/carto_slam_ws/install_isolated/setup.zsh
#export TURTLEBOT3_MODEL=burger
source /home/zhuzy/slam_ws/devel/setup.zsh 
source /datadisk/slam_learn_ws/devel/setup.zsh
source /datadisk/advanced_slam_ws/devel/setup.zsh
}

# choose which qt to be used
#export CMAKE_PREFIX_PATH=/home/zhuzy/Qt5.12.0/5.12.0/gcc_64:$CMAKE_PREFIX_PATH
#export QT_SELECT=qt5.12.0
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/zhuzy/Qt5.12.0
#export QT_SELECT=5
setopt no_nomatch #make * as param available

#ros2 configure
function sourceROS2(){
source /opt/ros/foxy/setup.zsh
# connext rmw setting
export RTI_LICENSE_FILE=path/to/rti_license.dat
source /opt/rti.com/rti_connext_dds-5.3.1/resource/scripts/rtisetenv_x64Linux3gcc5.4.0.bash 2>&1 > /dev/null
export NDDSHOME=/opt/rti.com/rti_connext_dds-5.3.1
export CONNEXTDDS_DIR=${NDDSHOME}
#setup colcon_cd
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=~/ros2_install
#setup colcon completion
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.zsh
#resolve auto complete bug
#eval "$(register-python-argcomplete3 ros2)"
eval "$(register-python-argcomplete3 colcon)"

#self workspace
#source ~/ros2_ws/install/setup.zsh
source /home/zhuzy/carla-ros-bridge/install/setup.zsh
source /home/zhuzy/ground_manifold_ws/install/setup.zsh
source /datadisk/ros2_lidar_ws/install/setup.zsh
}

sourceROS1
#sourceROS2
source /datadisk/slam_learn_ws/devel/setup.zsh
source /datadisk/advanced_slam_ws/devel/setup.zsh
export COLCON_HOME=~/.colcon
eval "$(register-python-argcomplete3 colcon)"
# carla
export CARLA_ROOT=/opt/carla-simulator
export PYTHONPATH=$PYTHONPATH:$CARLA_ROOT/PythonAPI/carla/dist/carla-0.9.13-py3.7-linux-x86_64.egg:$CARLA_ROOT/PythonAPI/carla
alias carla_run=/opt/carla-simulator/CarlaUE4.sh
#export http_proxy="socks5://127.0.0.1:1080"
#export https_proxy="socks5://127.0.0.1:1080"
export PATH=/usr/bin:$PATH
export PATH=/usr/local/sunlogin/bin:$PATH
eval "`pip completion --zsh`"
alias nv='neovide'

# cuda setting
export PATH=/usr/local/cuda/bin:$PATH   
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH 
export LIBRARY_PATH=/usr/local/cuda/lib64:$LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda:$CUDA_HOME

another strange thing is source /opt/ros/noetic/setup.zsh in function sourceROS1 seems work, however source /datadisk/slam_learn_ws/devel/setup.zsh in the same function didn't work. And if I write it out of the function it works again.

romkatv commented 7 months ago

If some command in your .zshrc does not work with instant prompt, move it to the top of the file. See https://github.com/romkatv/powerlevel10k#how-do-i-configure-instant-prompt or https://github.com/romkatv/zsh-bench#instant-prompt for details.

another strange thing is source /opt/ros/noetic/setup.zsh in function sourceROS1 seems work, however source /datadisk/slam_learn_ws/devel/setup.zsh in the same function didn't work. And if I write it out of the function it works again.

What happens if you disable powerlevel10k? Does that help?

zhuzy-2018 commented 7 months ago

you mean disable p10k instant prompt? yes disable it will make every source action work.

---- Replied Message ---- | From | Roman @.> | | Date | 11/20/2023 16:38 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [romkatv/powerlevel10k] some source is not working when I enable instant prompt (Issue #2488) |

If some command in your .zshrc does not work with instant prompt, move it to the top of the file. See https://github.com/romkatv/powerlevel10k#how-do-i-configure-instant-prompt or https://github.com/romkatv/zsh-bench#instant-prompt for details.

another strange thing is source /opt/ros/noetic/setup.zsh in function sourceROS1 seems work, however source /datadisk/slam_learn_ws/devel/setup.zsh in the same function didn't work. And if I write it out of the function it works again.

What happens if you disable powerlevel10k? Does that help?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

romkatv commented 7 months ago

My response has two parts. The second part answers the question of yours that I quoted.

zhuzy-2018 commented 7 months ago

If some command in your .zshrc does not work with instant prompt, move it to the top of the file. See https://github.com/romkatv/powerlevel10k#how-do-i-configure-instant-prompt or https://github.com/romkatv/zsh-bench#instant-prompt for details.

another strange thing is source /opt/ros/noetic/setup.zsh in function sourceROS1 seems work, however source /datadisk/slam_learn_ws/devel/setup.zsh in the same function didn't work. And if I write it out of the function it works again.

What happens if you disable powerlevel10k? Does that help?

YES! change the theme does help. But I'd like to use p10k as my theme ,what should I do?

romkatv commented 7 months ago

what should I do?

Please see my first comment and try doing what it says.

zhuzy-2018 commented 7 months ago

what should I do?

Please see my first comment and try doing what it says.

I'm sorry, my thinking was a bit rigid. However, thank you very much. I have completely resolved this issue!