https://github.com/aperezdc/rockz
Virtualfish-alike Lua+LuaRocks “Rockenv” wrapper for Zsh
https://github.com/aperezdc/rockz
environment lua luajit luarocks profile-manager
Last synced: 8 months ago
JSON representation
Virtualfish-alike Lua+LuaRocks “Rockenv” wrapper for Zsh
- Host: GitHub
- URL: https://github.com/aperezdc/rockz
- Owner: aperezdc
- Created: 2016-03-10T14:33:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-02T08:47:58.000Z (over 1 year ago)
- Last Synced: 2025-02-28T12:55:34.291Z (9 months ago)
- Topics: environment, lua, luajit, luarocks, profile-manager
- Language: Shell
- Size: 28.3 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-zsh-plugins - rockz - Lua + LuaRocks virtual environment manager based upon VirtualZ. (Plugins / ZSH on Windows)
- fucking-awesome-zsh-plugins - rockz - Lua + LuaRocks virtual environment manager based upon VirtualZ. (Plugins / ZSH on Windows)
- awesome-zsh-plugins - rockz - Lua + LuaRocks virtual environment manager based upon VirtualZ. (Plugins / Zinit (née zplugin))
README
# RockZ
A [Z shell](http://zsh.org) virtualenvwrapper-lookalike, loosely based on Adam
Brenecki's [virtualfish](https://github.com/adambrenecki/virtualfish) for the
[Fish shell](http://fishshell.com), and highly based upon my own
[VirtualZ](https://github.com/aperezdc/virtualz).
* For [Lua](http://www.lua.org) instead of Python.
* Using [LuaRocks](https://luarocks.org) instead of Pip.
☺
## Quickstart
RockZ needs the paths to the Lua header files and the Lua library in order to
bootstrap LuaRocks — so in turn LuaRocks knows how to build binary modules.
The names and locations vary in each system, so instead RockZ expects the user
to define a *profile* which stores the needed paths.
The following should work for creating a `default` profile in most GNU/Linux
distributions:
```sh
rockz profile default \
--lua=/usr/bin/lua \
--include=/usr/include \
--library=/usr/lib/liblua.so
```
Once you have a profile, you can create a new “rockenv” (Lua+LuaRocks
environment):
```sh
rockz new myenv
```
The variables `${ROCK_ENV}` and `${ROCK_ENV_NAME}` will be set with the full
path to the rockenv prefix directory and the rockenv name, respectively.
Environments can be managed with the rest of `rockz` subcommands:
```sh
rockz activate myenv
rockz new myotherenv
rockz rm myenv
rockz deactivate
```
## Installation & Setup
The recommended way is to use a plugin manager. By default, the location where
RockZ looks for rockenvs is `~/.rockenvs`. This can be changed by setting the
desired path in the `${ROCKZ_HOME}` variable.
With [zgen](https://github.com/tarjoilija/zgen), add the following to your
`.zshrc`:
```sh
zgen load aperezdc/rockz
```
### Using with LuaJIT
RockZ works just fine with [LuaJIT](http://luajit.org). You will need to
create a *profile* pointing to the LuaJIT binary and libraries. Use the
`profile` subcommand as follows:
```sh
rockz profile luajit \
--lua=/usr/bin/luajit \
--include=/usr/include/luajit-2.0 \
--library=/usr/lib/libluajit-5.1.so.2
```
*(Note that the actual paths may be different in your system — please
change the paths in the above invocation accordingly.)*
Now that the profile is available, use `--profile` with the `new` subcommand
to create a LuaJIT-powered environment:
```sh
rockz new luajitenv --profile=luajit
```
Now because RockZ created a symbolic link names `lua` to the Lua interpreter
specified in the profile, using `lua` will actually run LuaJIT:
```
% readlink "$(which lua)"
/usr/bin/luajit-2.0.4
% lua
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 fold cse dce fwd dse narrow loop abc sink fuse
>
```
Isn't that convenient?
### Rockenv name in the prompt
When a rockenv is active, the following variables are defined:
- `ROCK_ENV` contains the full path to the active environment.
- `ROCK_ENV_NAME` contains the name of the active environment.
For example, the following will prepend the name of the current rockenv to
your existing prompt, but only if there is an environment active:
```sh
PROMPT="\${ROCK_ENV_NAME:+\${ROCK_ENV_NAME} }${PROMPT}"
```