πŸŽ„ Happy Holidays! πŸ₯³

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

Terminal Environment setup

Tamimi
Tamimi Member, Administrator, Employee Posts: 541 admin
edited July 2020 in General Discussions #1

Hey Solace Dev Community πŸ‘‹ I'm curious to know what your development environment setup looks like: Are you a Window, Mac or Linux user (or even some random OS user, I don't discriminate)? And on your machines, how do you configure your command line interface terminal for all your CLI magic?

Personally I am a HUGE fan of iTerm on MacOS and use zsh - or Z shell (and that's Zee not Zed πŸ˜‰) - which is basically just an extended version of the native Bourne Shell (sh) with a bunch of cool features, plugins and themes that enhances my productivity. I use the "powerlevel9k" theme which has an on-point contrast colours πŸ‘Œ. and i also have a bunch of aliases and shortcuts for increased productivity.

What about you? And if you are a windows user, I'm curious to know how you can customize and enhance your CLI experience because I am a windows n00b πŸ˜…

Comments

  • uherbst
    uherbst Member, Employee Posts: 130 Solace Employee
    edited July 2020 #2

    bash. (obviously I'm old enough to even know ksh by heart.... but for sure, I prefer bash).
    From my toolset, IMHO the most important pieces of setup are:

         # set alias "cli" to get in the cli of a docker solace container   
         if [ "x$USER" = "xroot" ]; then
            alias cli='docker exec -ti solace cli'
            else
            alias cli='sudo su - root -c "docker exec -ti solace cli"'
          fi
    

    With that you can just type "cli" - and you are in a cli :-)

    Next thing:

    # Query the healthcheck-port and output if we are the active node
    # Querying is done without curl, but just with bash builtins.
    function solacehealth {
        # Question: Is a broker running on localhost ?
        # and is this broker active ?
        HEALTHCHECK="/dev/tcp/localhost/5550"
        timeout 1 bash -c "<$HEALTHCHECK" > /dev/null 2>&1
        if [ $? -eq 0 ]; then
        # Ok, there is an open health check port... we assume
        # there is a broker running
        exec 5<>$HEALTHCHECK
        echo -e "GET /health-check/guaranteed-active HTTP/1.1\r\n\r\n" >&5
        read LINE <&5
        echo "$LINE" | grep -q 200
        if [ $? -eq 0 ]; then
            # Active broker => HTTP/200
            echo "Solace-Broker: This is the active node"
        else
            echo "Solace-Broker: This is the standby node"
        fi
      fi
    }
    

    And then just putting "solacehealth" in your .bashrc... you can see during login, if you are on the active broker.

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Mac for me. Terminal so it's just a *nix terminal, and since I'm constantly hopping across multiple environments it's defaults all the way! Reluctant Z shell user, would prefer to use bash everywhere. And it's definitely a zed :-)

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin

    @uherbst the solacehealth is very neat! Definitely verrrry useful for a quick sanity check. And re: ksh, I had to google that! So cool!

    @TomF: Zee.

  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee

    I am a long time Linux user. I have always run Linux desktops at home (btw, Pop_OS 20.04 is amazing) but at work, I can't run Linux bare metal and for my daily driver I don't love running in a VM soooo... I run Windows (in anger) at work.
    That said, Windows 2004 has WSL2 which uses a real kernel and can actually run docker locally now so it's actually a pretty decent environment for cli/terminal now. And the new Windows Terminal ain't half bad so I have my Windows Terminal default to Ubuntu 20.04 on WSL2. I also use MobaXTerm on Windows as it's a terrific terminal and has a ton of features even in the free version.
    In my terminals, I also use zsh like @Tamimi . It is configured with Prezto: https://github.com/sorin-ionescu/prezto which I prefer to the more popular oh-my-zsh.
    I am a notorius Apple h8tr so don't even get me started on Macs ;)
    btw, all my SSH environments share a common .ssh/config file so that I have a common set of aliases for my various hosts across all my computers (of which I have many).

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin
    edited July 2020 #6

    @amackenzie I was vibing in acceptance with everything you were saying about Linux and Ubuntu, and then you said you are notorious Apple h8tr 😱😭 hahah but im glad you use WSL2, I heard alot about it but I never used it. I've been always curious tho, doesnt it add yet another layer of interaction and complexity on your windows machine tho? So like do you face any lagging or compatibility issues? I see it as a bandaid fix to running Linux binary executables natively on Windows which I would assume comes with its own limitations? I might be wrong coz I never used or looked too much into it because I am... a Mac user πŸ˜‰

    Also: bonus points on having a shared SSH environment in .ssh/config!

    P.S: i'd be happy to convince you to get a mac.

  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee

    hard pass on Mac... I can use the $$$ to buy 3 or 4 Linux laptops instead.

    WSL was decently limited, though I still used it a lot. WSL1 was emulating Linux kernel calls through the Windows kernel. It was slow, especially file i/o and had a bunch of limitations especially around init and system services. WSL2 is using a real Linux kernel maintained by Microsoft (4.6, I think... 4.x for sure). So most performance issues are gone, though it's still a VM. That's why I don't tend to run X apps in WSL2 (but you can).

    So the takeaway is that Windows 10 + Ubuntu 20.04 on WSL2 using Windows Terminal (or even better MobaXTerm or CONEMU) is sooooooo much better than Mac OSX + iTerm it's barely worth even noting :smiley:

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin
    edited July 2020 #8

    @uherbst said:
    bash. (obviously I'm old enough to even know ksh by heart.... but for sure, I prefer bash).
    From my toolset, IMHO the most important pieces of setup are:

         # set alias "cli" to get in the cli of a docker solace container   
         if [ "x$USER" = "xroot" ]; then
          alias cli='docker exec -ti solace cli'
            else
          alias cli='sudo su - root -c "docker exec -ti solace cli"'
          fi
    

    Awesome, thanks for this @uherbst. Added to my dotfiles!

    My current environment: Mac, iterm2 (need to steal @Tamimi's setup!), bash, vim
    I previously used Windows and definitely made heavy use of mobaxterm as @amackenzie mentioned. Awesome tool and a must for windows users IMO.

    One thing that I setup in my .bash_profile that's pretty useful is the ability to easily switch between java versions.

    # Java
    export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
    export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
    export JAVA_12_HOME=$(/usr/libexec/java_home -v12)
    alias java8='export JAVA_HOME=$JAVA_8_HOME'
    alias java11='export JAVA_HOME=$JAVA_11_HOME'
    alias java12='export JAVA_HOME=$JAVA_12_HOME'
    # default to Java 8
    java8
    
  • amackenzie
    amackenzie Member, Employee Posts: 269 Solace Employee

    I have made pretty extensive use of asdf version manager in the past for things like Java, NodeJS, and others. You can install and manage a whole bunch of stuff with it. Saves me time as I am lazy and don't like changing my .zshrc ;)
    https://github.com/asdf-vm/asdf