|
1 | 1 | # Getting Started
|
2 | 2 |
|
3 |
| -## Installation |
| 3 | +Succinctly, bpm is a fancy combination of `git clone` and `ln -s`. It clones a repositories, and puts all of its man pages, completion scripts, and binaries in common folders. Let's see it in action |
4 | 4 |
|
5 |
| -STATUS: IN DEVELOPMENT |
| 5 | +## Installing a simple package |
6 | 6 |
|
7 |
| -`bpm` requires `bash >= 4.3`, and the `realpath` utility from `coreutils`. On |
8 |
| -osx you can install both with brew: |
| 7 | +For this demonstration, we're going to install and use [bash2048](JosefZIla/bash2048). Note that this will still work, even if Zsh or Fish is your default shell |
9 | 8 |
|
10 | 9 | ```sh
|
11 |
| -brew install bash coreutils |
| 10 | +bpm --global add github.com/JosefZIla/bash2048 |
12 | 11 | ```
|
13 | 12 |
|
14 |
| -1. Clone `bpm` |
| 13 | +That's it - now you can use it! |
15 | 14 |
|
16 |
| - ```sh |
17 |
| - git clone https://github.com/bpmpm/bpm "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source" |
18 |
| - ``` |
| 15 | +```sh |
| 16 | +$ bash2048.sh |
| 17 | +Bash 2048 v1.1 (https://github.com/mydzor/bash2048) pieces=6 target=2048 score=60 |
19 | 18 |
|
20 |
| -2. Initialize `bpm` in your shell initialization |
| 19 | +/------+------+------+------\ |
| 20 | +| | | | | |
| 21 | +|------+------+------+------| |
| 22 | +| 4 | | | | |
| 23 | +|------+------+------+------| |
| 24 | +| 2 | 2 | | | |
| 25 | +|------+------+------+------| |
| 26 | +| 16 | 8 | | 2 | |
| 27 | +\------+------+------+------/ |
| 28 | +``` |
21 | 29 |
|
22 |
| - For `bash`, `zsh`, `sh` |
| 30 | +## Install a Bash function |
23 | 31 |
|
24 |
| - ```sh |
25 |
| - export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin:$PATH" |
26 |
| - eval "$(bpm init bash)" # replace 'bash' with your shell |
27 |
| - ``` |
| 32 | +For the second demonstration, we're going to install [z](https://github.com/rupa/z). If you already have it installed, don't worry - it will be installed to a different location and you can remove it separately |
28 | 33 |
|
29 |
| - For `fish` |
| 34 | +```sh |
| 35 | +# Globally install z |
| 36 | +bpm --global add rupa/z |
| 37 | +``` |
30 | 38 |
|
31 |
| - ```fish |
32 |
| - set -gx PATH "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin" $PATH |
33 |
| - status --is-interactive; and . (bpm init fish | psub) |
34 |
| - ``` |
| 39 | +As you can see, if you do not include the domain, it automatically uses github.com |
35 | 40 |
|
| 41 | +This clones `z` to `$HOME/.local/share/bpm/cellar/packages/github.com/rupa/z` |
36 | 42 |
|
37 |
| -## Updating |
| 43 | +It adds a symlink from the repository's `z.1` man page to `$HOME/.local/share/bpm/cellar/man/man1/z.1` |
38 | 44 |
|
39 |
| -Go to the directory where you cloned bpm and pull the latest changes |
| 45 | +Now, (assuming you completed [Installation](./installation.md) properly), you can display the manual right away |
40 | 46 |
|
41 | 47 | ```sh
|
42 |
| -cd "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source" |
43 |
| -git pull |
| 48 | +man z |
44 | 49 | ```
|
45 | 50 |
|
| 51 | +You might also try to execute `z.sh` |
| 52 | + |
46 | 53 | ```sh
|
47 |
| -$ bash2048.sh |
48 |
| -Bash 2048 v1.1 (https://github.com/mydzor/bash2048) pieces=6 target=2048 score=60 |
| 54 | +$ z |
| 55 | +bash: z: command not found |
| 56 | +$ z.sh |
| 57 | +bash: z.sh: command not found |
| 58 | +``` |
49 | 59 |
|
50 |
| -/------+------+------+------\ |
51 |
| -| | | | | |
52 |
| -|------+------+------+------| |
53 |
| -| 4 | | | | |
54 |
| -|------+------+------+------| |
55 |
| -| 2 | 2 | | | |
56 |
| -|------+------+------+------| |
57 |
| -| 16 | 8 | | 2 | |
58 |
| -\------+------+------+------/ |
| 60 | +But it doesn't work - this is standard behavior. When looking for binaries, bpm _does_ look at the root directory, but only symlinks shell scripts that are marked as _executable_ (`chmod +x z.sh`) |
| 61 | + |
| 62 | +The authors of `z` did not mark the file as executable because they did not intend for you to execute the file - you are supposed to `source` it. This is why the `package-path` command exists: |
| 63 | + |
| 64 | +```sh |
| 65 | +$ bpm --global package-path z.sh |
| 66 | +/home/username/bpm/cellar/packages/rupa/z |
| 67 | +``` |
| 68 | + |
| 69 | +Now, use the `package-path` to source `z.sh`. Note that `z.sh` only supports either Bash or Zsh, so you need to currently be in one of those shells for this to work |
| 70 | + |
| 71 | +```sh |
| 72 | +$ source "$(bpm --global package-path rupa/z)/z.sh" |
| 73 | +$ z |
| 74 | +common: /tmp/tmp.MBF063fdlK/completions |
| 75 | +29988 /tmp/tmp.MBF063fdlK/completions |
59 | 76 | ```
|
| 77 | + |
| 78 | +Note that if `z` does not show output, that's normal. You may need to `cd` to some directories to build the database |
| 79 | + |
| 80 | +If you want to do this persistantly, just add this to your `~/.bashrc` (or `~/.zshrc`). |
| 81 | + |
| 82 | +## Remove packages |
| 83 | + |
| 84 | +If you completed boht previous steps, two packages should be installed |
| 85 | +```sh |
| 86 | +$ bpm --global list |
| 87 | +github.com/JosefZIla/bash2048 |
| 88 | +github.com/rupa/z |
| 89 | +``` |
| 90 | + |
| 91 | +Remove them with `remove` |
| 92 | + |
| 93 | +```sh |
| 94 | +$ bpm --global remove \ |
| 95 | + git@github.com:JosefZIla/bash2048 \ |
| 96 | + https://github.com/rupa/z |
| 97 | +$ bpm --global list |
| 98 | +``` |
| 99 | + |
| 100 | +Note that we specified the SSH URL and the HTTPS URL when removing. You can specify the package this way with all commands, including the `add`, `package-path`, and `upgrade` commands |
| 101 | + |
| 102 | +And you are done! To learn more, see [Recepies](./.recepies.md), [Reference](./reference.md), or [Tips](./tips.md) |
0 commit comments