Compare commits
19 Commits
7d81e68049
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a18dfd678a | |||
| 696bacb597 | |||
| 109bf0f93b | |||
| 844c10948b | |||
| 28f98a23d6 | |||
| 16194ce20f | |||
| 524bdf030d | |||
| 88ccccdb50 | |||
| f2f34750ac | |||
| 8e5ea523b2 | |||
| 4b2490c4aa | |||
| 2fd7a84165 | |||
| 771c7d5fe6 | |||
| 78afb43678 | |||
| 926ac8baa0 | |||
| 5f2e74623b | |||
| c5f1be3006 | |||
| 2fcda19a40 | |||
|
be2e175976
|
25
Makefile
25
Makefile
@@ -2,13 +2,25 @@ BUILD_COMMIT = $(shell git rev-parse HEAD)
|
||||
BASE_IMAGE = registry.fedoraproject.org/fedora-toolbox
|
||||
BASE_IMAGE_VERSION = $(shell cat /etc/os-release | grep VERSION_ID | cut -d = -f 2)
|
||||
REPOSITORY = localhost/toolbox-dev-env
|
||||
STARSHIP_COLOR = $(shell cat starship.$(HOSTNAME).color)
|
||||
|
||||
build:
|
||||
.PHONY: container
|
||||
container:
|
||||
podman build ./container/ --tag $(REPOSITORY):$(BUILD_COMMIT) --build-arg BASE_IMAGE="$(BASE_IMAGE)" --build-arg BASE_IMAGE_VERSION="$(BASE_IMAGE_VERSION)" --build-arg BUILD_COMMIT="$(BUILD_COMMIT)"
|
||||
podman tag $(REPOSITORY):$(BUILD_COMMIT) $(REPOSITORY):latest
|
||||
|
||||
install: build
|
||||
|
||||
.PHONY: container
|
||||
scripts:
|
||||
mkdir --parents ~/.local/share/fonts/
|
||||
curl -sSLo ~/.local/share/fonts/nerdfont.zip https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AdwaitaMono.zip
|
||||
unzip -o ~/.local/share/fonts/nerdfont.zip -d ~/.local/share/fonts/
|
||||
rm ~/.local/share/fonts/nerdfont.zip
|
||||
fc-cache -f -v
|
||||
|
||||
mkdir --parents ~/.local/bin
|
||||
curl -sSo /tmp/starship.sh https://starship.rs/install.sh
|
||||
sh /tmp/starship.sh --yes --bin-dir=$(HOME)/.local/bin
|
||||
|
||||
mkdir --parents ~/.config/bashrc.d
|
||||
cp scripts.d/*.sh ~/.config/bashrc.d/
|
||||
|
||||
@@ -16,4 +28,9 @@ install: build
|
||||
cp completions.d/*.completion ~/.config/completions.d/
|
||||
|
||||
cp bashrc.sh ~/.bashrc
|
||||
cp inputrc ~/.inputrc
|
||||
cp inputrc ~/.inputrc
|
||||
cp starship.toml ~/.config/starship.toml
|
||||
sed -i "s/#XXXXXX/$(STARSHIP_COLOR)/g" ~/.config/starship.toml
|
||||
|
||||
install: container scripts;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ if [ -f /etc/bashrc ]; then
|
||||
fi
|
||||
|
||||
if [ -f '/run/.toolboxenv' ]; then
|
||||
export LOCATION="Toolbox: $(cat /run/.containerenv | grep name | cut -d '=' -f 2)"
|
||||
export LOCATION="Toolbox: $(cat /run/.containerenv | grep name | cut -d '=' -f 2 | tr -d '"')"
|
||||
else
|
||||
export LOCATION="Host: $(hostname)"
|
||||
fi
|
||||
|
||||
@@ -2,4 +2,5 @@ function _dev_completion() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]};
|
||||
COMPREPLY=( $(compgen -W "$(command ls $PROJECTS_PATH)" -- $cur) );
|
||||
}
|
||||
complete -F _dev_completion dev
|
||||
complete -F _dev_completion dev
|
||||
complete -F _dev_completion gg
|
||||
|
||||
@@ -41,7 +41,6 @@ RUN dnf install --assumeyes \
|
||||
pinentry \
|
||||
podman-remote \
|
||||
postgresql \
|
||||
powerline \
|
||||
python3-devel \
|
||||
python3.10 \
|
||||
python3.10-devel \
|
||||
@@ -57,7 +56,11 @@ RUN dnf install --assumeyes \
|
||||
xxhash-devel
|
||||
|
||||
ADD github-install.bash /tmp/github-install.bash
|
||||
RUN bash /tmp/github-install.bash && rm -rf /tmp/github-install.bash
|
||||
RUN bash /tmp/github-install.bash && \
|
||||
rm -rf /tmp/github-install.bash && \
|
||||
curl -sSLo /tmp/starship.sh https://starship.rs/install.sh && \
|
||||
sh /tmp/starship.sh --yes && \
|
||||
rm -rf /tmp/starship.sh
|
||||
|
||||
ADD profile.d/*.sh /etc/profile.d/
|
||||
|
||||
|
||||
87
container/profile.d/toolbox.sh
Normal file
87
container/profile.d/toolbox.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
# This is a patched version of the default toolbox.sh that
|
||||
# comes with default toolbox images. The only thing I modified
|
||||
# is removing the mucking about with PS1 since I'm using starship
|
||||
# for that
|
||||
|
||||
# shellcheck shell=sh
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
[ "${BASH_VERSION:-}" != "" ] || [ "${ZSH_VERSION:-}" != "" ] || return 0
|
||||
[ "$PS1" != "" ] || return 0
|
||||
|
||||
toolbox_config="$HOME/.config/toolbox"
|
||||
host_welcome_stub="$toolbox_config/host-welcome-shown"
|
||||
toolbox_welcome_stub="$toolbox_config/toolbox-welcome-shown"
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
# shellcheck disable=SC2046
|
||||
eval $(
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
else
|
||||
. /usr/lib/os-release
|
||||
fi
|
||||
|
||||
echo ID="$ID"
|
||||
echo PRETTY_NAME="\"$PRETTY_NAME\""
|
||||
echo VARIANT_ID="$VARIANT_ID"
|
||||
)
|
||||
|
||||
if [ -f /run/ostree-booted ] \
|
||||
&& ! [ -f "$host_welcome_stub" ] \
|
||||
&& [ "${ID}" = "fedora" ] \
|
||||
&& { [ "${VARIANT_ID}" = "workstation" ] \
|
||||
|| [ "${VARIANT_ID}" = "silverblue" ] \
|
||||
|| [ "${VARIANT_ID}" = "kinoite" ] \
|
||||
|| [ "${VARIANT_ID}" = "sericea" ]; }; then
|
||||
echo ""
|
||||
echo "Welcome to ${PRETTY_NAME:-Linux}."
|
||||
echo ""
|
||||
echo "This terminal is running on the host system. You may want to try"
|
||||
echo "out the Toolbx for a directly mutable environment that allows "
|
||||
echo "package installation with DNF."
|
||||
echo ""
|
||||
printf "For more information, see the "
|
||||
# shellcheck disable=SC1003
|
||||
printf '\033]8;;https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/\033\\documentation\033]8;;\033\\'
|
||||
printf ".\n"
|
||||
echo ""
|
||||
|
||||
mkdir -p "$toolbox_config"
|
||||
touch "$host_welcome_stub"
|
||||
fi
|
||||
|
||||
if [ -f /run/.containerenv ] \
|
||||
&& [ -f /run/.toolboxenv ]; then
|
||||
if ! [ -f /etc/profile.d/vte.sh ] && [ -z "$PROMPT_COMMAND" ] && [ "${VTE_VERSION:-0}" -ge 3405 ]; then
|
||||
case "$TERM" in
|
||||
xterm*|vte*)
|
||||
[ -n "${BASH_VERSION:-}" ] && PROMPT_COMMAND=" "
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "$TERM" != "" ]; then
|
||||
error_message="Error: terminfo entry not found for $TERM"
|
||||
term_without_first_character="${TERM#?}"
|
||||
term_just_first_character="${TERM%"$term_without_first_character"}"
|
||||
terminfo_sub_directory="$term_just_first_character/$TERM"
|
||||
|
||||
if [ "$TERMINFO" = "" ]; then
|
||||
! [ -e "/usr/share/terminfo/$terminfo_sub_directory" ] \
|
||||
&& ! [ -e "/lib/terminfo/$terminfo_sub_directory" ] \
|
||||
&& ! [ -e "$HOME/.terminfo/$terminfo_sub_directory" ] \
|
||||
&& echo "$error_message" >&2
|
||||
else
|
||||
! [ -e "$TERMINFO/$terminfo_sub_directory" ] \
|
||||
&& echo "$error_message" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
unset ID
|
||||
unset PRETTY_NAME
|
||||
unset VARIANT_ID
|
||||
unset toolbox_config
|
||||
unset host_welcome_stub
|
||||
unset toolbox_welcome_stub
|
||||
@@ -14,4 +14,5 @@ alias prun="poetry run"
|
||||
alias psync="poetry install --sync"
|
||||
alias code='codium'
|
||||
alias ssh='ssh -F ~/.ssh/config'
|
||||
alias whereami='echo $LOCATION'
|
||||
alias whereami='echo $LOCATION'
|
||||
alias gg='dev'
|
||||
@@ -1,6 +0,0 @@
|
||||
if [ -f `which powerline-daemon` ]; then
|
||||
powerline-daemon -q
|
||||
POWERLINE_BASH_CONTINUATION=1
|
||||
POWERLINE_BASH_SELECT=1
|
||||
. /usr/share/powerline/bash/powerline.sh
|
||||
fi
|
||||
11
scripts.d/10-starship.sh
Normal file
11
scripts.d/10-starship.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
function set_window_title() {
|
||||
if [[ "${PWD}" == $PROJECTS_PATH/* ]]; then
|
||||
echo -ne "\033]0; Project: $(basename ${PWD}) \007"
|
||||
else
|
||||
echo -ne "\033]0; $LOCATION \007"
|
||||
fi
|
||||
}
|
||||
|
||||
starship_precmd_user_func="set_window_title"
|
||||
|
||||
eval "$(starship init bash)"
|
||||
@@ -5,11 +5,11 @@ function dev() {
|
||||
echo "WARNING: Missing project name";
|
||||
project=""
|
||||
else
|
||||
project="${2}"
|
||||
project="${1}"
|
||||
fi
|
||||
|
||||
if [ -f '/run/.toolboxenv' ]; then
|
||||
cd "${PROJECTS_DIR}/${project}";
|
||||
cd "${PROJECTS_PATH}/${project}";
|
||||
|
||||
if [ -f "${PWD}/ansible.cfg" ]; then
|
||||
export ANSIBLE_CONFIG="${PWD}/ansible.cfg";
|
||||
@@ -19,7 +19,7 @@ function dev() {
|
||||
if [ -f "${PWD}/pyproject.toml" ]; then
|
||||
poetry_venv=$(poetry env info --path)
|
||||
|
||||
if [ ! -z "${poetry_venv}" ]; then
|
||||
if [ ! -z "${poetry_venv}" ] && [ -f "${poetry_venv}/bin/activate" ]; then
|
||||
source "${poetry_venv}/bin/activate";
|
||||
fi
|
||||
fi
|
||||
@@ -39,8 +39,8 @@ function dev() {
|
||||
echo ">>> Loading project: ${project}"
|
||||
echo ">>> ${PWD}"
|
||||
toolbox enter "${container_name}"
|
||||
echo ">>> Exited: ${namespace}"
|
||||
cd ${current}
|
||||
echo ">>> Exited: ${container_name}"
|
||||
cd "${current}"
|
||||
|
||||
podman container stop "${container_name}" &>/dev/null
|
||||
podman container rm --force "${container_name}" &>/dev/null
|
||||
@@ -48,7 +48,8 @@ function dev() {
|
||||
}
|
||||
|
||||
if [ -f '/run/.toolboxenv' ]; then
|
||||
if [ "${PWD}" == "$PROJECTS_PATH/*" ]; then
|
||||
if [[ "${PWD}" == $PROJECTS_PATH/* ]]; then
|
||||
dev $(basename "${PWD}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
1
starship.discovery.color
Normal file
1
starship.discovery.color
Normal file
@@ -0,0 +1 @@
|
||||
#893937
|
||||
49
starship.toml
Normal file
49
starship.toml
Normal file
@@ -0,0 +1,49 @@
|
||||
add_newline = false
|
||||
|
||||
format = '[ ](bold fg:#000000 bg:#XXXXXX)${custom.toolbox}${custom.localhost}[](bold fg:#XXXXXX bg:#444444)$directory$python$git_branch$git_status$status$character'
|
||||
|
||||
[directory]
|
||||
format = "[$read_only]($read_only_style)[$path ]($style)[](fg:#444444 bg:#000000)"
|
||||
style = "fg:bright-white bg:#444444"
|
||||
read_only = ' '
|
||||
read_only_style = "bold fg:red bg:#444444"
|
||||
truncation_symbol = ' '
|
||||
home_symbol = '~'
|
||||
[directory.substitutions]
|
||||
'/' = ' '
|
||||
'~ ' = ''
|
||||
|
||||
[character]
|
||||
success_symbol = '[](bold fg:#000000)'
|
||||
error_symbol = '[](bold fg:#6d0505)'
|
||||
|
||||
[status]
|
||||
disabled = false
|
||||
symbol = ''
|
||||
pipestatus = true
|
||||
style = "bold fg:bright-white bg:#6d0505"
|
||||
format = '[](bold fg:#000000 bg:#6d0505)[ $status ]($style)'
|
||||
|
||||
[git_branch]
|
||||
symbol = ''
|
||||
format = '[](bold fg:#000000 bg:#44b240)[$symbol $branch]($style)[](bold bg:#000000 fg:#44b240)'
|
||||
style = 'bold bg:#44b240 fg:black'
|
||||
|
||||
[git_status]
|
||||
style = "bold fg:black bg:#f4862c"
|
||||
format = '([](bold fg:#000000 bg:#f4862c)[$all_status$ahead_behind]($style)[](bold bg:#000000 fg:#f4862c))'
|
||||
|
||||
[python]
|
||||
style = 'bold bg:#fcf52a fg:black'
|
||||
symbol = ''
|
||||
format = '([](bold fg:#000000 bg:#fcf52a)[$virtualenv]($style)[](bold bg:#000000 fg:#fcf52a))'
|
||||
|
||||
[custom.toolbox]
|
||||
style = "bold bg:#XXXXXX fg:bright-white"
|
||||
command = "echo -ne ' toolbox'"
|
||||
when = '[ -f /run/.toolboxenv ]'
|
||||
|
||||
[custom.localhost]
|
||||
style = "bold bg:#XXXXXX fg:bright-white"
|
||||
command = 'echo -ne " $HOSTNAME"'
|
||||
when = '[ ! -f /run/.toolboxenv ]'
|
||||
1
starship.voyager.color
Normal file
1
starship.voyager.color
Normal file
@@ -0,0 +1 @@
|
||||
#01568e
|
||||
Reference in New Issue
Block a user