Skip to content

Commit 4781571

Browse files
committed
docs: Revamp and update Docs
1 parent c7ddc62 commit 4781571

File tree

9 files changed

+252
-138
lines changed

9 files changed

+252
-138
lines changed

README.md

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
---
66

7+
STATUS: ALPHA
8+
79
`bpm` is a fork of [basher](https://github.com/basherpm/basher) that adds a _ton_ of new functionality. It makes it significantly easier to install Bash, Zsh, etc. projects to your computer. Often, these projects / scripts are _not_ available through official `apt`, `DNF`, `pacman` repositories, or even from unofficial sources like third party apt repositories or the [AUR](https://aur.archlinux.org)
810

9-
Let's say you want to install [rupa/z](https://github.com/rupa/z), [tj/git-extras](https://github.com/tj/git-extras), [aristocratos/bashtop](https://github.com/aristocratos/bashtop), and [JosefZIla/bash2048](https://github.com/JosefZIla/bash2048). Simply run the following (as you can see, many formats are supported)
11+
Let's say you want to install [rupa/z](https://github.com/rupa/z), [tj/git-extras](https://github.com/tj/git-extras), [aristocratos/bashtop](https://github.com/aristocratos/bashtop), and [JosefZIla/bash2048](https://github.com/JosefZIla/bash2048). Simply run the following
1012

1113
```sh
12-
$ bpm add \
13-
rupa/z \
14-
github.com/tj/git-extras \
15-
https://github.com/aristocratos/bashtop \
16-
git@github.com:JosefZIla/bash2048
14+
$ bpm add rupa/z tj/git-extras aristocratos/bashtop JosefZIla/bash2048
1715
```
1816

1917
This symlinks all executable scripts to a common directory. It does this for completion files and man pages as well
@@ -27,57 +25,22 @@ $ ls -l --color=always ~/.local/share/bpm/cellar/bin/
2725
...
2826
```
2927

30-
If you want to automatically add the bin directory to your path, source the completion files, and add the man pages to your man path, simply add a two-liner in your shell configuration
28+
To be able to access the binaries, completion files, and man pages in your shell, simply add a two-liner in your shell configuration
3129

3230
```sh
31+
# ~/.bashrc
3332
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin:$PATH"
34-
eval "$(bpm init bash)" # replace 'bash' with your shell
33+
eval "$(bpm init bash)" # zsh and fish are also supported
3534
```
3635

37-
STATUS: ALPHA
38-
39-
See [Getting Started](./docs/getting-started.md) for more details
40-
41-
## Local Package Development
42-
43-
If you are working on a project, and want to pull in a dependency, say [bash-args](https://github.com/eankeen/bash-args), the workflow looks like this
44-
45-
To use the packages, simply append to the `PATH` variable in your script entrypoint (script.sh in the example below). Note that exporting it isn't required because it's already an exported variable
46-
47-
```sh
48-
mkdir 'my-project' && cd 'my-project'
49-
50-
# Creating a 'bpm.toml' is required so bpm knows where
51-
# the root of the project is
52-
touch 'bpm.toml'
53-
54-
bpm add 'eankeen/bash-args'
55-
56-
cat > 'script.sh' <<-"OUTEREOF"
57-
#!/usr/bin/env bash
58-
59-
PATH="$PWD/bpm_packages/bin:$PATH"
60-
61-
declare -A args=()
62-
63-
# 'bash-args' requires that we use `source`
64-
source bash-args parse "$@" <<-"EOF"
65-
@flag [port.p] {3000} - The port to open on
66-
EOF
67-
68-
echo "Using port '${args[port]}'"
69-
OUTEREOF
70-
71-
chmod +x './script.sh'
72-
./script.sh # Using port '3000'
73-
./script.sh --port 4000 # Using port '4000'
74-
```
36+
See [Installation](./docs/installation.md) and [Getting Started](./docs/getting-started.md) for more details
7537

7638
## Alternatives Comparison
7739

7840
Why not use `bpkg` or `Basher`? Because `bpm`...
7941

8042
- Can install multiple packages at once
43+
- Install local dependencies for a particular project (bpkg and basher)
8144
- Does not use a `package.json` that clobbers with NPM's `package.json` (bpkg)
8245
- Does not automatically invoke `make` commands on your behalf (bpkg)
8346
- Does not automatically source a `package.sh` for package configuration (basher)
@@ -88,5 +51,6 @@ Why not use `bpkg` or `Basher`? Because `bpm`...
8851
- Prints why a command failed, rather than just printing the help menu (basher)
8952
- Better bpm completion scripts
9053
- More flexibly parses command line arguments (basher)
54+
- Install local directories as packages (bpkg)
9155

92-
I originally created a [different](https://github.com/eankeen/shell-installer) Shell package manager but later abandoned it. When I _really_ needed the functionality, I forked Basher because it had an excellent test suite and its behavior for installing packages actually made sense, compared to `bpkg`
56+
I I forked Basher because it had an excellent test suite and its behavior for installing packages made more sense to me, compared to `bpkg`

docs/getting-started.md

Lines changed: 78 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,102 @@
11
# Getting Started
22

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
44

5-
STATUS: IN DEVELOPMENT
5+
## Installing a simple package
66

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
98

109
```sh
11-
brew install bash coreutils
10+
bpm --global add github.com/JosefZIla/bash2048
1211
```
1312

14-
1. Clone `bpm`
13+
That's it - now you can use it!
1514

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
1918

20-
2. Initialize `bpm` in your shell initialization
19+
/------+------+------+------\
20+
| | | | |
21+
|------+------+------+------|
22+
| 4 | | | |
23+
|------+------+------+------|
24+
| 2 | 2 | | |
25+
|------+------+------+------|
26+
| 16 | 8 | | 2 |
27+
\------+------+------+------/
28+
```
2129

22-
For `bash`, `zsh`, `sh`
30+
## Install a Bash function
2331

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
2833

29-
For `fish`
34+
```sh
35+
# Globally install z
36+
bpm --global add rupa/z
37+
```
3038

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
3540

41+
This clones `z` to `$HOME/.local/share/bpm/cellar/packages/github.com/rupa/z`
3642

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`
3844

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
4046

4147
```sh
42-
cd "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
43-
git pull
48+
man z
4449
```
4550

51+
You might also try to execute `z.sh`
52+
4653
```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+
```
4959

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
5976
```
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)

docs/installation.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Installation
2+
3+
## Prerequisites
4+
5+
- `bash >= 4.3`
6+
- GNU coreutils
7+
8+
If you are on macOS, you need to install the latest `bash` and `coreutils`:
9+
10+
```sh
11+
# Install prerequisite packages
12+
brew install bash coreutils
13+
```
14+
15+
See the full list of supported operating systems in [Support](./support.md)
16+
17+
## Install
18+
19+
##### 1. Clone `bpm`
20+
21+
```sh
22+
git clone https://github.com/bpmpm/bpm "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
23+
```
24+
25+
By default, this installs bpm to `$HOME/.local/share/bpm/source`
26+
27+
##### 2. Add initialization script to shell profile
28+
29+
This enables bpm to automatically setup your `PATH`, set completion variables, source completion files, and other things
30+
31+
32+
For `bash`, `zsh`, `sh`
33+
34+
```sh
35+
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin:$PATH"
36+
eval "$(bpm init bash)" # replace 'bash' with your shell
37+
```
38+
39+
For `fish`
40+
41+
```fish
42+
set -gx PATH "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin" $PATH
43+
status --is-interactive; and . (bpm init fish | psub)
44+
```
45+
46+
And now you're done! Move on to [Getting Started](./getting-started.md) to learn the basics

docs/recepies.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)