239 lines
8.5 KiB
Org Mode
239 lines
8.5 KiB
Org Mode
#+TITLE: Tooling setup
|
|
#+AUTHOR: James Blair
|
|
#+EMAIL: mail@jamesblair.net
|
|
#+DATE: <2022-11-15 Tue 09:15>
|
|
|
|
|
|
This guide will walk through how I setup fresh installations of [[https://projectbluefin.io][Bluefin]]. For end users Bluefin provides a system as reliable as a Chromebook with near-zero maintainance, with the power of homebrew, flathub, and a container runtime to give you access to all the best software Open Source has to offer.
|
|
|
|
I use Bluefin as my daily driver operating system on a variety of different machines. The intent of this guide is to make it easy for me to get back up and running quickly whenver I do a fresh installation.
|
|
|
|
|
|
* Install brew packages
|
|
|
|
Additional packages are ideally sourced from [[https://docs.brew.sh/Homebrew-on-Linux][Homebrew for Linux]], with [[https://flathub.org/][Flathub]] for anything I can't find in brew. Included in this repository is my ~Brewfile~ of packages.
|
|
|
|
#+begin_src tmux
|
|
brew bundle install --cleanup
|
|
#+end_src
|
|
|
|
|
|
* Install flatpak packages
|
|
|
|
For anything I can't get through Homebrew for Linux I install via Flathub. Included in this repository is my ~Flatfile~ of packages. Unfortunately the ~flatpak~ cli [[https://github.com/flatpak/flatpak/issues/5876][does not yet support list based installs]] so below is a bash oneliner to get the job done.
|
|
|
|
#+begin_src
|
|
while read line; do flatpak install --assumeyes `echo $line | awk '{print $2}'`; done < Flatfile
|
|
#+end_src
|
|
|
|
|
|
* Secret management
|
|
|
|
For managing secrets we use [[https://bitwarden.com/][bitwarden]] which provides a great [[https://github.com/bitwarden/cli][cli utility]]. Additionally in our [[.bashrc][bashrc]] file included in this repository there are a number of helper functions to make working with ~bw~ easier.
|
|
|
|
The ~bw~ utility should already be installed as part of our homebrew packages. Let's login now.
|
|
|
|
#+NAME: Login to bitwarden
|
|
#+begin_src tmux
|
|
bw login mail@jamesblair.net
|
|
#+end_src
|
|
|
|
|
|
* Restore ssh keys and dotfiles
|
|
|
|
I make extensive use of ~.dotfiles~ to further customise my environment. The script below restores my versions of key dotfiles automatically.
|
|
|
|
** Obtain ssh key from bitwarden
|
|
|
|
In order to be able to clone the repository in the next step we need to obtain our ssh keys from bitwarden. Given we have installed the bitwarden cli we can mostly automte this process minus the initial login to bitwarden.
|
|
|
|
#+NAME: Obtain ssh keys from bitwarden
|
|
#+begin_src shell
|
|
# Ensure we have an ssh-agent running
|
|
eval `ssh-agent`
|
|
|
|
# Generate a new blank key to overwrite
|
|
ssh-keygen -t rsa -f ~/.ssh/james -q -P ""
|
|
|
|
# Ensure we have an active bitwarden session
|
|
export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)
|
|
|
|
# Export both keys
|
|
export key=$(bw get item "$(hostname)" --pretty | grep notes)
|
|
|
|
# Extract private key
|
|
export private=${key:12}
|
|
export private=${private/END RSA*/END RSA PRIVATE KEY-----}
|
|
echo $private | awk '{gsub(/\\n/,"\n")}1' > ~/.ssh/james
|
|
|
|
# Extract public key
|
|
export public=${key/*ssh-rsa/ssh-rsa} && echo ${public::-2} | awk '{gsub(/\\n/,"\n")}1' > ~/.ssh/james.pub
|
|
#+end_src
|
|
|
|
|
|
** Clone and restore dotfiles
|
|
|
|
Once our keys are available to us we can clone down our dotfiles and get back to our comfortable normal terminal environment.
|
|
|
|
#+NAME: Clone and restore the dotfiles
|
|
#+BEGIN_SRC shell
|
|
# Clone down this repository
|
|
git clone https://jmhbnz@gitea.jamma.life/jmhbnz/tooling.git ~/Documents/tooling/
|
|
|
|
# Restore all dotfiles
|
|
cp ~/Documents/tooling/.* ~/
|
|
|
|
# Reload bashrc with updated version
|
|
source ~/.bashrc
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
* Optional configuration
|
|
|
|
** Optional - Cloud provider tools
|
|
|
|
For working with google cloud platform we use the [[https://cloud.google.com/sdk/][GCP SDK]], which provides our cli tools. Unfortunately we [[https://github.com/orgs/Homebrew/discussions/3594][can't install it via brew on Linux]] so we need to install it manually.
|
|
|
|
#+NAME: Install google cloud sdk
|
|
#+BEGIN_src tmux
|
|
# Download the sdk archive
|
|
curl -o gcpsdk.tar -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz
|
|
|
|
# Extract to a folder in path then remove archive
|
|
mkdir /home/${USER}/.var/bin && tar xvf gcpsdk.tar -C /home/${USER}/.var/bin && rm gcpsdk.tar
|
|
|
|
# Run the install script
|
|
/home/${USER}/.var/bin/google-cloud-sdk/install.sh
|
|
#+END_SRC
|
|
|
|
|
|
** Optional - Setup doom emacs
|
|
|
|
An integral part of my development workflow is [[https://github.com/doomemacs/doomemacs][Doom Emacs]]. Below are the instructions to set this up.
|
|
|
|
#+NAME: Install and configure doom
|
|
#+BEGIN_src tmux
|
|
# Install doom emacs
|
|
git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs
|
|
~/.config/emacs/bin/doom install
|
|
|
|
# Copy in my configuration
|
|
cp /home/${USER}/Documents/doom/* /home/${USER}/.config/doom/
|
|
|
|
# Doom sync to finalise
|
|
doom sync
|
|
#+END_SRC
|
|
|
|
Included in this repository is a ~doom/~ subdirectory which layers my personal preferences on top of doom.
|
|
|
|
|
|
** Optional - setup tmux plugin manager
|
|
|
|
For terminal efficiency I use the [[https://github.com/tmux/tmux][tmux]] terminal multiplexer, however to customize it further I use the [[https://github.com/tmux-plugins/tpm][tpm]] plugin manager.
|
|
|
|
#+NAME Install tmux plugin manager
|
|
#+begin_src tmux
|
|
# Install tmux plugin manager
|
|
mkdir --parents /home/${USER}/.tmux/plugins
|
|
git clone https://github.com/tmux-plugins/tpm /home/${USER}/.tmux/plugins/tpm
|
|
./home/${USER}/.tmux/plugins/tpm/bin/install_plugins
|
|
|
|
# Source the tmux configuration file
|
|
tmux source ~/.tmux.conf
|
|
#+end_src
|
|
|
|
|
|
** Optional - Setup sbp powerline prompt
|
|
|
|
Having an informative bash prompt can ease cognitive burden and make development more pleasant. Below is an example of my terminal prompt which is based on [[https://github.com/powerline/fonts/][powerline fonts]] for symbols and [[https://github.com/brujoand/sbp][simple bash prompt]] for the overall presentation.
|
|
|
|
As you can see in the screenshot, contextual "segments" are presented in the prompt to provide information like directory, current user and detailed git status.
|
|
|
|
[[./images/powerline-prompt.png]]
|
|
|
|
#+NAME: Install simple bash prompt
|
|
#+begin_src tmux
|
|
# Disable bluefin/aurora terminal motd
|
|
ujust toggle-user-motd
|
|
|
|
# Clone the repository
|
|
git clone https://github.com/brujoand/sbp ~/Downloads/sbp/
|
|
|
|
# Run the install script
|
|
/home/$USER/Downloads/sbp/bin/install
|
|
|
|
# Ensure config directory exists
|
|
mkdir --parents /home/$USER/.config/sbp/
|
|
|
|
# Write the config file
|
|
cat << EOF > /home/$USER/.config/sbp/settings.conf
|
|
#!/usr/bin/env bash
|
|
SBP_THEME_COLOR='apathy'
|
|
SBP_THEME_LAYOUT='powerline'
|
|
|
|
# Hooks will run once before every prompt
|
|
# Run 'sbp list hooks' to list all available hooks
|
|
SBP_HOOKS=('alert')
|
|
|
|
# Segments are generated before each prompt and can
|
|
# be added, removed and reordered
|
|
# Run 'sbp list segments' to list all available segments
|
|
# Maybe you don't want to run all segments when in
|
|
# a small window?
|
|
|
|
if [[ "$COLUMNS" -le 120 ]]; then
|
|
# Let's adjust to the smaller screen
|
|
SBP_THEME_LAYOUT='powerline'
|
|
SBP_SEGMENTS_LEFT=('path' 'python_env' 'git' 'command')
|
|
else
|
|
SBP_SEGMENTS_LEFT=('host' 'path' 'python_env' 'k8s' 'git' 'nix')
|
|
SBP_SEGMENTS_RIGHT=('command' 'timestamp')
|
|
SBP_SEGMENTS_LINE_TWO=('prompt_ready')
|
|
fi
|
|
|
|
# Segment specific settings
|
|
SEGMENTS_K8S_DEFAULT_USER="$USER"
|
|
SEGMENTS_K8S_HIDE_CLUSTER=1
|
|
SEGMENTS_LOAD_THRESHOLD=50
|
|
SEGMENTS_LOAD_THRESHOLD_HIGH=80
|
|
SEGMENTS_RESCUETIME_REFRESH_RATE=600
|
|
SEGMENTS_TIMESTAMP_FORMAT="%H:%M:%S"
|
|
SEGMENTS_WTTR_LOCATION='Oslo'
|
|
SEGMENTS_WTTR_FORMAT='%p;%t;%w'
|
|
EOF
|
|
|
|
# Reload the prompt
|
|
sbp reload
|
|
|
|
# Disable the k8s segment (it's a bit too long when working with openshift)
|
|
sbp toggle peekaboo k8s
|
|
#+end_src
|
|
|
|
Congratulations - you should now have a functional, good looking and informative bash prompt! 🎉
|
|
|
|
|
|
** Optional - bluetooth device names
|
|
|
|
On a fresh install a selection of bluetooth devices need to be paired. I prefer a custom naming scheme for these devices, so the snippet below can be used to bulk apply my preferred device names.
|
|
|
|
#+NAME: Rename bluetooth devices
|
|
#+begin_src tmux
|
|
bluetoothctl connect CC:98:8B:B6:F0:8E && bluetoothctl set-alias james-headphones
|
|
bluetoothctl connect CA:20:FE:30:DA:C0 && bluetoothctl set-alias james-travel-mouse
|
|
bluetoothctl connect 80:E1:26:6D:66:4A && bluetoothctl set-alias james-flipper
|
|
bluetoothctl connect 88:C9:E8:5A:56:6C && bluetoothctl set-alias james-earphones
|
|
bluetoothctl connect E2:A0:9F:BC:DB:27 && bluetoothctl set-alias james-home-mouse
|
|
#+end_src
|
|
|
|
|
|
** Optional - disable sleep
|
|
|
|
I just power off my devices when they aren't in use, the snippet below disables sleep buttons and also ensures my devices will never unintentionally sleep when closing lid etc.
|
|
|
|
#+NAME: Disable sleep
|
|
#+begin_src bash
|
|
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
|
|
#+end_src
|