bluesky / yaqc-bluesky

A bluesky interface to the yaq instrument control framework.
https://yaq.fyi/
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

Happi doesn't activate on zsh shell macOS M1 #100

Open nfortune opened 5 months ago

nfortune commented 5 months ago

MacOS for M1 recommends use of zsh rather than bash and selects zsh as its default shell . Happi appears to require bash shell. Will yaqc-bluesky still work without Happi activation or should I switch from zsh to bash?

The Happi.sh code follows below:

#!/bin/bash
# This activates fzf-based fuzzy finding for happi searches.
# This is meant to be sourced from bash.

if [[ "${BASH}" =~ .*"bash" ]]; then
    # Do nothing
    :
else
    echo "'happi' activation: only bash shell is supported. Used shell: ${BASH}"
    return
fi

_fzf_complete_happi() {
  _fzf_complete --multi --reverse --prompt="happi> " -- "$@" < <(
    python `which happi` search '*' --json 2>/dev/null | python -c '
import json
import sys
items = json.load(sys.stdin)
for item in items:
    print(item["name"])
'

  )
}

[ -n "$BASH" ] && complete -F _fzf_complete_happi -o default -o bashdefault happi
ksunden commented 5 months ago

This is a completely optional additional feature of upstream happi installing a hook for fzf, a fuzzy search cli program.

If you do not already use fzf, I certainly would not worry about it at all.

If you do use fzf, I think there should be a way to install the correct hook for zsh, and I have a strong suspicion upstream would be willing to add it.

The file that looks substantially the same in the happi repo is https://github.com/pcdshub/happi/blob/master/conda-recipe/activate.sh Which I will note seems to be:

Regardless, even here happi integration is a small add on that is absolutely no requirement.

untzag commented 5 months ago

Can you say a bit more @nfortune? Are you running into an error or warning while trying to use yaqc-bluesky?