Skip to content

Repository files navigation

Toolshed

CircleCIHex version

Toolshed aims to improve the Elixir shell experience by adding a number of helpers and path autocompletion. This is really helpful when a normal Unix shell prompt is unavailable or inconvenient. Toolshed was originally written for Nerves, but doesn't require it and the Nerves-specific helpers are compiled out for normal Elixir projects.

Here's a sample list of helpers:

  • cmd - run a command and print out the output
  • top - get a list of the top processes and their OTP applications based on CPU and memory
  • exit - exit an IEx session (useful over ssh)
  • tree - list directory contents as a tree
  • save_term/load_term - save and load Elixir terms to files
  • ping - check if a remote host is up (almost like ping, but uses TCP instead of ICMP to avoid needing additional permissions)
  • ifconfig - list network interfaces
  • lsusb - list USB devices

To get a complete list:

iex>hToolshed

To try it out, add this project to your deps:

defdepsdo[{:toolshed,"~> 0.2"}]end

Rebuild and run in whatever way you prefer. At the IEx prompt, run:

iex>useToolshedToolshed imported.Runh(Toolshed) for more info.:okiex>cmd("echo hello world")helloworld0iex>ping"nerves-project.org"PressentertostopResponsefromnerves-project.org(185.199.108.153): time=4.155msResponsefromnerves-project.org(185.199.108.153): time=10.385msResponsefromnerves-project.org(185.199.108.153): time=12.458ms
iex>topOTP Application Name orPID Reds/Δ Mbox/Δ Total/Δ Heap/Δ Stack/Δ
nerves_runtimeNerves.Runtime.Kernel.UE72M/10M 157/-32384K/-4642192K/73K 86/52system_registrySystemRegistry.Global41M/6134K 0/0694K/192K 192K/035/-11system_registrySystemRegistry.Processor61M/6075K 0/073K/-121573K/010/0system_registrySystemRegistry.Registrat1623K/293K 1/1211K/109K 73K/010/0system_registrySystemRegistry.Processor790K/197K 59/31011K/4461502K/038/0undefined#PID<0.1793.0> 221K/68K 0/0 21K/0 6772/0 504/0system_registrySystemRegistry.Processor382K/58K 0/016K/-12274185/-135422/0ssh#PID<0.1786.0> 133K/52K 0/0 4184/1599 2586/1599 10/0nerves_init_gadg#PID<0.1432.0> 213K/39K 0/0 192K/101K 73K/0 10/0

When you get tired of typing use Toolshed, add it to your .iex.exs.

FAQ

I have some IEx helpers. Would you consider adding them?

Yes! Absolutely. Please send a PR. At some point I may have to whittle down what's in the library, but for now, I'm open to adding almost anything.

This includes:

  1. Pretty much anything that helps debugging or inspecting a running system
  2. Wrappers on OTP functions that are hard to remember or have output that's not ideal for interactive use.
  3. Fun stuff - submit a text game if it's not too long if you'd like.

I'd really like to stay away from adding anything that's not Elixir to this project. I.e., no port processes or NIFs. It would also be nice to keep Toolshed low on dependencies. Of course, maybe I'm just not thinking of something. Don't let that be a reason to not file an issue proposing the idea. If it doesn't seem to fit well, maybe a simplified version does and we add a link to the full featured one.

A lot of these look like Unix commands? Why not run a proper shell?

Yeah, I miss many Unix commands when I'm at the IEx prompt. Switching to a shell is easy on my laptop, but on Nerves devices, it's a pain. Getting a shell prompt on Nerves is possible, but it's limited due to Nerves not containing a full set of commands and it having to be run through Erlang's job control.

You can do so much more with some of these helpers!!!

Definitely. There's so much that I'd like to explore, but time gets in the way. I'm not sold on many decisions that I made, but something was better than nothing. Please help me improve this or make your own IEx helpers library. I'm quite happy to use it too or pull it in as a dependency.

I want to use one of the functions in my program. Is the API stable?

This really isn't a normal hex.pm library. Use it for the helpers. If you want some code, copy and paste it or incorporate it into a library. I'd like the flexibility to change the API to improve interactive use.

It would be better if you changed the colors.

This also isn't a question, and you've now made me regret naming the project toolshed. Please file your grievances here.

About

A toolshed of IEx helpers

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages