Portable Bash/Readline/fzf/tmux and CLI-tool setup for Ubuntu, WSL, and SSH Linux environments without replacing machine-specific configuration.
- Keeps the existing
~/.bashrcand preserves ROS, CUDA, conda, proxy, aliases, custom PATHs, etc. - Adds/replaces only a clearly delimited managed block in
~/.bashrc. - Preserves an existing
~/.inputrc; if absent, creates one that first includes/etc/inputrc. - Preserves an existing
~/.tmux.conf; if absent, creates a small loader file. - Creates timestamped backups under
~/.shell-setup-backup/before every install/update. - Installs core apt packages through a shared apt helper that repairs interrupted dpkg state first.
- Installs/updates the official
junegunn/fzfGit checkout in~/.fzf. - Runs
installers/*.shin filename order. - Copies portable common files, the apt helper, and
update.shto~/.config/shell-setup/so the original clone can be deleted.
shell-setup/
├── install.sh
├── update.sh
├── bashrc.common
├── inputrc.common
├── tmux.conf.common
├── lib/
│ └── apt.sh
├── installers/
│ ├── 00-install_basics.sh
│ └── 01-install_agents.sh
├── tests/
│ └── test.sh
└── README.md
git clone https://github.com/YOUR_NAME/YOUR_REPO.git ~/Downloads/shell-setup
cd ~/Downloads/shell-setup
./install.shinstall.sh automatically remembers git remote origin. After a successful installation, the downloaded clone may be removed.
If installing from a ZIP instead of Git, specify the repository URL once:
./install.sh --repo-url https://github.com/YOUR_NAME/YOUR_REPO.git~/.config/shell-setup/update.shThe updater creates a temporary clone of the latest repository, executes its latest install.sh, and removes the temporary clone afterward. This means changes to installers/*.sh, lib/apt.sh, Bash settings, Readline settings, and tmux settings all arrive through the same update command.
All project-owned apt installers should use the shared helper instead of writing raw sudo apt install ... commands.
Example installer:
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="${SHELL_SETUP_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
. "$ROOT_DIR/lib/apt.sh"
apt_install vim ffmpeg wget git tmuxapt_install performs the following sequence:
- Run
dpkg --configure -ato finish an interrupted package transaction. - If that fails because dependencies need repair, run
apt-get -f install -y, then retrydpkg --configure -a. - Run
apt-get updateonce per shell-setup execution when packages are actually missing. - Install only missing packages with
apt-get install -y. - Run the dpkg repair check again before returning.
This specifically handles the common error:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
The top-level install.sh also runs apt_repair immediately before every installers/*.sh file, so an older/custom installer containing raw apt commands is protected from a pre-existing interrupted-dpkg state. New installers should still use apt_install because it is safer and reusable when the installer is run by itself.
If a package's own post-install script is genuinely broken, the installer stops instead of hiding that real error.
Installs:
vim ffmpeg wget git git-lfs tmux tree zip unzip fd-find curl
It uses apt_install; do not add sudo yourself when adding packages to this list.
For example:
apt_install \
vim \
ffmpeg \
jq \
ripgrep \
btopInstalls Claude Code and Codex only when the corresponding command is not already available. User-level installers are used; sudo is not added.
Installs bubblewrap for the Codex Linux sandbox. When
kernel.apparmor_restrict_unprivileged_userns=1 (including Ubuntu 24.04),
it also installs apparmor-profiles and apparmor-utils, copies the distribution's
bwrap-userns-restrict profile into /etc/apparmor.d/ if absent, and loads it
with apparmor_parser -r. Existing profiles are preserved; repeated runs reload
them. No global sysctl restrictions or Codex permission settings are changed.
--skip-packages skips this entire installer, including profile configuration.
Systems without the AppArmor restriction only need the bubblewrap package.
If the distribution does not supply the extra profile, installation stops with
an error rather than disabling AppArmor restrictions.
This addresses bwrap: setting up uid map: Permission denied when the
AppArmor user namespace restriction blocks sandbox creation. See the
official sandbox documentation.
Run the installer through the normal ./install.sh / update workflow, or alone:
bash installers/04-configure_codex_sandbox.shValidate from a normal host terminal (not inside another sandbox):
bwrap --unshare-user --ro-bind / / /usr/bin/true
echo $? # 0 means successNested sandbox creation can be denied even when the outer Codex sandbox works.
Loading the profile requires sudo but does not require a reboot. To undo a profile
newly created by this installer, unload it with
sudo apparmor_parser -R /etc/apparmor.d/bwrap-userns-restrict, then remove that
file. Do not remove a pre-existing, administrator-managed profile.
Create, for example:
installers/02-install_robotics_tools.sh
with:
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="${SHELL_SETUP_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
. "$ROOT_DIR/lib/apt.sh"
apt_install \
v4l-utils \
can-utils \
minicomInstallers are executed lexicographically:
00-install_basics.sh
01-install_agents.sh
02-install_robotics_tools.sh
...
On normal Ubuntu/WSL:
~/.config/shell-setup/
├── bashrc.common
├── inputrc.common
├── tmux.conf.common
├── lib/
│ └── apt.sh
├── update.sh
└── repo-url
Check from WSL:
ls -la ~/.config/shell-setup
cat ~/.config/shell-setup/bashrc.commonOpen in Windows Explorer:
cd ~/.config/shell-setup
explorer.exe .tmux.conf.common contains:
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -RWith the default tmux prefix, use Ctrl-b, release it, then h/j/k/l.
Reload an already-running tmux server with:
tmux source-file ~/.tmux.confThe managed .inputrc settings provide:
- Prefix-aware
Up/Downhistory search. Tabto cycle completion candidates.Shift-Tabto cycle backwards.- Case-insensitive/colored completion.
set mark-directories offso selecting a directory candidate does not immediately append/and change the next Tab completion context.
Official fzf shell integration provides:
Ctrl-R: fuzzy history searchCtrl-T: fuzzy file selectionAlt-C: fuzzy directory selection**<Tab>: fuzzy completion
--skip-packages Skip apt/dpkg package operations.
--skip-fzf Skip fzf install/update.
--skip-installers Skip installers/*.sh entirely.
--repo-url URL Set/save the repository used by update.sh.
Before modifying files, backups are written to:
~/.shell-setup-backup/YYYYMMDD-HHMMSS-PID/
The installer validates Bash and Readline configuration and loads tmux configuration on a private tmux server when tmux is available.
Run regression tests with:
./tests/test.shThe regression tests include a simulated interrupted-dpkg condition and verify that dpkg --configure -a occurs before installer apt-get install.