2022-03-19 04:34:14 +01:00
|
|
|
#!/usr/bin/env zsh
|
2022-03-19 03:54:51 +01:00
|
|
|
# Export variable to Emacs.
|
|
|
|
|
2022-04-03 05:47:50 +02:00
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
|
2022-03-19 04:34:14 +01:00
|
|
|
if [[ ARGC -eq 0 ]]; then
|
|
|
|
print -u 2 "Usage: ${0} <variable> …"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fail if we can't communicate with the daemon
|
|
|
|
[[ "$(emacsclient -e t)" == 't' ]] || return 1
|
2022-03-19 03:54:51 +01:00
|
|
|
|
2022-03-19 04:34:14 +01:00
|
|
|
for name in "${@}"; do
|
2022-03-19 04:38:23 +01:00
|
|
|
local value=$(eval print \"\$${name}\")
|
2022-03-19 04:34:14 +01:00
|
|
|
emacsclient -e "(setenv \"${name}\" \"${value}\")" >/dev/null
|
|
|
|
done
|