Skip to content

Commit

Permalink
refactor project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel committed Jul 27, 2024
1 parent afdf153 commit bd9839d
Show file tree
Hide file tree
Showing 44 changed files with 284 additions and 226 deletions.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified assets/iterm.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/vscode.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions bootstrap.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env fish
#
# bootstrap installs things.

# set -gx STD_DEBUG /dev/stdout

set -gx DOTFILES_ROOT (pwd -P)
set -gx FISH_CONFIG "$HOME/.config/fish"

source $DOTFILES_ROOT/lib/*

make 'check prerequisites'
and type -q fish
and type -q brew
and type -q git
and type -q vim
and success 'check prerequisites'
or abort "Install 'fish', 'git', 'vim', and 'brew' first"

for init in install_pre/*/init.fish
set -l STEP_NAME $(basename $(dirname $init))
make Configuring $STEP_NAME
and run_with_prefix fish $init
and success Configured $STEP_NAME
or abort Aborted $STEP_NAME
end

for init in install/*/init.fish
set -l STEP_NAME $(basename $(dirname $init))
make Configuring $STEP_NAME
and run_with_prefix fish $init
and success Configured $STEP_NAME
or abort Aborted $STEP_NAME
end
Empty file added dupa
Empty file.
12 changes: 0 additions & 12 deletions fish/init.fish

This file was deleted.

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.
15 changes: 15 additions & 0 deletions install/fish/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/fish
set FISH_CONFIG "$HOME/.config/fish"
source $DOTFILES_ROOT/lib/*

set -l plugins (cat $DOTFILES_ROOT/install/fish/fisher_list)
fisher install $plugins >/dev/null
and info_installation_complete "fisher plugins"
or abort "fisher plugins"

lnWithBackup $STEP_PATH/config.fish $FISH_CONFIG/config.fish
lnFishFolder $STEP_PATH/conf.d $FISH_CONFIG/conf.d
lnFishFolder $STEP_PATH/functions $FISH_CONFIG/functions
8 changes: 5 additions & 3 deletions iterm2/init.fish → install/iterm2/init.fish
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env fish

source $argv[1]/scripts/common.fish
set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/iterm2
source $DOTFILES_ROOT/lib/*

if test -f /Library/Fonts/"RobotoMonoNerdFont-Regular.ttf"
info_installation_skipped "RobotoMonoNerdFont-Regular.ttf"
else
curl -fLo /Library/Fonts/"RobotoMonoNerdFont-Regular.ttf" \
https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/RobotoMono/Regular/RobotoMonoNerdFont-Regular.ttf \
&>/dev/null
>/dev/null
info_installation_complete "RobotoMonoNerdFont-Regular.ttf"
end

if test -f ~/Library/"Application Support"/iTerm2/DynamicProfiles/natural-fish.json
info_installation_skipped "natural-fish.json"
else
lnWithBackup $argv[1]/iterm2/natural-fish.json \
lnWithBackup $STEP_PATH/natural-fish.json \
~/Library/"Application Support"/iTerm2/DynamicProfiles/natural-fish.json
info_installation_complete "natural-fish.json"
end
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions install/k9s/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/k9s
set K9S_CONFIG "$HOME/.config/k9s"
source $DOTFILES_ROOT/lib/*

mkdir -p $K9S_CONFIG

lnWithBackup $STEP_PATH/skin.yml \
$K9S_CONFIG/skin.yml

info_installation_complete "skin.yml"

lnWithBackup $STEP_PATH/config.yml \
$K9S_CONFIG/config.yml

info_installation_complete "config.yml"

lnWithBackup $STEP_PATH/plugin.yml \
$K9S_CONFIG/plugin.yml

info_installation_complete "plugin.yml"
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions tmux/init.fish → install/tmux/init.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env fish

source $argv[1]/scripts/common.fish
set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/tmux
source $DOTFILES_ROOT/lib/*

if test -d ~/.tmux/plugins/tpm
info_installation_skipped 'tpm'
Expand All @@ -16,4 +18,4 @@ else
info_installation_complete 'tmux-natural'
end

lnWithBackup $argv[1]/tmux/.tmux.conf $HOME/.tmux.conf
lnWithBackup $STEP_PATH/.tmux.conf $HOME/.tmux.conf
File renamed without changes.
10 changes: 6 additions & 4 deletions vim/init.fish → install/vim/init.fish
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env fish

source $argv[1]/scripts/common.fish
set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/vim
source $DOTFILES_ROOT/lib/*

if test -f ~/.vim/autoload/plug.vim
info_installation_skipped 'vim-plug'
else
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim &>/dev/null
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim >/dev/null
info_installation_complete 'vim-plug'
end

lnWithBackup $argv[1]/vim/.vimrc $HOME/.vimrc
lnWithBackup $STEP_PATH/.vimrc $HOME/.vimrc

mkdir -p $HOME/.config/nvim
lnWithBackup $argv[1]/vim/init.vim $HOME/.config/nvim/init.vim
lnWithBackup $STEP_PATH/init.vim $HOME/.config/nvim/init.vim
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions vscode/init.fish → install/vscode/init.fish
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/usr/bin/env fish

source $argv[1]/scripts/common.fish
set DOTFILES_ROOT (pwd -P)
set STEP_PATH $DOTFILES_ROOT/install/vscode
source $DOTFILES_ROOT/lib/*

if test -f /Library/Fonts/"DejaVuSansMNerdFont-Regular.ttf"
info_installation_skipped "DejaVuSansMNerdFont-Regular.ttf"
else
curl -fLo /Library/Fonts/"DejaVuSansMNerdFont-Regular.ttf" \
https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/DejaVuSansMNerdFont-Regular.ttf \
&>/dev/null
>/dev/null
info_installation_complete "font 'DejaVuSansMNerdFont-Regular.ttf'"
end

lnWithBackup "$argv[1]/vscode/settings.json" "$HOME/Library/Application Support/Code/User/settings.json"
lnWithBackup "$STEP_PATH/settings.json" "$HOME/Library/Application Support/Code/User/settings.json"

cat $argv[1]/vscode/extensions | while read line
cat $STEP_PATH/extensions | while read line
code --install-extension "$line" >/dev/null
and info_installation_complete "$line"
or abort_installation "$line"
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions install_pre/fisher/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
source $DOTFILES_ROOT/lib/*

if type -q 'fisher'
info_installation_skipped 'fisher'
else
curl -sL git.io/fisher | source && fisher install jorgebucaran/fisher >/dev/null
info_installation_complete 'fisher'
end
21 changes: 21 additions & 0 deletions install_pre/git/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
source $DOTFILES_ROOT/lib/*

if test -z (git config --global --get user.email)
ask 'What is your github author email?'
read user_email
test -n $user_email
or abort "empty author email"
end
if test -z (git config --global --get user.name)
ask 'What is your github author name?'
read user_name
test -n $user_name
or abort "empty author name"
end
git config --global user.name $user_name >/dev/null
and git config --global user.email $user_email >/dev/null
or abort 'failed to setup git user name and email'

15 changes: 15 additions & 0 deletions install_pre/krew/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
source $DOTFILES_ROOT/lib/*

set -l temp_dir (mktemp -d)

pushd $temp_dir
set -l _OS (uname | tr '[:upper:]' '[:lower:]')
and set -l _ARCH (uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')
and set -l _KREW krew-$_OS"_"$_ARCH
and curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/$_KREW.tar.gz"
and tar zxvf $_KREW.tar.gz >/dev/null
and ./$_KREW install krew >/dev/null
popd
File renamed without changes.
33 changes: 33 additions & 0 deletions install_pre/pkg_manager/brew.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
source $DOTFILES_ROOT/lib/*

set -l file_name $argv[1]
set -l cask $argv[2]

function install
set -l val $argv[1]

if brew ls --versions $val >/dev/null
run_with_prefix brew upgrade $val
else if test -n "$cask"
run_with_prefix brew install --cask $val
else
run_with_prefix brew install $val
end
end

set -l brew_list
while read -la line
set brew_list $brew_list $line
end < $DOTFILES_ROOT/install_pre/pkg_manager/$file_name

for val in $brew_list
make "Installing $val..."

install $val
or abort_installation $val

info_installation_complete $val
end
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions install_pre/pkg_manager/init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env fish

set DOTFILES_ROOT (pwd -P)
source $DOTFILES_ROOT/lib/lib.fish

set BREW_INSTALL $DOTFILES_ROOT/install_pre/pkg_manager/brew.fish

# TODO: support linux
make 'Update brew'
and run_with_prefix brew update --auto-update
and success 'Updated brew'
or abort 'Updated brew'

$BREW_INSTALL "brew"

$BREW_INSTALL 'brew_cask' "true"

$BREW_INSTALL 'brew_custom'
20 changes: 0 additions & 20 deletions k9s/init.fish

This file was deleted.

7 changes: 7 additions & 0 deletions lib/lib.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env fish

set LIB_PATH (pwd -P)/lib

source $LIB_PATH/log.fish
source $LIB_PATH/run_with_prefix.fish
source $LIB_PATH/utils.fish
38 changes: 38 additions & 0 deletions lib/log.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env fish

function info_installation_complete
success "Installation complete for $argv"
end

function info_installation_skipped
skip "Installation skipped for $argv"
end

function info
echo '[ .. ]' $argv &>/dev/stdout
end

function ask
echo [(set_color --bold yellow)' ?? '(set_color normal)] $argv &>/dev/stdout
end

function make
echo [(set_color --bold blue)'MAKE'(set_color normal)] $argv &>/dev/stdout
end

function success
echo [(set_color --bold green)'DONE'(set_color normal)] $argv &>/dev/stdout
end

function skip
echo [(set_color --bold yellow)'SKIP'(set_color normal)] $argv &>/dev/stdout
end

function abort
echo [(set_color --bold red)'ABRT'(set_color normal)] $argv &>/dev/stderr
exit 1
end

function abort_installation
abort "Installation aborted for '$argv'" &>/dev/stdout
end
22 changes: 22 additions & 0 deletions lib/run_with_prefix.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env fish

function run_with_prefix
if test $DOTFILES_STREAM
$argv &>$DOTFILES_STREAM_2
else
# primary stream (stdout/stderr)
set -x DOTFILES_STREAM (mktemp -u)
touch "$DOTFILES_STREAM"

# double prefixed stream
set -x DOTFILES_STREAM_2 (mktemp -u)
touch "$DOTFILES_STREAM_2"

tail -f $DOTFILES_STREAM | sed 's/^/ /' &
tail -f $DOTFILES_STREAM_2 | sed 's/^/ /' &
$argv &>$DOTFILES_STREAM

kill -SIGKILL %2 %1
rm -f $DOTFILES_STREAM &>/dev/null
end
end
Loading

0 comments on commit bd9839d

Please sign in to comment.