Running custom zsh function for tmux status bar not displaying output -


i'm wrote function called test_status trying incorporate in tmux status bar. give background, tests output file called .guard_result either success or failure , test_status function reads file , echoes 💚 if tests passing , ❤️ if failing.

the news running test_status works fine, i'm having trouble getting work tmux. missing here?

#  ~/.oh-my-zsh/custom/aliases.zsh  function test_status {   if [ ! -f "./.guard_result" ];     echo "?"     return 1   fi    result="$(cat ./.guard_result)"    if [[ $result == *"success"* ]]       echo "💚";   elif [[ $result == *"fail"* ]]       echo "❤️";   fi } 

this function works... here tmux configuration (which doesn't show result):

# ~/.tmux.conf  set -g status-right "#(test_status) #[fg=colour245]%d %b %y #[fg=white]:: #[fg=colour245]%l:%m %p" 

i know must missing simple... help!

tmux passes shell commands /bin/sh not zsh. , if tmux use zsh, function not available in context ~/.zshrc, loads oh-my-zsh, read interactive shells.

in order the output of test_status tmux, suggest put function zsh script , call that.

you can either source ~/.oh-my-zsh/custom/aliases.zsh within script , call test_status:

#!/usr/bin/zsh #  ^ make sure reflects path zsh (`type zsh`)  source ~/.oh-my-zsh/custom/aliases.zsh test_status 

or can put entire function script, not clutter alias.zsh:

#!/usr/bin/zsh function test_status {     if [ ! -f "./.guard_result" ];         echo "?"         return 1     fi      result="$(cat ./.guard_result)"      if [[ $result == *"success"* ]]             echo "💚";     elif [[ $result == *"fail"* ]]             echo "❤️";     fi } 

safe script somewhere (e.g. /path/to/test_status.zsh), make executable (chmod a+x /path/to/test_status.zsh) , call path in tmux configuration.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -