Managing dotfiles and scripts between computers can be a pain... this aims to make that easier!
First, make sure git is installed, then run:
curl https://raw.githubusercontent.com/dqsully/sh-pkg/main/install.sh | bash -This will add the std remote source pointing to this repository, as well as install the std/sh-pkg package, which puts the sh-pkg executable in the ~/bin directory. Note: until you install a dotfile-* package, the sh-pkg executable may not be in your PATH.
To update your shell dotfiles (only Bash and Zsh are currently supported) to work with sh-pkg packages, run:
~/bin/sh-pkg install dotfile-bash dotfile-zshNOTE: this will migrate your .bashrc, .profile, .zshenv, and .zshrc files into the sh-pkg dotfile dirs.
A "source" is just a named folder of packages. This can be a subdirectory of a Git repository, or just a directory on your local computer.
To add a local source, run
sh-pkg source add mysourcename path/to/sourceTo add a remote source, run
sh-pkg source add mysourcename https://github.com/me/mypackages subdir/within/the/repoBy default, the std source is added during installation and points to this repository.
A "package" is a folder with files to copy into a user's home directory. Packages are referred to in a source/package format, e.g. std/sh-pkg for the package manager itself.
Also, if a source is omitted from a package reference, it's assumed to be part of the std source, e.g. sh-pkg is the same as std/sh-pkg.
To install the std/aliases-kubectl package for example, run
sh-pkg install aliases-kubectlTo remove that package, run
sh-pkg uninstall aliases-kubectlWhen writing a package, you can use some special files starting with .pkg to add metadata or package hooks:
.pkg.info- plaintext package info.pkg.deps- newline-delimited package dependencies insource/packageformat,.can be used in this file to reference the current source, e.g../kubelet.pkg.preinstall.sh- preinstall script executed only before installation, best for migrating existing user files (make sure tochmod +x).pkg.install.sh- script executed during install or update, before files are copied but after installation is validated (make sure tochmod +x)
sh-pkg maintains a basic key-value database with list values for anyone to use. sh-pkg itself uses this database to save information about installed packages and files, but it can also be used for general-purpose configuration, like with the std/projects package.
To read or edit any database entries, use the sh-pkg db subcommands.
~/.sh-pkg is where sh-pkg stores all of its configuration. The following directories are standard, but packages may add nonstandard ones as well:
db- the sh-pkg database directoryenv.d- scripts to compile into a.zshenvor.profilefile, should contain environment variable settingshook- sh-pkg hooksinstall- scripts to run after anysh-pkg installcommand, e.g. compiling~/.sh-pkg/env.d
rc.d- scripts to compile into a.zshrcor.bashrcfile, should contain shell configurations, aliases, and functionsremote_sources- where sh-pkg maintains Git repositories for remote sourcessources- symlinks for each installed source to the source's real location (e.g. to a repo inremote_sources)
Directories added by packages
- Can install and update local or remote package sources
- Packages can be installed
- Packages can have dependencies
-
sh-pkgcan be bootstrapped - Scripts from
env.dandrc.dare precompiled for speed - Command to uninstall packages
- Command to list installed and/or available packages
- Command to print package info
- Command to update all sources
- Command to update installed packages
- Support for pre-install hooks
- Suggested packages
- More safety around package removal
- Better shell detection (instead of defaulting to zsh if not bash)
- Package features
- brew - installs brew
- brew - updates brew
- code-insiders - rename to something better
- dotnet - install/manage .NET versions?
- git - migrates existing
.gitconfig - go - installs go
- go - updates go
- kubectl - rename to aliases-kubectl
- kubectl - add Bash aliases, remove oh-my-zsh dependency
- kubie - fix zsh compdef
- kubie - add Bash support
- nvm - install nvm
- nvm - update nvm
- nvm - support nvm in Bash
- oh-my-zsh - make install compatible
- oh-my-posh - create package
- projects - rename
- pyenv - install pyenv
- pyenv - update pyenv
- rust - installs rustup
- rust - updates cargo packages
- sh-pkg - migrates existing
.profile,.bashrc,.zshrc, and.zshenv - sh-pkg - overwrite
.profile,.bashrc,.zshrc, and.zshenvdirectly instead of using.sh-pkg/.compileddirectory - sh-pkg - split Bash/Zsh support into separate packages