Skip to content

Commit 3134d9b

Browse files
committed
misc: Miscellaneous small improvements
1 parent 25e214b commit 3134d9b

File tree

6 files changed

+141
-110
lines changed

6 files changed

+141
-110
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[*]
22
indent_style = tab
33
indent_size = 3
4+
5+
[*.md]
6+
indent_style = space
7+
indent_size = 2

README.md

Lines changed: 33 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,56 @@
11
# bpm
22

3-
Originally a fork of [bpm](https://github.com/bpmpm/bpm), `bpm` is a package manager for Bash repositories.
3+
`bpm` is the ultimate Bash (and Zsh, Fish, etc.) Package Manager
44

5-
> Instead of looking for specific install instructions for each package and messing with your path, [bpm] will create a central location for all packages and manage their binaries for you
5+
---
66

7-
More specifically, when `bpm` is given a repository to install, it will automatically
7+
`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)
88

9-
- Detect shell-specific completion scripts, and symlink them to a common directory
10-
- Detect executable scripts and symlink them to a common directory
11-
- Detect man pages and symlink them to a common directory
12-
13-
Since the completions and executables are in a common directory, it's much easier to make PATH / completion modifications
14-
15-
## Alternatives Comparison
16-
17-
### Compared to `bpkg`, `bpm`
18-
19-
- Can install multiple packages at once
20-
- Does not use a `package.json` that clobbers with NPM's
21-
- Does not automatically invoke `make install` commands on your behalf
22-
- Probably is able to install more repositories (not verified)
23-
- Respects XDG
24-
- Is likely faster
25-
26-
### Compared to `bpm`, `bpm`
27-
28-
- Can install multiple packages at once
29-
- Has an improved help output
30-
- Prints why a command failed (rather than just showing the help menu)
31-
- Has more modern code
32-
- Better bpm completion scripts
33-
- Is faster (less exec'ing Bash processes and subshell creations)
34-
- Does not source `package.sh` which allows for arbitrary command execution
35-
- More flexible parsing of command line arguments
36-
37-
Even though it is called bpm, it also works with zsh and fish.
38-
39-
## Installation
40-
41-
STATUS: IN DEVELOPMENT
42-
43-
`bpm` requires `bash >= 4`, and the `realpath` utility from `coreutils`. On
44-
osx you can install both with brew:
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)
4510

4611
```sh
47-
brew install bash coreutils
12+
$ bpm install \
13+
rupa/z \
14+
github.com/tj/git-extras \
15+
https://github.com/aristocratos/bashtop \
16+
git@github.com:JosefZIla/bash2048
4817
```
4918

50-
1. Clone `bpm``
19+
This symlinks all executable scripts to a common directory. It does this for completion files and man pages as well
5120

5221
```sh
53-
git clone https://github.com/bpmpm/bpm "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
22+
$ ls -l --color=always ~/.local/share/bpm/cellar/bin/
23+
... bash2048.sh -> /home/edwin/.local/share/bpm/cellar/packages/JosefZIla/bash2048/bash2048.sh
24+
... bashtop -> /home/edwin/.local/share/bpm/cellar/packages/aristocratos/bashtop/bashtop
25+
... git-alias -> /home/edwin/.local/share/bpm/cellar/packages/tj/git-extras/bin/git-alias
26+
... git-archive-file -> /home/edwin/.local/share/bpm/cellar/packages/tj/git-extras/bin/git-archive-file
27+
...
5428
```
5529

56-
2. Initialize `bpm` in your shell initialization
57-
58-
For `bash`, `zsh`, `sh`
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
5931

6032
```sh
6133
export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin:$PATH"
6234
eval "$(bpm init bash)" # replace 'bash' with your shell
6335
```
6436

65-
For `fish`
66-
67-
```fish
68-
set -gx PATH "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source/pkg/bin" $PATH
69-
status --is-interactive; and . (bpm init fish | psub)
70-
```
71-
72-
## Updating
73-
74-
Go to the directory where you cloned bpm and pull the latest changes
75-
76-
```sh
77-
cd "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
78-
git pull
79-
```
80-
81-
## Usage
82-
83-
### Installing packages from Github
37+
See [Getting Started](./docs/getting-started.md) for more details
8438

85-
```sh
86-
bpm install sstephenson/bats
87-
```
88-
89-
This will install [Bats](https://github.com/sstephenson/bats) and add its `./bin` to the `PATH`.
90-
91-
### Installing packages from other sites
92-
93-
```sh
94-
bpm install bitbucket.org/user/repo_name
95-
```
96-
97-
This will install `repo_name` from https://bitbucket.org/user/repo_name
98-
99-
### Installing a local package
100-
101-
If you develop a package locally and want to try it through Basher,
102-
use the `link` subcommand
103-
104-
```sh
105-
bpm link ./directory my_namespace/my_package
106-
```
107-
108-
The `link` command will install the dependencies of the local package.
109-
You can prevent that with the `--no-deps` option
110-
111-
### Sourcing files from a package into current shell
39+
## Alternatives Comparison
11240

113-
`bpm` provides an `include` function that allows sourcing files into the
114-
current shell. After installing a package, you can run:
41+
Why not use `bpkg` or `Basher`? Because `bpm`...
11542

116-
```sh
117-
include username/repo lib/file.sh
118-
```
119-
120-
## Contributing
43+
- Can install multiple packages at once
44+
- Does not use a `package.json` that clobbers with NPM's `package.json` (bpkg)
45+
- Does not automatically invoke `make` commands on your behalf (bpkg)
46+
- Does not automatically source a `package.sh` for package configuration (basher)
47+
- Is able to install more repositories
48+
- Respects the XDG Base Directory specification (bpkg)
49+
- Is faster (bpm considers exec and subshell creation overhead)
50+
- Has a _much_ improved help output (basher)
51+
- Prints why a command failed, rather than just printing the help menu (basher)
52+
- Has actually been updated recently
53+
- Better bpm completion scripts
54+
- More flexibly parses command line arguments (basher)
12155

122-
```sh
123-
git clone https://github.com/eankeen/bpm
124-
cd bpm
125-
git submodule update --init
126-
make test
127-
```
56+
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`

docs/getting-started.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Getting Started
2+
3+
## Installation
4+
5+
STATUS: IN DEVELOPMENT
6+
7+
`bpm` requires `bash >= 4.3`, and the `realpath` utility from `coreutils`. On
8+
osx you can install both with brew:
9+
10+
```sh
11+
brew install bash coreutils
12+
```
13+
14+
1. Clone `bpm`
15+
16+
```sh
17+
git clone https://github.com/bpmpm/bpm "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
18+
```
19+
20+
2. Initialize `bpm` in your shell initialization
21+
22+
For `bash`, `zsh`, `sh`
23+
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+
```
28+
29+
For `fish`
30+
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+
```
35+
36+
37+
## Updating
38+
39+
Go to the directory where you cloned bpm and pull the latest changes
40+
41+
```sh
42+
cd "${XDG_DATA_HOME:-$HOME/.local/share}/bpm/source"
43+
git pull
44+
```
45+
46+
```sh
47+
$ bash2048.sh
48+
Bash 2048 v1.1 (https://github.com/mydzor/bash2048) pieces=6 target=2048 score=60
49+
50+
/------+------+------+------\
51+
| | | | |
52+
|------+------+------+------|
53+
| 4 | | | |
54+
|------+------+------+------|
55+
| 2 | 2 | | |
56+
|------+------+------+------|
57+
| 16 | 8 | | 2 |
58+
\------+------+------+------/
59+
```

docs/recepies.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Recepies
2+
3+
### Installing packages from Github
4+
5+
```sh
6+
bpm install sstephenson/bats
7+
```
8+
9+
This will install [Bats](https://github.com/sstephenson/bats) and add its `./bin` to the `PATH`.
10+
11+
### Installing packages from other sites
12+
13+
```sh
14+
bpm install bitbucket.org/user/repo_name
15+
```
16+
17+
This will install `repo_name` from https://bitbucket.org/user/repo_name
18+
19+
### Installing a local package
20+
21+
If you develop a package locally and want to try it through Basher,
22+
use the `link` subcommand
23+
24+
```sh
25+
bpm link ./directory
26+
```
27+
28+
The `link` command will install the dependencies of the local package.
29+
You can prevent that with the `--no-deps` option
30+
31+
### Sourcing files from a package into current shell
32+
33+
`bpm` provides an `include` function that allows sourcing files into the
34+
current shell. After installing a package, you can run:
35+
36+
```sh
37+
include username/repo lib/file.sh
38+
```

pkg/lib/cmd/bpm.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ main() {
2626
Version: $PROGRAM_VERSION
2727
EOF
2828
exit
29-
;;
29+
;;
30+
*)
31+
break
32+
;;
3033
esac
3134
done
3235

@@ -82,7 +85,7 @@ main() {
8285
exit
8386
;;
8487
*)
85-
log.error "No command given"
88+
log.error "Command '$1' not valid"
8689
util.show_help
8790
;;
8891
esac

pkg/lib/util/util.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Usage:
228228
229229
Subcommands:
230230
init <shell>
231-
Configure the shell environment for Basher
231+
Configure shell environment for Basher
232232
233233
install [--ssh] [site]/<package>[@ref]
234234
Installs a package from GitHub (or a custom site)
@@ -252,12 +252,10 @@ Subcommands:
252252
complete <command>
253253
Perform the completion for a particular subcommand. Used by the completion scripts
254254
255-
echo <variable>
256-
Echo a particular internal variable. Used by the testing suite
257-
258255
Examples:
259256
bpm install tj/git-extras
260257
bpm install github.com/tj/git-extras
261258
bpm install https://github.com/tj/git-extras
259+
bpm install git@github.com:tj/git-extras
262260
EOF
263261
}

0 commit comments

Comments
 (0)