Giter Club home page Giter Club logo

iterm-components's Introduction

iterm-components

Custom status bar components for use with iTerm2

Built-in components and custom components

Components

GitHub stars

Shows the current number of stars for the specified repository. Clicking on the text takes you to the repo in your default browser. You can add a personal access token in order to minimize rate limiting or to keep tabs on a private repository.

GitHub stars component

kubectl context

Shows the active kubectl context.

kubectl context component

environment variable (work in progress)

Shows the current value of an environment variable, with the option to show or hide the variable name.

pyenv

Shows the active Python version or virtual environment.

pyenv component

rvm gemset

Shows the active gemset.

rvm gemset component

Generic command

Display the stdout from an arbitrary command.

Installation

You can install the scripts to iTerm2's AutoLaunch folder with ./install.sh. Select Scripts > AutoLaunch in the iTerm2 menu bar and select the scripts you want to be available as status bar components. You may be prompted to download the Python runtime. They should then be available to configure.

Configuring the components

After the components you want are present in the AutoLaunch folder and selected in the Scripts > AutoLaunch menu, iTerm2 should make them available to use.

Read the instructions for using status bar components and drag them where you like.

iterm-components's People

Contributors

daneah avatar harrygallagher4 avatar mastoj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

iterm-components's Issues

Create environment for AutoLaunch components

It would open a lot of doors to enable long-running components to use third-party packages.

Long-running components need to be placed in the AutoLaunch folder. The docs mention that scripts can have their own full environment via pyenv if done correctly, but I wasn't able to create a directory structure that seemed to work.

Interpolated String Not Updating

I tried using your Hello World example to get something working (I would like to help build out the reading of a session environment variable if possible). Anyways, I used an interpolated string with this value: \(hello_world_coroutine(knobs: "{}")) . When I open iterm it will display a random greeting, but it never changes. Am I doing something wrong? I realize that this isn't necessarily an issue with your code, but I would greatly appreciate the assistance and would like to help you with this project as I see value in it.

Autolaunch fails: script failed / ended unexpectedly / Too many levels of symbolic links

Looks like a symlink issue.

Installation: (note- I had copied generic_command earlier)

epedrosa@3Y:~/git$ git clone https://github.com/daneah/iterm-components.git
Cloning into 'iterm-components'...
remote: Enumerating objects: 144, done.
remote: Total 144 (delta 0), reused 0 (delta 0), pack-reused 144
Receiving objects: 100% (144/144), 283.85 KiB | 2.87 MiB/s, done.
Resolving deltas: 100% (72/72), done.
epedrosa@3Y:~/git$ cd iterm-components/
epedrosa@3Y:~/git/iterm-components$ ./install.sh
Linking scripts to AutoLaunch folder /Users/epedrosa/Library/Application Support/iTerm2/Scripts/AutoLaunch
Linking WIP_environment_variable.py...
Linking generic_command.py...
replace /Users/epedrosa/Library/Application Support/iTerm2/Scripts/AutoLaunch/generic_command.py? y
Linking github_stars.py...
Linking hello_world.py...
Linking kubectl_context.py...
Linking pyenv.py...
Linking rvm_gemset.py...

Selected scripts | autolaunch | hello_world.py...
Log:

3/21, 4:50:43.745 PM: /bin/bash -c /Users/epedrosa/Applications/iTerm.app/Contents/Resources/it2_api_wrapper.sh /Users/epedrosa/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.8.0/bin/python3 /Users/epedrosa/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py
3/21, 4:50:43.764 PM: + unset PYTHONPATH
3/21, 4:50:43.764 PM: + export PYTHONUNBUFFERED=1
3/21, 4:50:43.764 PM: + PYTHONUNBUFFERED=1
3/21, 4:50:43.764 PM: + /Users/epedrosa/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.8.0/bin/python3 /Users/epedrosa/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py
3/21, 4:50:43.810 PM: /Users/epedrosa/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.8.0/bin/python3: can't open file '/Users/epedrosa/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py': [Errno 62] Too many levels of symbolic links
3/21, 4:50:43.810 PM: 
3/21, 4:50:43.810 PM: ** Script exited with status 2 **

Replaced link with copy of script

epedrosa@3Y:~/git/iterm-components$ rm ~/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py
epedrosa@3Y:~/git/iterm-components$ cp hello_world.py ~/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/

Runs successfully now.

3/21, 4:52:42.385 PM: /bin/bash -c /Users/epedrosa/Applications/iTerm.app/Contents/Resources/it2_api_wrapper.sh /Users/epedrosa/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.8.0/bin/python3 /Users/epedrosa/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py
3/21, 4:52:42.411 PM: + unset PYTHONPATH
3/21, 4:52:42.411 PM: + export PYTHONUNBUFFERED=1
3/21, 4:52:42.411 PM: + PYTHONUNBUFFERED=1
3/21, 4:52:42.411 PM: + /Users/epedrosa/Library/ApplicationSupport/iTerm2/iterm2env/versions/3.8.0/bin/python3 /Users/epedrosa/Library/ApplicationSupport/iTerm2/Scripts/Autolaunch/hello_world.py
3/21, 4:52:42.845 PM: Connection accepted: Script launched by user action

GitHub Stars fails with a knobs error

When the component is added to the status bar and configured, a ladybug shows in the status bar. Clicking returns this error:

Status bar component “GitHub stars” (engineering.dane.iterm-components.github-stars) failed.

This function call had an error:

statusbar.engineering.dane.iterm_components.github_stars.github_stars_coroutine(knobs:__knobs)

The error was:

Reference to undefined variable “__knobs”. Change it to “__knobs?” to treat the undefined value as null.

I think something has changed with the way this variable is scoped, maybe?

Add generic script to execute simple command

As long as a status bar doesn't need to be interactive and only displays the output from a command it can be solved in a generic manner.

It should work basically as kubectl_context.py but instead of having a fixed command it should be able to configure the command as well as defining a prefix to make it look prettier in the status bar.

Run component processes in the user's shell context

I can't figure out how to get components to run in the context of the current shell, which means things like pyenv and rvm don't work since they require loading. The WIP components work when run manually in a virtualenv, but not when placed in the AutoLaunch folder.

Switch kubectl contexts via component

It would be awesome if the kubectl context component, when clicked, would show a popover menu of the available contexts via:

kubectl config view -o jsonpath='{.contexts[*].name}' | tr " " "\n"

And switch to one of the displayed contexts when clicked via:

kubectl config use-context <context>

The popover is covered well in the docs (see onclick in this example) but being able to click items inside the popover isn't AFAICT.

The built in git state component does something like this, but the built-ins all appear to be written in Objective-C.

Access knob values in onclick handler

It would be cool for the GitHub stars component to open the configured repo in the browser on click via:

@iterm2.RPC
def click_handler(session_id):
    repo = ...
    proc = await asyncio.create_subprocess_shell(
        f'open https://github.com/{repo}',
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
    )
    stdout, stderr = await proc.communicate()

Unfortunately, the repo value is only available in the knobs, which can't be passed to the onclick coroutine. This is perhaps possible with some magic since the @StatusBarRPC coroutine does receive the knobs, but it was out of my reach.

Can't get the kube context working

Great stuff you have going here, I just need to get it working :)

I want the kubernetes context in my status bar, but it is just blank. My guess is that the script is running in some weird context so it doesn't have access to kubectl.

Is there a way to verify my assumption? Do you know how to fix it?

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.