Skip to content

Commit

Permalink
Refactor and update the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kplachkov authored Dec 31, 2024
1 parent 5b6ed18 commit 3b63e3c
Show file tree
Hide file tree
Showing 76 changed files with 359 additions and 1,189 deletions.
6 changes: 0 additions & 6 deletions .bashrc.d/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,3 @@ alias ll='ls -alhF'
alias la='ls -A'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Add an "alert" alias for long running commands. Use like so:
# $ sleep 10; alert
alias alert='notify-send --urgency=critical -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')" && printf "\7"'
2 changes: 0 additions & 2 deletions .bashrc.d/completions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ _have minikube && source <(minikube completion bash)
# shellcheck disable=SC1090
_have kubectl && source <(kubectl completion bash)

_have pipenv && eval "$(pipenv --completion)"

if _have pip3; then
_pip_completion() {
# shellcheck disable=SC2207
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v3

- name: "Test installation"
run: make install
run: make auto-install

lint:
name: "Lint"
Expand Down
34 changes: 17 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
.vscode

*.zip
/config/jetbrains/codestyles/Default.xml
/config/jetbrains/colors/_@user_Darcula.icls
/config/jetbrains/colors/_@user_Default.icls
/config/jetbrains/colors/_@user_High ontrast.icls
/config/jetbrains/options/applicationLibraries.xml
/config/jetbrains/options/docker.xml
/config/jetbrains/options/jdk.table.xml
/config/jetbrains/options/remote-servers.xml
/config/jetbrains/options/databaseDrivers.xml
/config/jetbrains/options/FeatureSuggester.xml
/config/jetbrains/options/ide-features-trainer.xml
/config/jetbrains/options/go.sdk.xml
/config/jetbrains/options/laf.xml
/config/jetbrains/options/nodejs.xml
/config/jetbrains/options/updates.xml
/config/jetbrains/installed.txt
/config/jetbrains/IntelliJ IDEA Global Settings
/.config/jetbrains/codestyles/Default.xml
/.config/jetbrains/colors/_@user_Darcula.icls
/.config/jetbrains/colors/_@user_Default.icls
/.config/jetbrains/colors/_@user_High ontrast.icls
/.config/jetbrains/options/applicationLibraries.xml
/.config/jetbrains/options/docker.xml
/.config/jetbrains/options/jdk.table.xml
/.config/jetbrains/options/remote-servers.xml
/.config/jetbrains/options/databaseDrivers.xml
/.config/jetbrains/options/FeatureSuggester.xml
/.config/jetbrains/options/ide-features-trainer.xml
/.config/jetbrains/options/go.sdk.xml
/.config/jetbrains/options/laf.xml
/.config/jetbrains/options/nodejs.xml
/.config/jetbrains/options/updates.xml
/.config/jetbrains/installed.txt
/.config/jetbrains/IntelliJ IDEA Global Settings
21 changes: 13 additions & 8 deletions .profile.d/exports.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# shellcheck disable=SC2148

export EDITOR="code --wait --new-window"
export VISUAL="code --wait --new-window"
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT="-c"
export BROWSER="google-chrome"

# Don't put duplicate lines or lines starting with space in the history.
export HISTCONTROL=ignoreboth
# Increase the maximum number of commands recorded.
Expand All @@ -26,9 +20,20 @@ export POWERLINE_BASH_CONTINUATION=1
export POWERLINE_BASH_SELECT=1

export HOMEBREW_NO_ANALYTICS=1
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

# Set PATH so it includes user's private bin.
if _have /home/linuxbrew/.linuxbrew/bin/brew; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi

if _have code; then
export EDITOR="code --wait --new-window"
export VISUAL="code --wait --new-window"
fi

if _have bat; then
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT="-c"
fi

if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
Expand Down
255 changes: 242 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,248 @@
.PHONY: install
##@ General

check: fmt lint
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

fmt: ## format code
shfmt -w -s .
auto-install: ## Run automated installation.
@./install.sh

lint: ## run lint check
shfmt -d -s .
shellcheck $$(shfmt -f .)
##@ Operating systems

install: ## install the setup
@install/main.sh
fedora-workstation: configuration gnome dnf-packages tpm ## Install Fedora Workstation setup.

fingerprint: ## generate SHA-256 fingerprint of the dotfiles
@git ls-files | xargs -I {} sha256sum "{}" | cut -d " " -f 1 | sha256sum | cut -d " " -f 1
ubuntu-desktop: configuration gnome apt-packages tpm ## Install Ubuntu Desktop setup.
sudo ubuntu-drivers install

help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
sudo sed -E -i '/(en_US.UTF-8|en_GB.UTF-8)/s/^# //g' /etc/locale.gen
sudo locale-gen
sudo update-locale \
LANG='en_US.UTF-8' \
LC_ADDRESS='en_US.UTF-8' \
LC_NAME='en_US.UTF-8' \
LC_MONETARY='en_US.UTF-8' \
LC_PAPER='en_GB.UTF-8' \
LC_IDENTIFICATION='en_US.UTF-8' \
LC_TELEPHONE='en_US.UTF-8' \
LC_MEASUREMENT='en_GB.UTF-8' \
LC_TIME='en_GB.UTF-8' \
LC_NUMERIC='en_GB.UTF-8'

macos: configuration homebrew homebrew-packages tpm ## Install macOS setup.

github-codespaces: configuration apt-packages tpm ## Install GitHub Codespaces setup.
sudo ubuntu-drivers install

sudo sed -E -i '/(en_US.UTF-8|en_GB.UTF-8)/s/^# //g' /etc/locale.gen
sudo locale-gen
sudo update-locale \
LANG='en_US.UTF-8' \
LC_ADDRESS='en_US.UTF-8' \
LC_NAME='en_US.UTF-8' \
LC_MONETARY='en_US.UTF-8' \
LC_PAPER='en_GB.UTF-8' \
LC_IDENTIFICATION='en_US.UTF-8' \
LC_TELEPHONE='en_US.UTF-8' \
LC_MEASUREMENT='en_GB.UTF-8' \
LC_TIME='en_GB.UTF-8' \
LC_NUMERIC='en_GB.UTF-8'

##@ Desktop environments

gnome: ## Apply GNOME settings.
# Keybindings.
gsettings set org.gnome.desktop.wm.keybindings switch-applications "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-group "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-group-backward "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-windows "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "[]"
gsettings set org.gnome.shell.keybindings toggle-application-view "[]"
gsettings set org.gnome.settings-daemon.plugins.media-keys logout "['<Control><Super>End']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-right "['<Control><Super><Shift>Right']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-left "['<Control><Super><Shift>Left']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['<Super>Above_Tab', '<Control><Super>Right']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['<Shift><Super>Above_Tab', '<Control><Super>Left']"
gsettings set org.gnome.desktop.wm.keybindings show-desktop "['<Super>d']"
gsettings set org.gnome.desktop.wm.keybindings cycle-windows "['<Super>Tab']"
gsettings set org.gnome.desktop.wm.keybindings cycle-windows-backward "['<Shift><Super>Tab']"
gsettings set org.gnome.desktop.wm.keybindings toggle-fullscreen "['<Alt>F11']"
gsettings set org.gnome.desktop.wm.keybindings close "['<Shift><Super>q']"

# Keyboard.
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'bg+phonetic')]"
gsettings set org.gnome.desktop.input-sources per-window true
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable true
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-max-speed 1100
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-init-delay 60
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-accel-time 600
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-accel-time 600

# Night light.
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
gsettings set org.gnome.settings-daemon.plugins.color night-light-schedule-automatic false
gsettings set org.gnome.settings-daemon.plugins.color night-light-schedule-from 5
gsettings set org.gnome.settings-daemon.plugins.color night-light-schedule-to 5
gsettings set org.gnome.settings-daemon.plugins.color night-light-temperature 2700

# Power.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 5400
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 3600

# Appearance.
gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.interface clock-show-weekday true
gsettings set org.gnome.desktop.interface clock-format '24h'
gsettings set org.gnome.desktop.interface show-battery-percentage true

# Miscellaneous.
gsettings set org.gnome.system.locale region 'en_GB.UTF-8'
gsettings set org.gnome.desktop.media-handling autorun-never true
gsettings set org.gnome.desktop.privacy send-software-usage-stats false
gsettings set org.gnome.desktop.privacy report-technical-problems false
gsettings set org.gnome.mutter center-new-windows true
gsettings set org.gtk.Settings.FileChooser show-hidden true
gsettings set org.gtk.Settings.FileChooser sort-directories-first true
gsettings set org.gnome.nautilus.preferences show-delete-permanently true
gsettings set org.gnome.nautilus.preferences show-hidden-files true

##@ Software

dnf-packages: ## Install DNF packages.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' && \
dnf check-update && \
sudo dnf install -y code

sudo dnf install -y \
lshw \
nmap \
powerline \
powerline-fonts \
tmux \
tmux-powerline \
htop \
iftop \
bat \
alacritty

apt-packages: ## Install APT packages.
sudo apt-get update && sudo apt-get upgrade -y

sudo apt-get install -y \
curl \
whois \
net-tools \
apt-transport-https \
ca-certificates \
gnupg \
software-properties-common \
nmap \
htop \
iftop \
tmux \
tree \
xclip \
powerline \
fonts-powerline \
bat \
git \
cmake \
ruby-dev \
shc \
python3-pip \
pipenv \
python3-tk \
libseccomp-dev \
protobuf-compiler \
imagemagick \
gimp

homebrew-packages: ## Install Homebrew packages.
brew install go
brew install node
brew install helm
brew install kubectl
brew install minikube
brew install k9s
brew install lazygit
brew install shellcheck
brew install shfmt
brew install hugo

homebrew: ## Install Homebrew.
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew analytics off

TPM_REPOSITORY = https://github.com/tmux-plugins/tpm
TPM_RELEASE = v3.1.0
TPM_DIR = ~/.tmux/plugins/tpm

tpm: ## Install Tmux Plugin Manager.
git -C $(TPM_DIR) fetch || git clone -c advice.detachedHead=false --branch $(TPM_RELEASE) --depth 1 $(TPM_REPOSITORY) $(TPM_DIR)
git -C $(TPM_DIR) checkout $(TPM_RELEASE)

##@ Common

OS_ID = $(shell grep -oP '^ID="?\K[a-zA-Z0-9_ ]+' /etc/os-release || uname | tr "[:upper:]" "[:lower:]")

EXPORTS_DF_SH_PATH = ~/.profile.d/exports.df.sh

define EXPORTS_DF_SH_TEMPLATE
#!/usr/bin/env bash

# Code generated by dotfiles.

export POWERLINE_BASH_CONFIG='%s'
export POWERLINE_TMUX_CONFIG='%s'
endef

export EXPORTS_DF_SH_TEMPLATE
configuration: ## Apply configurations of packages and dotfiles.
cp -r .profile.d ~/.profile.d
cp -r .bashrc.d ~/.bashrc.d
cp -r .config/alacritty ~/.config/alacritty
cp -r .config/powerline ~/.config/powerline
cp -r .config/lazygit ~/.config/lazygit
cp -r .config/htop ~/.config/htop
cp .bash_profile ~/
cp .bashrc ~/
cp .gitconfig ~/
cp .inputrc ~/
cp .npmrc ~/
cp .tmux.conf ~/
ifeq ($(OS_ID),fedora)
printf "$$EXPORTS_DF_SH_TEMPLATE" \
'/usr/share/powerline/bash/powerline.sh' \
'/usr/share/tmux/powerline.conf' \
> $(EXPORTS_DF_SH_PATH)
else ifeq ($(OS_ID),ubuntu)
printf "$$EXPORTS_DF_SH_TEMPLATE" \
'/usr/share/powerline/bindings/bash/powerline.sh' \
'/usr/share/powerline/bindings/tmux/powerline.conf' \
> $(EXPORTS_DF_SH_PATH)
else
$(warning Unsupported OS/kernel ($(OS_ID)). Powerline may not work.)
endif

gpg-key: ## Generate GPG key.
@gpg --full-generate-key

SSH_COMMENT = $(shell echo "$(USER) - $(OS_ID)")

ssh-keys: ## Generate SSH keys.
ssh-keygen -q -t rsa -b 4096 -C "$(SSH_COMMENT)" -f ~/.ssh/id_rsa
ssh-keygen -q -t ed25519 -C "$(SSH_COMMENT)" -f ~/.ssh/id_ed25519

default-apps: ## Set default applications.
xdg-mime default code.desktop text/plain

##@ Development

fmt: ## Format code.
@shfmt -w -s .

lint: ## Lint code.
@shfmt -d -s .
@shellcheck $$(shfmt -f .)
Loading

0 comments on commit 3b63e3c

Please sign in to comment.