aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.stowrc4
-rw-r--r--alacritty/.config/alacritty/alacritty.yml35
-rw-r--r--alacritty/.config/alacritty/options.yml28
-rw-r--r--alacritty/.config/alacritty/shell.yml6
-rw-r--r--wsl/.config/alacritty/font.yml13
-rw-r--r--wsl/.config/alacritty/shell.yml6
-rw-r--r--wsl/.config/wsl/alacritty.yml25
-rwxr-xr-xwsl/.local/bin/mkln.sh254
-rwxr-xr-xwsl/.local/bin/wsl-installer.sh15
9 files changed, 237 insertions, 149 deletions
diff --git a/.stowrc b/.stowrc
index 5d35626..7319f24 100644
--- a/.stowrc
+++ b/.stowrc
@@ -1,4 +1,6 @@
--verbose
--dotfiles
--no-folding
---target=$HOME \ No newline at end of file
+--target=$HOME
+--override=.gnupg/gpg-agent.conf
+--override=.config/alacritty/* \ No newline at end of file
diff --git a/alacritty/.config/alacritty/alacritty.yml b/alacritty/.config/alacritty/alacritty.yml
index f26facc..a24e1ef 100644
--- a/alacritty/.config/alacritty/alacritty.yml
+++ b/alacritty/.config/alacritty/alacritty.yml
@@ -1,12 +1,33 @@
import:
- ~/.config/alacritty/font.yml
- ~/.config/alacritty/colors.yml
- - ~/.config/alacritty/options.yml
- ~/.config/alacritty/key_bindings.yml
+ - ~/.config/alacritty/shell.yml
-shell:
- program: /bin/zsh
- args:
- - -l
- - -c
- - tmux new -As main
+env:
+ TERM: alacritty
+
+window:
+ dimensions:
+ columns: 120
+ lines: 40
+ dynamic_padding: false
+ decorations: full
+ title: Alacritty
+
+scrolling:
+ history: 10000
+ multiplier: 3
+
+selection:
+ save_to_clipboard: false
+
+cursor:
+ blinking: On
+
+mouse:
+ hide_when_typing: true
+
+live_config_reload: true
+
+persistent_logging: false
diff --git a/alacritty/.config/alacritty/options.yml b/alacritty/.config/alacritty/options.yml
deleted file mode 100644
index 1b180c0..0000000
--- a/alacritty/.config/alacritty/options.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-env:
- TERM: alacritty
-
-window:
- dimensions:
- columns: 120
- lines: 40
- dynamic_padding: false
- decorations: full
- title: Alacritty
-
-scrolling:
- history: 10000
- multiplier: 3
-
-selection:
- save_to_clipboard: false
-
-cursor:
- blinking: On
-
-mouse:
- hide_when_typing: true
-
-live_config_reload: true
-
-
-persistent_logging: true \ No newline at end of file
diff --git a/alacritty/.config/alacritty/shell.yml b/alacritty/.config/alacritty/shell.yml
new file mode 100644
index 0000000..04aeab5
--- /dev/null
+++ b/alacritty/.config/alacritty/shell.yml
@@ -0,0 +1,6 @@
+shell:
+ program: /bin/zsh
+ args:
+ - -l
+ - -c
+ - tmux new -As main
diff --git a/wsl/.config/alacritty/font.yml b/wsl/.config/alacritty/font.yml
new file mode 100644
index 0000000..9872d01
--- /dev/null
+++ b/wsl/.config/alacritty/font.yml
@@ -0,0 +1,13 @@
+font:
+ normal:
+ family: FiraCode NF
+ style: Regular
+ bold:
+ family: FiraCode NF
+ style: Bold
+ italic:
+ family: FiraCode NF
+ style: Italic
+ bold_italic:
+ family: FiraCode NF
+ style: Bold Italic \ No newline at end of file
diff --git a/wsl/.config/alacritty/shell.yml b/wsl/.config/alacritty/shell.yml
new file mode 100644
index 0000000..8b80d89
--- /dev/null
+++ b/wsl/.config/alacritty/shell.yml
@@ -0,0 +1,6 @@
+shell:
+ program: C:\WINDOWS\system32\wsl.exe
+ args:
+ - "tmux new -As main"
+
+working_directory: '\\wsl$\Arch\home\tobyv' \ No newline at end of file
diff --git a/wsl/.config/wsl/alacritty.yml b/wsl/.config/wsl/alacritty.yml
deleted file mode 100644
index f05d070..0000000
--- a/wsl/.config/wsl/alacritty.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-import:
- - ~/.config/alacritty/colors.yml
- - ~/.config/alacritty/options.yml
- - ~/.config/alacritty/key_bindings.yml
-
-font:
- normal:
- family: FiraCode NF
- style: Regular
- bold:
- family: FiraCode NF
- style: Bold
- italic:
- family: FiraCode NF
- style: Italic
- bold_italic:
- family: FiraCode NF
- style: Bold Italic
-
-shell:
- program: C:\WINDOWS\system32\wsl.exe
- args:
- - "tmux new -As main"
-
-working_directory: '\\wsl$\Arch\home\tobyv' \ No newline at end of file
diff --git a/wsl/.local/bin/mkln.sh b/wsl/.local/bin/mkln.sh
index ef174c2..60fd719 100755
--- a/wsl/.local/bin/mkln.sh
+++ b/wsl/.local/bin/mkln.sh
@@ -1,115 +1,205 @@
#!/usr/bin/env bash
-TEMP=$(getopt -o hvqdf --long help,verbose,quiet,debug,force \
- -n 'javawrap' -- "$@")
+SCRIPT="$(basename "$0")"
-if [ $? != 0 ]; then
- echo "Terminating..." >&2
- exit 1
-fi
+long='help,verbose,quiet,force,dry-run'
+short='hvqfn'
+
+eval set -- "$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"
-eval set -- "$TEMP"
+help() {
+ cat <<-EOF
+$SCRIPT
+Toby Vincent <tobyv13@gmail.com>
-SCRIPT="$(basename $0)"
-VERBOSE=false
-QUIET=false
-DEBUG=false
-FORCE=false
+$SCRIPT
+ Creates symbolic links (for files) or junctions (for directories) from the
+ windows filesystem to the WSL2 instance using mklink.exe.
-read -r -d '' USAGE <<-EOF
-USAGE: $SCRIPT [OPTIONS] <SOURCE> <TARGET>
+USAGE:
+ $SCRIPT [OPTIONS] <SOURCE> [TARGET]
OPTIONS:
- -h, --help Show this message
- -v, --verbose Show more output
- -q, --quiet Suppress all output
- -d, --debug NOT IMPLEMENTED
- -f, --force Overwrite items
+ -h, --help Show this message
+ -v, --verbose Show more output
+ -q, --quiet Suppress all output
+ -f, --force Overwrite items
+ -n, --dry-run Write output of commands with running them.
ARGS:
- <SOURCE> <TARGET>... File to link.
-EOF
+ SOURCE (required)
+ Path to the source file or directory the link should point to.
+ TARGET (optional)
+ Path to the location to create the link. [Default: $PWD]
+EOF
+}
+
+say() {
+ if ! $quiet; then
+ printf "%s: %s\n" "$SCRIPT" "$@"
+ fi
+}
+
+say_verbose() {
+ if $verbose; then
+ say "$@"
+ fi
+}
+
+say_err() {
+ say "$@" >&2
+}
+
+err() {
+ # shellcheck disable=SC2145
+ say_err "ERROR: $@"
+ exit 1
+}
+
+err_help() {
+ help
+ err "$*"
+}
+
+run() {
+ if $is_dry_run; then
+ say "DRYRUN: $*"
+ return 0
+ fi
+
+ say_verbose "running: $*"
+
+ if $quiet; then
+ "$@" &>/dev/null
+ else
+ say "$("$@")"
+ fi
+}
+
+need() {
+ for cmd in "$@"; do
+ if ! command -v "$cmd" >/dev/null 2>&1; then
+ err "need $cmd (command not found)"
+ fi
+ done
+}
+
+trg=$PWD
+verbose=false
+quiet=false
+force=false
+is_dry_run=false
while true; do
- case "$1" in
+ case "$1" in
-h | --help)
- echo "$USAGE"
- exit 0
- ;;
+ help
+ exit 0
+ ;;
-v | --verbose)
- VERBOSE=true
- shift
- ;;
+ verbose=true
+ shift
+ ;;
-q | --quiet)
- QUIET=true
- shift
- ;;
- -d | --debug)
- DEBUG=true
- shift
- ;;
+ quiet=true
+ shift
+ ;;
-f | --force)
- FORCE=true
- shift
- ;;
+ force=true
+ shift
+ ;;
+ -n | --dry-run)
+ is_dry_run=true
+ shift
+ ;;
--)
- shift
- break
- ;;
+ shift
+ break
+ ;;
*)
- break
- ;;
- esac
+ break
+ ;;
+ esac
done
-if ! command -v powershell.exe &>/dev/null; then
- [ "$QUIET" != true ] && echo "Powershell not found in path." >&2
- exit 1
-fi
+need powershell.exe
+need realpath
-if [ -z "$2" ]; then
- 2="$(pwd)"
-fi
+case "$#" in
+ 0) err_help "must provide at least 1 argument";;
+ 1) src="$1"; trg="$PWD"; shift;;
+ 2) src="$1"; trg="$2"; shift 2;;
+ *) err_help "too many arguments"
+esac
-[ "$VERBOSE" == true ] && echo "linking $2 -> $1"
+while test -L "$src"; do
+ tmp="$src"
+ src=$(realpath "$src")
+ say_verbose "resolved symbolic link $tmp -> $src"
+done
-if [ -d "$1" ]; then
- [ "$VERBOSE" == true ] && echo "$1 is a directory. Creating symbolic link."
- args='/D'
+if ! test -e "$src"; then
+ err "$src does not exist."
fi
-mkdir -p $(dirname $2)
+if test -d "$src"; then
+ say_verbose "$src is a directory. Switching to directory symbolic link."
+ args='/D'
+fi
-source=$(wslpath -w $1)
-target=$(wslpath -w $(dirname $2))\\$(basename $2)
+trg_name=$(basename "$trg")
+trg_dir=$(dirname "$trg")
-if ls -la "$(dirname $2)/" 2>/dev/null | grep -q "$(basename $2)"; then
+if ! test -d "$trg_dir"; then
+ mkdir -p "$trg_dir"
+ say_verbose "created directory $trg_dir"
+fi
- current_path=$(powershell.exe -c "(Get-Item $target).Target" 2>/dev/null)
+win_src=$(wslpath -w "$src")
+win_trg=$(wslpath -w "$trg_dir")\\"$trg_name"
- if [[ "${current_path/*wsl$/}" == *"${source/*wsl$/}"* ]]; then
- [ "$VERBOSE" == true ] && echo "$(basename $2) is set correctly. Skipping."
- exit 0
- fi
+old_trg="$(powershell.exe "(Get-Item $win_trg).FullName" 2>/dev/null)"
+old_src="$(powershell.exe "(Get-Item $win_trg).Target" 2>/dev/null)"
- if [ "$FORCE" == true ]; then
- [ "$VERBOSE" == true ] && echo "$(basename $2) exists. Overwriting."
- rm -rf "$2"
- else
- [ "$QUIET" != true ] && echo "$(basename $target) already exists. Use -f to overwrite." >&2
- exit 1
- fi
-fi
+old_src="${old_src/*wsl$/}"
+new_src="${win_src/*wsl$/}"
-mkdir -p "$(dirname $2)"
-cmd="cd ~; cmd /c mklink ${args} ${target} ${source}"
+if ! $force && test "${old_src#*"$new_src"}" != "$old_src"; then
+ say_verbose "symbolic link already exists."
+ exit 0
+fi
-if [ "$DEBUG" == true ]; then
- [ "$QUIET" != true ] && printf '\nCommand: \n%s\n\n' "powershell.exe -c ${cmd} &>/dev/null"
-else
- if $QUIET; then
- powershell.exe -c "${cmd}" &>/dev/null
- else
- powershell.exe -c "${cmd}"
- fi
+say_verbose "$(cat <<-EOF
+linking:
+ WSL paths:
+ target: $trg
+ source: $src
+ Win paths:
+ target: $win_trg
+ source: $win_src
+EOF
+)"
+
+if test "$old_trg" != ''; then
+ if $force; then
+ say_verbose "$(cat <<-EOF
+$win_trg already exists. Overwriting.
+ target: $win_trg
+ source: $old_src
+EOF
+)"
+ rm -rf "$trg"
+ else
+ err "$(cat <<-EOF
+$win_trg already exists.
+ Existing file:
+ target: $win_trg
+ source: $old_src
+
+ Use -f or --force to overwrite.
+EOF
+)"
+ fi
fi
+
+run powershell.exe "cd ~; cmd /c mklink $args $win_trg $win_src"
diff --git a/wsl/.local/bin/wsl-installer.sh b/wsl/.local/bin/wsl-installer.sh
index db4d015..04f6b00 100755
--- a/wsl/.local/bin/wsl-installer.sh
+++ b/wsl/.local/bin/wsl-installer.sh
@@ -14,12 +14,15 @@ sed -r 's|(RemoteForward\s+.+\s+)\/home\/tobyv\/\.gnupg\/S\.gpg-agent\.extra|\11
sed '/Control/d' >"${WINHOME}/.ssh/config"
# Create windows symlinks to dotfiles
-mkln.sh -f "$@" "${DOTFILES}"/git/.gitconfig "${WINHOME}"/.gitconfig
-mkln.sh -f "$@" "${DOTFILES}"/gnupg/.gnupg/gpg.conf "${WINHOME}"/AppData/Roaming/gnupg/gpg.conf
-mkln.sh -f "$@" "${DOTFILES}"/gnupg/.gnupg/gpg-agent.conf "${WINHOME}"/AppData/Roaming/gnupg/gpg-agent.conf
-mkln.sh -f "$@" "${DOTFILES}"/gnupg/.gnupg/scdaemon.conf "${WINHOME}"/AppData/Roaming/gnupg/scdaemon.conf
-mkln.sh -f "$@" "${DOTFILES}"/wsl/.config/wsl "${WINHOME}"/AppData/Roaming/alacritty
-mkln.sh -f "$@" "${DOTFILES}"/alacritty/.config/alacritty "${WINHOME}"/.config/alacritty
+mkln.sh "$@" "$HOME"/.gitconfig "${WINHOME}"/.gitconfig
+mkln.sh "$@" "$HOME"/.gnupg/gpg.conf "${WINHOME}"/AppData/Roaming/gnupg/gpg.conf
+mkln.sh "$@" "$HOME"/.gnupg/gpg-agent.conf "${WINHOME}"/AppData/Roaming/gnupg/gpg-agent.conf
+mkln.sh "$@" "$HOME"/.gnupg/scdaemon.conf "${WINHOME}"/AppData/Roaming/gnupg/scdaemon.conf
+mkln.sh "$@" "$HOME"/.config/alacritty/alacritty.yml "${WINHOME}"/AppData/Roaming/alacritty/alacritty.yml
+
+for f in "$HOME"/.config/alacritty/*; do
+ mkln.sh "$@" "$f" "${WINHOME}"/.config/alacritty/"$(basename "$f")"
+done
# install xclip/xsel
curl -sL "https://raw.githubusercontent.com/Konfekt/win-bash-xclip-xsel/master/clip.sh" >"${HOME}/.local/bin/xclip"