Skip to content

Commit 2c897af

Browse files
authored
feat!: separate configs by operating system
BREAKING CHANGE: changes paths where configs are stored. Update or use `legacy` branch.
1 parent ee82a84 commit 2c897af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1122
-595
lines changed

.gitignore

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
**/.DS_Store
1+
!.figlink
22

3-
home/.config/jesseduffield/lazygit/
4-
home/.config/jesseduffield/lazydocker/development.log
5-
home/.config/karabiner/automatic_backups/
6-
home/.config/zsh/.zcompdump
7-
home/.config/zsh/.zcompcache/
8-
home/.config/nvim/.netrwhist
9-
home/.config/nvim/spell/
3+
.DS_Store
4+
.zcompdump
5+
.zcompcache
106

11-
extras/osx-config/
7+
**/lazydocker/development.log
8+
**/karabiner/automatic_backups/
9+
**/nvim/.netrwhist
10+
**/nvim/spell/
11+
12+
**/lazygit/*/
13+
**/lazygit/state.yml

.script_utils.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
debug_echo() {
2+
echo "> " "$@" >&2
3+
}
4+
5+
set_debug_mode() {
6+
alias mkdir="debug_echo mkdir"
7+
alias mv="debug_echo mv"
8+
alias rm="debug_echo rm"
9+
alias ln="debug_echo ln"
10+
}
11+
12+
get_fig_home() {
13+
fig_root=$(pwd)
14+
[ "${fig_root%%/*}" ] &&
15+
{ echo "error getting path of fig dir" >&2; exit 1; }
16+
17+
fig_home="$fig_root/home"
18+
[ ! -d "$fig_home" ] && mkdir -p "$fig_home"
19+
20+
echo "$fig_home"
21+
}
22+
23+
get_fig_swap() {
24+
xdg_data_home=${XDG_DATA_HOME:-$HOME/.local/share}
25+
26+
fig_swap="$xdg_data_home/fig/$(date +%FT%H:%M:%S)"
27+
[ ! -d "$fig_swap" ] && mkdir -p "$fig_swap"
28+
29+
echo "$fig_swap"
30+
}
31+
32+
get_link_dirs() {
33+
fig_home=$1
34+
find "$fig_home" -mindepth 1 -type f -name ".figlink" -exec dirname {} \; | grep -v "^$"
35+
}
36+
37+
get_link_files() {
38+
fig_home=$1
39+
find "$fig_home" -mindepth 1 -type f
40+
}
41+
42+
get_existing_path() {
43+
fig_home=$1
44+
target=$2
45+
echo "$target" | sed "s|$fig_home|$HOME|"
46+
}
47+
48+
get_backup_path() {
49+
fig_swap=$1
50+
existing=$2
51+
echo "$fig_swap/$(echo "$existing" | tr "/" "%")"
52+
}
53+
54+
needs_backup() {
55+
existing=$1
56+
[ ! -L "$existing" ] && { [ -d "$existing" ] || [ -f "$existing" ]; } && return 0
57+
return 1
58+
}
59+
60+
create_link() {
61+
fig_home=$1
62+
fig_swap=$2
63+
target=$3
64+
65+
existing=$(get_existing_path "$fig_home" "$target")
66+
67+
needs_backup "$existing" &&
68+
! mv "$existing" "$(get_backup_path "$fig_swap" "$existing")" &&
69+
{ echo "error backing up $existing" >&2; exit 2; }
70+
71+
echo "moved existing $(basename "$existing") to $fig_swap"
72+
73+
parent_dir=$(dirname "$existing")
74+
[ -L "$parent_dir" ] && rm "$parent_dir"
75+
[ ! -d "$parent_dir" ] && mkdir -p "$parent_dir"
76+
77+
ln -sFh "$target" "$existing" && echo "created link for $existing"
78+
}

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# About
2+
3+
Fig gives you a simple way to track, backup, and share system configurations.
4+
This repo currently has some of my own configs.
5+
6+
# Usage
7+
8+
If you plan to use this repo, it's probably a good idea to fork it. That way you can
9+
easily make your own changes on top of what's here.
10+
11+
The config files are split up into 4 directories:
12+
- shared_configs - for both Linux and macOS
13+
- linux_configs - specific to Linux
14+
- macos_configs - specific to macOS
15+
- other_configs - other helpful files and scripts
16+
17+
Some of the `*_configs` directories have a `home` directory in them.
18+
It represents the `$HOME` directory of you system.
19+
Here's an example:
20+
If I want a file to exist as `~/.config/foo/bar.conf` on my Linux and macOS systems,
21+
then I should put that file in `shared_configs/home/.config/foo/bar.conf`.
22+
23+
The default behavior of the `link_*_configs.sh` scripts is to create links in `$HOME` that point to the
24+
corresponding file in `*_configs/home`. You can also create links that point to a
25+
corresponding directory by adding a file named `.figlink` to that directory.
26+
27+
# Tips
28+
- I highly recommend simplifying your home directory. I primarily use these:
29+
- repos - where I clone git repos
30+
- save - for anything worth saving, documents, media, etc
31+
- temp - for scratch files, downloads, and anything I won't need in a few months
32+
33+
- If after installing you see and error like: `zsh compinit: insecure directories...`,
34+
check [this](https://stackoverflow.com/a/43544733). It explains why you're seeing that
35+
and how to fix it.
36+
37+
38+
<!--
39+
# Highlights
40+
### nvim
41+
plugins
42+
functions
43+
coding maps
44+
space maps
45+
term, tabs, bufs, splits
46+
## zsh ✔
47+
autocomplete
48+
vi mode
49+
aliases
50+
### lazygit ✔
51+
basics
52+
delta
53+
x key
54+
### lf ✔
55+
marks
56+
H key
57+
hiddenFiles PR
58+
### amethyst ✔
59+
bindings
60+
use workspaces
61+
### karabiner ✔
62+
layers
63+
### vimiumc ✔
64+
? key
65+
disabling keys
66+
### local/bin ✔
67+
swaprm
68+
clipedit
69+
historybackup
70+
### other ✔
71+
docs good
72+
### projects
73+
keys
74+
sink
75+
change
76+
-->

docs/README.md

Lines changed: 0 additions & 120 deletions
This file was deleted.

docs/base-layer.png

-68 KB
Binary file not shown.

docs/layer1.png

-58.1 KB
Binary file not shown.

docs/layer2.png

-60.5 KB
Binary file not shown.

extras/alacritty-new-instance.png

-36.8 KB
Binary file not shown.

extras/link-lazydocker-config.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

extras/link-lazygit-config.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)