commit
Updates and add shell script
diff --git a/.gitignore b/.gitignore
index 9bf24ce..20f9eee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,8 @@
!/swaylock/
!/gtklock/
-# --- Terminal + prompt ---
+# --- Terminal + prompt (bashrc is copied to ~/.bashrc by install-config.sh) ---
+!/bashrc
!/kitty/
!/omp/
!/hyfetch.json
@@ -30,13 +31,13 @@
!/gtkrc-2.0
!/xsettingsd/
-# --- Scripts (linked into ~/.local/bin by install-scripts.sh) ---
+# --- Scripts (copied into ~/.local/bin by install-scripts.sh) ---
!/binaries/
# --- Login theme (installed to /usr/share/sddm/themes by install-assets.sh) ---
!/sddm/
-# --- Cursor theme (linked into ~/.icons by install-assets.sh) ---
+# --- Cursor theme (copied into ~/.icons by install-assets.sh) ---
!/icons/
# --- Monitors (they save configs here once you change a setting) ---
diff --git a/README.md b/README.md
index e94e038..5cfd09f 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ A swayfx desktop with a "Clockwork" theme pulled from the wallpaper: deep-space
## Install
-Clone it anywhere, then run the installer. It links everything into place.
+Clone it anywhere, then run the installer. It copies everything into place, so you can delete the clone afterwards (keep it if you want to pull updates and re-run the installer).
On Arch, packages missing from the repos come from the AUR with yay or paru (paru gets installed if you have neither).
```sh
@@ -35,8 +35,8 @@ The installer runs five scripts, and you can run any of them on its own:
| `install-deps.sh` | Installs the software (add `--no-flatpak` or `--no-services` to skip those parts) |
| `install-git.sh` | Sets your git name, email and default branch (asks, or pass `--git-name=`, `--git-email=`, `--git-branch=`; `--defaults` uses User / [email protected] / main) |
| `install-assets.sh` | Installs the font and the cursor |
-| `install-config.sh` | Links the configs into `~/.config` |
-| `install-scripts.sh` | Links the helper scripts into `~/.local/bin` |
+| `install-config.sh` | Copies the configs into `~/.config` and `bashrc` to `~/.bashrc` |
+| `install-scripts.sh` | Copies the helper scripts into `~/.local/bin` |
### Login screen (optional)
@@ -52,7 +52,7 @@ Or add `--with-sddm` to `./install` to get everything at once.
### Background sound (optional)
-Off by default. Turn it on with `./install --with-sound`, or edit these lines in `sway/config` and reload sway:
+Off by default. Turn it on with `./install --with-sound`, or edit these lines in `~/.config/sway/config` and reload sway:
```
set $ambient_sound on
diff --git a/bashrc b/bashrc
new file mode 100644
index 0000000..8027cac
--- /dev/null
+++ b/bashrc
@@ -0,0 +1,94 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+
+# If not running interactively, don't do anything
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+# Prompt is oh-my-posh, configured at the end of this file
+unset color_prompt force_color_prompt
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+
+export NVM_DIR="$HOME/.nvm"
+[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
+[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
+
+# bun (ported from zsh)
+export BUN_INSTALL="$HOME/.bun"
+export PATH="$BUN_INSTALL/bin:$PATH"
+[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun" # bun completions
+
+# local bin (ported from zsh)
+export PATH="$HOME/.local/bin:$PATH"
+
+# Rust (rustup lives in ~/.cargo, shared by Arch and Void via /home)
+[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
+
+# Prompt (cyberpunk powerline), with a plain fallback if the binary is missing
+if command -v oh-my-posh >/dev/null 2>&1; then
+ eval "$(oh-my-posh init bash --config ~/.config/omp/config.toml)"
+else
+ PS1='\n\[\033[38;5;205m\]\u@\h \[\033[38;5;135m\][\w]\[\033[00m\]\n❯ '
+fi
+
+# Greeting: only for interactive shells on a real terminal
+if [[ $- == *i* ]] && [ -t 1 ] && command -v hyfetch >/dev/null 2>&1; then
+ hyfetch
+fi
diff --git a/install b/install
index 6cf4b31..e555c2d 100755
--- a/install
+++ b/install
@@ -3,8 +3,8 @@
# 1. install-deps.sh software (packages, rust + hyfetch, oh-my-posh, flatpaks, services)
# 2. install-git.sh git name, email and default branch
# 3. install-assets.sh font and cursor themes
-# 4. install-config.sh link configs into ~/.config
-# 5. install-scripts.sh link binaries/ into ~/.local/bin
+# 4. install-config.sh copy configs into ~/.config, bashrc to ~/.bashrc
+# 5. install-scripts.sh copy binaries/ into ~/.local/bin
#
# ./install everything
# ./install --dry-run print every command without running anything
@@ -14,7 +14,8 @@
# --git-name=, --git-email=, --git-branch=, --defaults
# passed through to install-git.sh
#
-# Each script also works on its own.
+# Each script also works on its own. Everything is copied, so the clone can
+# be deleted afterwards.
set -uo pipefail
diff --git a/install-assets.sh b/install-assets.sh
index 603c463..7005fe7 100755
--- a/install-assets.sh
+++ b/install-assets.sh
@@ -5,7 +5,7 @@
# ./install-assets.sh --dry-run print the commands without running them
#
# - JetBrainsMono Nerd Font Mono -> ~/.local/share/fonts/jetbrainsmono-nfm (downloaded)
-# - icons/<cursor theme>/ -> linked into ~/.icons/
+# - icons/<cursor theme>/ -> copied into ~/.icons/
# The SDDM login theme has its own script: install-sddm.sh
# The wallpaper needs no step: sway/config points straight at sway/background.png.
# Needs curl, unzip and fontconfig, which install-deps.sh installs.
@@ -26,7 +26,7 @@ step() { printf '\n%s==> %s%s\n' "$c_head" "$*" "$c_off"; }
warn() { printf '%s ! %s%s\n' "$c_warn" "$*" "$c_off"; }
run() { printf ' $ %s\n' "$*"; [ "$DRY" = 1 ] || "$@"; }
-REPO=$(cd "$(dirname "$0")" && pwd)
+REPO=$(cd "$(dirname "$0")" && pwd -P)
[ "$DRY" = 1 ] && echo "Dry run: nothing will be changed."
# ---------- Font ----------
@@ -54,18 +54,24 @@ fi
# ---------- Cursor themes ----------
step "Cursor themes -> ~/.icons"
+stamp=$(date +%Y%m%d-%H%M%S)
for theme in "$REPO"/icons/*/; do
[ -d "$theme" ] || continue
theme=${theme%/}
name=$(basename "$theme") dest="$HOME/.icons/$name"
- if [ "$(readlink "$dest" 2>/dev/null)" = "$theme" ]; then
- echo " $name already linked"
+ if [ -L "$dest" ] && [[ $(readlink -f "$dest") == "$REPO"/* ]]; then
+ echo " $name is a link into the repo, replacing it with a copy"
+ run rm "$dest"
elif [ -e "$dest" ] || [ -L "$dest" ]; then
- warn "$dest already exists and isn't a link to this repo; left it alone"
- else
- run mkdir -p "$HOME/.icons"
- run ln -s "$theme" "$dest"
+ if diff -rq "$theme" "$dest" >/dev/null 2>&1; then
+ echo " $name already up to date"
+ continue
+ fi
+ warn "$name exists, moving it to $name.bak-$stamp"
+ run mv "$dest" "$dest.bak-$stamp"
fi
+ run mkdir -p "$HOME/.icons"
+ run cp -a "$theme" "$dest"
done
step "Done"
diff --git a/install-config.sh b/install-config.sh
index cab4d58..a91f47c 100755
--- a/install-config.sh
+++ b/install-config.sh
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
-# install-config.sh: link this repo's configs into ~/.config.
+# install-config.sh: copy this repo's configs into ~/.config (and bashrc to ~/.bashrc).
#
-# ./install-config.sh link every config folder/file into ~/.config
+# ./install-config.sh copy every config folder/file into ~/.config
# ./install-config.sh --dry-run print the commands without running them
# ./install-config.sh --with-sound turn on the background sound in sway/config
#
# If the repo already *is* ~/.config there is nothing to do.
-# If you cloned it somewhere else (e.g. ~/dotfiles), each config the
-# .gitignore allow-list tracks gets symlinked into ~/.config. Anything
-# already there is moved aside to <name>.bak-<date> first, never deleted.
+# If you cloned it somewhere else (e.g. ~/dots), each config the .gitignore
+# allow-list tracks is copied into ~/.config, so you can delete the clone
+# afterwards. Anything different already there is moved aside to
+# <name>.bak-<date> first, never deleted. Old symlinks into the repo are replaced.
set -uo pipefail
@@ -31,38 +32,68 @@ REPO=$(cd "$(dirname "$0")" && pwd -P)
TARGET="${XDG_CONFIG_HOME:-$HOME/.config}"
[ "$DRY" = 1 ] && echo "Dry run: nothing will be changed."
-if [ "$SOUND" = 1 ]; then
- step "Background sound: on"
- run sed -i 's/^set \$ambient_sound .*/set $ambient_sound on/' "$REPO/sway/config"
- ls "$REPO"/sway/background-sound.* >/dev/null 2>&1 ||
- warn "No sway/background-sound.* file yet; add one and it'll start playing"
-fi
-
-step "Linking configs into $TARGET"
+step "Copying configs into $TARGET"
if [ "$REPO" = "$(cd "$TARGET" 2>/dev/null && pwd -P)" ]; then
echo " The repo is $TARGET itself, so every config is already in place."
- exit 0
+ IN_PLACE=1
+else
+ IN_PLACE=0
fi
# Every "!/name" line in .gitignore is a tracked config, minus the repo's own
# files and the assets that install-assets.sh handles.
mapfile -t ITEMS < <(sed -n 's|^!/\([^/]*\)/\{0,1\}$|\1|p' "$REPO/.gitignore" |
- grep -v -x -E '\.gitignore|README\.md|screenshot\.png|install|install-.*\.sh|icons|binaries|sddm')
+ grep -v -x -E '\.gitignore|README\.md|screenshot\.png|install|install-.*\.sh|icons|binaries|sddm|bashrc')
-stamp=$(date +%Y%m%d-%H%M%S)
-run mkdir -p "$TARGET"
-for item in "${ITEMS[@]}"; do
- src="$REPO/$item" dest="$TARGET/$item"
- [ -e "$src" ] || continue
- if [ "$(readlink "$dest" 2>/dev/null)" = "$src" ]; then
- echo " $item already linked"
- continue
- fi
- if [ -e "$dest" ] || [ -L "$dest" ]; then
- warn "$item exists, moving it to $item.bak-$stamp"
+# place <src> <dest> <label>: copy src to dest. An old link into the repo is
+# swapped for a copy, an identical copy is left alone, anything else is
+# moved to <dest>.bak-<date> first.
+place() {
+ local src=$1 dest=$2 label=$3
+ if [ -L "$dest" ] && [[ $(readlink -f "$dest") == "$REPO"/* ]]; then
+ echo " $label is a link into the repo, replacing it with a copy"
+ run rm "$dest"
+ elif [ -e "$dest" ] || [ -L "$dest" ]; then
+ if diff -rq "$src" "$dest" >/dev/null 2>&1; then
+ echo " $label already up to date"
+ return
+ fi
+ warn "$label exists, moving it to $label.bak-$stamp"
run mv "$dest" "$dest.bak-$stamp"
fi
- run ln -s "$src" "$dest"
-done
+ run cp -a "$src" "$dest"
+}
+
+# Keep the background sound on if a previous install turned it on
+grep -qx 'set $ambient_sound on' "$TARGET/sway/config" 2>/dev/null && SOUND=1
+
+# The sway folder is copied from a staged version with the sound setting
+# applied, so re-running doesn't flag it as changed and back it up.
+stage=$(mktemp -d)
+trap 'rm -rf "$stage"' EXIT
+cp -a "$REPO/sway" "$stage/sway"
+[ "$SOUND" = 1 ] && sed -i 's/^set \$ambient_sound .*/set $ambient_sound on/' "$stage/sway/config"
+
+stamp=$(date +%Y%m%d-%H%M%S)
+if [ "$IN_PLACE" = 0 ]; then
+ run mkdir -p "$TARGET"
+ for item in "${ITEMS[@]}"; do
+ src="$REPO/$item"
+ [ "$item" = sway ] && src="$stage/sway"
+ [ -e "$src" ] || continue
+ place "$src" "$TARGET/$item" "$item"
+ done
+fi
+
+if [ "$SOUND" = 1 ]; then
+ step "Background sound: on"
+ grep -qx 'set $ambient_sound on' "$TARGET/sway/config" ||
+ run sed -i 's/^set \$ambient_sound .*/set $ambient_sound on/' "$TARGET/sway/config"
+ ls "$TARGET"/sway/background-sound.* >/dev/null 2>&1 ||
+ warn "No sway/background-sound.* file yet; add one to $TARGET/sway and it'll start playing"
+fi
+
+step "Shell config -> ~/.bashrc"
+[ -f "$REPO/bashrc" ] && place "$REPO/bashrc" "$HOME/.bashrc" ".bashrc"
step "Done"
diff --git a/install-scripts.sh b/install-scripts.sh
index e993613..a55a8bf 100755
--- a/install-scripts.sh
+++ b/install-scripts.sh
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
-# install-scripts.sh: link every script in binaries/ into ~/.local/bin.
+# install-scripts.sh: copy every script in binaries/ into ~/.local/bin.
#
-# ./install-scripts.sh link the scripts
+# ./install-scripts.sh copy the scripts
# ./install-scripts.sh --dry-run print the commands without running them
#
-# sway and waybar call these as ~/.local/bin/<name>, so they must be linked
-# there. A real file already in the way is moved to <name>.bak-<date>, never deleted.
+# sway and waybar call these as ~/.local/bin/<name>, so they must live there.
+# They're copied, so you can delete the clone afterwards. A different file
+# already in the way is moved to <name>.bak-<date>, never deleted.
set -uo pipefail
@@ -23,26 +24,29 @@ step() { printf '\n%s==> %s%s\n' "$c_head" "$*" "$c_off"; }
warn() { printf '%s ! %s%s\n' "$c_warn" "$*" "$c_off"; }
run() { printf ' $ %s\n' "$*"; [ "$DRY" = 1 ] || "$@"; }
-REPO=$(cd "$(dirname "$0")" && pwd)
+REPO=$(cd "$(dirname "$0")" && pwd -P)
BIN="$HOME/.local/bin"
[ "$DRY" = 1 ] && echo "Dry run: nothing will be changed."
-step "Linking scripts into $BIN"
+step "Copying scripts into $BIN"
run mkdir -p "$BIN"
stamp=$(date +%Y%m%d-%H%M%S)
for src in "$REPO"/binaries/*; do
[ -f "$src" ] || continue
name=$(basename "$src") dest="$BIN/$name"
- [ -x "$src" ] || run chmod +x "$src"
- if [ "$(readlink "$dest" 2>/dev/null)" = "$src" ]; then
- echo " $name already linked"
- continue
- fi
- if [ -e "$dest" ] || [ -L "$dest" ]; then
+ if [ -L "$dest" ] && [[ $(readlink -f "$dest") == "$REPO"/* ]]; then
+ echo " $name is a link into the repo, replacing it with a copy"
+ run rm "$dest"
+ elif [ -e "$dest" ] || [ -L "$dest" ]; then
+ if cmp -s "$src" "$dest" && [ -x "$dest" ]; then
+ echo " $name already up to date"
+ continue
+ fi
warn "$name exists, moving it to $name.bak-$stamp"
run mv "$dest" "$dest.bak-$stamp"
fi
- run ln -s "$src" "$dest"
+ run cp "$src" "$dest"
+ run chmod +x "$dest"
done
case ":$PATH:" in