Add init file timings and lazy load ros2 stuff
This commit is contained in:
parent
561596711f
commit
b85772067d
16
init.zsh
16
init.zsh
@ -1,5 +1,8 @@
|
|||||||
# Main zsh config file
|
# Main zsh config file
|
||||||
|
|
||||||
|
zmodload zsh/datetime
|
||||||
|
let __init_zsh_start="${EPOCHREALTIME}"
|
||||||
|
|
||||||
# Enable completions
|
# Enable completions
|
||||||
FPATH="${HOME}/.local/share/zsh/site-functions:${FPATH}"
|
FPATH="${HOME}/.local/share/zsh/site-functions:${FPATH}"
|
||||||
autoload -U compinit && compinit
|
autoload -U compinit && compinit
|
||||||
@ -255,6 +258,12 @@ source "${ZSH_CONFIG_DIR}/emacs-bookmark.zsh"
|
|||||||
# Platform specific stuff
|
# Platform specific stuff
|
||||||
[ -f /usr/bin/pacman ] && source "${ZSH_CONFIG_DIR}/arch.zsh"
|
[ -f /usr/bin/pacman ] && source "${ZSH_CONFIG_DIR}/arch.zsh"
|
||||||
|
|
||||||
|
# Ros2 instll on arch
|
||||||
|
if [[ -d /opt/ros/humble/ ]]; then
|
||||||
|
ZSH_ROS2_ROOT=/opt/ros/humble/
|
||||||
|
source "${ZSH_CONFIG_DIR}/lazy-ros2.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
# FZF Integration
|
# FZF Integration
|
||||||
load_plugin fzf-tab
|
load_plugin fzf-tab
|
||||||
# Disable sort when completing `git checkout`
|
# Disable sort when completing `git checkout`
|
||||||
@ -308,7 +317,7 @@ setopt histignoredups
|
|||||||
|
|
||||||
# Run fortune and cowsay if we are not in nvim or ssh
|
# Run fortune and cowsay if we are not in nvim or ssh
|
||||||
if cmd_exists fortune && cmd_exists cowsay; then
|
if cmd_exists fortune && cmd_exists cowsay; then
|
||||||
[[ -v NVIM ]] || [[ -v SSH_CLIENT ]] || \
|
[[ -v NVIM ]] || [[ -v SSH_CLIENT ]] || [[ -v INSIDE_EMACS ]] || \
|
||||||
fortune | cowsay -felephant-in-snake -n
|
fortune | cowsay -felephant-in-snake -n
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -316,3 +325,8 @@ fi
|
|||||||
unfunction load_plugin
|
unfunction load_plugin
|
||||||
unfunction cmd_exists
|
unfunction cmd_exists
|
||||||
unfunction source_user_file
|
unfunction source_user_file
|
||||||
|
|
||||||
|
(( ZSH_INIT_TIME="${EPOCHREALTIME}" - __init_zsh_start ))
|
||||||
|
function zsh-init-time {
|
||||||
|
printf 'Zsh initialization took: %05fms\n' "$(( ZSH_INIT_TIME * 1000 ))"
|
||||||
|
}
|
||||||
|
32
lazy-ros2.zsh
Normal file
32
lazy-ros2.zsh
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Lazy-load ros2 stuff
|
||||||
|
|
||||||
|
(( ${+ZSH_ROS2_ROOT} )) || return
|
||||||
|
|
||||||
|
local defined=()
|
||||||
|
|
||||||
|
local file
|
||||||
|
for file in "${ZSH_ROS2_ROOT}/bin/"*; do
|
||||||
|
local base="${file:t}"
|
||||||
|
hash -- "${base}" 2>/dev/null && continue
|
||||||
|
defined+=("${base}")
|
||||||
|
done
|
||||||
|
|
||||||
|
local undef_args=() def
|
||||||
|
for def in ${defined}; do
|
||||||
|
undef_args+=("${(q)def}")
|
||||||
|
done
|
||||||
|
|
||||||
|
local exec
|
||||||
|
for exec in ${defined}; do
|
||||||
|
eval "
|
||||||
|
function \${(q)exec} {
|
||||||
|
printf 'Setting up ros2 with \"%s\"...\n\n' \\
|
||||||
|
\"\${(q)ZSH_ROS2_ROOT%/}/setup.zsh\"
|
||||||
|
unfunction ${undef_args}
|
||||||
|
source \${(q)ZSH_ROS2_ROOT}/setup.zsh ||
|
||||||
|
{ echo 'Failed to load ros2 libraries!'; return }
|
||||||
|
(( \${#} == 0 )) && ${(q)exec} || ${(q)exec} \"\${@}\"
|
||||||
|
}"
|
||||||
|
done
|
||||||
|
|
||||||
|
unset exec def file defined undef_args
|
Loading…
x
Reference in New Issue
Block a user