GithubHelp home page GithubHelp logo

Comments (4)

borkdude avatar borkdude commented on June 18, 2024 2

@jkxyz Indeed, having just a function to map over the stdout and/or stderr would be the most flexible solution. Just an interceptor basically.

from process.

jkxyz avatar jkxyz commented on June 18, 2024 1

Just a note that foreman only colors the process name at the beginning of the line. The rest of the output is unmodified.

Would it be sufficient to just have a convenience option like

:process-line-fn (fn [s] (str (termcolor :green "FOO | ") s))

from process.

borkdude avatar borkdude commented on June 18, 2024 1

See discussion here with a potential solution:

#102 (reply in thread)

from process.

teodorlu avatar teodorlu commented on June 18, 2024

Pasting in my current plain bash solution that I'd like to replace. Essentially, I'm wrapping each line with some stuff.

frontend and backend are normal bash functions that cd into the right directory, and run make dev or something similar.

Perhaps I could delete the whole thing and replace it with a little bb.edn :)

with_prefix() {
    # Usage: with_prefix $APPNAME $COLOR
    local NOCOLOR='\033[0m'
    awk -v name="$1" -v color="$2" -v nocolor="$NOCOLOR" '{ printf "%s[%s]%s %s\n", color, name, nocolor, $0 }'
}

apps() {
    # from https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
    #
    #     Black        0;30     Dark Gray     1;30
    #     Red          0;31     Light Red     1;31
    #     Green        0;32     Light Green   1;32
    #     Brown/Orange 0;33     Yellow        1;33
    #     Blue         0;34     Light Blue    1;34
    #     Purple       0;35     Light Purple  1;35
    #     Cyan         0;36     Light Cyan    1;36
    #     Light Gray   0;37     White         1;37

    local NO_COLOR='\033[0m'

    local BLACK='\033[0;30m'
    local RED='\033[0;31m'
    local GREEN='\033[0;32m'
    local BROWN_ORANGE='\033[0;33m'
    local BLUE='\033[0;34m'
    local PURPLE='\033[0;35m'
    local CYAN='\033[0;36m'
    local LIGHT_GRAY='\033[0;37m'
    local DARK_GRAY='\033[1;30m'
    local LIGHT_RED='\033[1;31m'
    local LIGHT_GREEN='\033[1;32m'
    local YELLOW='\033[1;33m'
    local LIGHT_BLUE='\033[1;34m'
    local LIGHT_PURPLE='\033[1;35m'
    local LIGHT_CYAN='\033[1;36m'
    local WHITE='\033[1;37m'
    local BLACK='\033[0;30m'
    local RED='\033[0;31m'
    local GREEN='\033[0;32m'

    # If secrets env vars are not set, try to source bash / zsh.

    frontend 2> >(with_prefix "frontend" "$RED") 1> >(with_prefix "frontend" "$GREEN")  &
    backend  2> >(with_prefix "backend" "$RED")  1> >(with_prefix "backend" "$BLUE")    &
    nats     2> >(with_prefix "nats" "$RED")     1> >(with_prefix "nats" "$LIGHT_CYAN") &
    sleep 999999999999
}

from process.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.