Skip to content

Commit

Permalink
Merge pull request #4 from varp/shell-functions-refactor
Browse files Browse the repository at this point in the history
Shell functions refactor
  • Loading branch information
varp authored Nov 11, 2024
2 parents 6686f6e + 320396b commit d7dbc7a
Show file tree
Hide file tree
Showing 17 changed files with 491 additions and 409 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"entrypoint",
"gitignore",
"gitlens",
"gopls",
"rainglow",
"vardan",
"varp",
"vimrc"
]
}
}
89 changes: 62 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ FORCE_INSTALL?=false
$(SRC_DOTFILES) dotfiles-dotfiles \
$(SRC_VSCODE_SETTINGS) dotfiles-vscode \
dev-node dev-go dev-php \
editor-vim-vundle editor-micro editor-micro-plugins editor-neovim \
tool-brew tool-powerline-go tool-bat \
editor-micro editor-micro-plugins editor-neovim \
tool-brew tool-powerline-go tool-bat tool-zoxide tool-fzf tool-ripgrep \
@base @base-tools @dotfiles-group @tools-group \
dotfiles tools editors devs \
all \
Expand Down Expand Up @@ -67,29 +67,21 @@ dotfiles-vscode: $(SRC_VSCODE_SETTINGS)
dst=$(addprefix $(DEST_VSCODE_SETTINGS_DIR)/,$$vscodeDotFile); \
ln -vsf "$$src" "$$dst"; \
done

#: Install VimVundle package mamanger (see: https://github.com/VundleVim/Vundle.vim) #editors
editor-vim-vundle:
-@[ -L $(VIM_VUNDLE_DIR) ] && unlink $(VIM_VUNDLE_DIR)
-@[ -d $(VIM_VUNDLE_DIR) ] && rm -rf $(VIM_VUNDLE_DIR)
-@mkdir -p $(VIM_VUNDLE_DIR)
git clone $(VIM_VUNDLE_REPO) $(VIM_VUNDLE_DIR)/Vundle.vim

#: Install Neovim (see: https://github.com/neovim/neovim) #editors
editor-neovim:
editor-neovim: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v nvim >/dev/null; then \
if [[ "$$(uname -s)" == "Darwin" ]]; then \
brew install neovim; \
else \
curl -L https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.deb -o /tmp/nvim-linux64.deb && \
apt install -y /tmp/nvim-linux64.deb && apt install -fy; \
sudo snap install --beta nvim --classic; \
fi \
else \
echo -e "$(@):\n $$(nvim --version)"; \
fi

#: Install micro (see: https://micro-editor.github.io/) #editors
editor-micro:
editor-micro: tool-brew
@if ! command -v micro >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install micro; \
Expand All @@ -110,24 +102,29 @@ editor-micro-plugins: editor-micro
echo -e "$(@):\n micro editor is not installed"; \
fi

#: Install Homebrew (see: https://brew.sh) #tools
tool-brew:
@if [[ "$$(uname -s)" == "Darwin" ]]; then \
if [[ "$(FORCE_INSTALL)" != "false" ]] || ! brew --version >/dev/null; then \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
fi \
fi

#: Install powerline-go (see: https://github.com/justjanne/powerline-go) #tools
tool-powerline-go: dev-go bin-folder
@platAsset="powerline-go-$$(go env GOOS)-$$(go env GOARCH)"; \
url="https://github.com/justjanne/powerline-go/releases/latest/download/$$platAsset"; \
curl -L $$url -o $(DST_BIN_DIR)/powerline-go; \
chmod a+x $(DST_BIN_DIR)/powerline-go

#: Install Homebrew (see: https://brew.sh) #tools
tool-brew:
@if [[ "$$(uname -s)" == "Darwin" ]]; then \
if ! brew --version >/dev/null; then \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
fi \
fi

#: Install oh-my-posh (see: https://ohmyposh.dev/) #tools
tool-oh-my-posh: bin-folder
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d $(DST_BIN_DIR)

#: Install bat (see: https://github.com/sharkdp/bat) #tools
tool-bat: brew
@if ! command -v bat >/dev/null; then \
tool-bat: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v bat >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install bat; \
else \
Expand All @@ -137,8 +134,46 @@ tool-bat: brew
echo -e "$(@):\n $$(bat --version)"; \
fi

#: Install zoxide (see: https://github.com/ajeetdsouza/zoxide) #tools
tool-zoxide: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v zoxide >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install zoxide; \
else \
sudo apt install -y zoxide; \
fi \
else \
echo -e "$(@):\n $$(zoxide --version)"; \
fi


#: Install fzf (see: https://github.com/junegunn/fzf) #tools
tool-fzf: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v fzf >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install fzf; \
else \
sudo apt install -y fzf; \
fi \
else \
echo -e "$(@):\n $$(fzf --version)"; \
fi

#: Install ripgrep (see: https://github.com/BurntSushi/ripgrep) #tools
tool-ripgrep: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v ripgrep >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install ripgrep; \
else \
sudo apt install -y ripgrep; \
fi \
else \
echo -e "$(@):\n $$(rg --version)"; \
fi


#: Install NodeJs (see: https://nodejs.org) #dev
dev-node: brew
dev-node: tool-brew
@if [[ "$(FORCE_INSTALL)" != "false" ]] || ! command -v node >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install node; \
Expand All @@ -159,7 +194,7 @@ dev-node-nvm:
fi

#: Install Go (see: https://go.dev) #dev
dev-go: brew
dev-go: tool-brew
@if ! command -v go >/dev/null; then \
if [ "$$(uname -s)" = "Darwin" ]; then \
brew install go; \
Expand All @@ -171,7 +206,7 @@ dev-go: brew
fi

#: Install PHP (see: https://php.net) #dev
dev-php: brew
dev-php: tool-brew
@if ! command -v php >/dev/null; then \
if [ "$$(uname -s)" == "Darwin" ]; then \
brew install php; \
Expand All @@ -188,7 +223,7 @@ release-tag:


@base: dotfiles-dotfiles bin-folder
@base-tools: tool-powerline-go tool-bat
@base-tools: tool-powerline-go tool-oh-my-posh tool-bat tool-zoxide tool-fzf tool-ripgrep

ifeq ($(shell uname -s), Darwin)
@dotfiles-group: @base dotfiles-vscode
Expand All @@ -202,7 +237,7 @@ endif
dotfiles: @dotfiles-group

#: Installs micro and VimVundle
editors: editor-micro editor-micro-plugins editor-vim-vundle
editors: editor-micro editor-micro-plugins editor-neovim

#: Installs powerline-go. On MacOS: Homebrew #group
tools: @tools-group
Expand Down
5 changes: 1 addition & 4 deletions brew/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ brew "bash"
brew "bash-completion@2"
brew "coreutils"
brew "binutils"
brew "bat"
brew "ripgrep"
brew "neovim"
brew "micro"
# dev
brew "git"
brew "git-lfs"
Expand Down Expand Up @@ -52,4 +48,5 @@ cask "notion"
cask "obsidian"

# fonts
cask "font-jetbrains-mono"
cask "font-jetbrains-mono-nerd-font"
3 changes: 3 additions & 0 deletions dotfiles.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"--shell=bash"
],
"shellcheck.useWorkspaceRootAsCwd": true,
"cSpell.words": [
"gopls"
],
}
}
126 changes: 0 additions & 126 deletions dotfiles/base16_theme

This file was deleted.

6 changes: 1 addition & 5 deletions dotfiles/bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if [[ $(whoami) == "root" ]]; then
PS1="${debian_chroot:+($debian_chroot)}\[\e[104m\]\A\[\e[0m\] \[\e[41m\]\u@\H\[\e[0m\] @ \w \n\[\e[41m\]#\[\e[0m\] "
else
PS1="${debian_chroot:+($debian_chroot)}\[\e[104m\]\t\[\e[0m\]\[\e[46m\] \u \[\e[0m\]\[\e[44m\] \w \[\e[0m\]\[\e[47m\]\[\e[0;33;47m\]\$(parse_git_branch)\[\e[0;0m\]\[\e[1;34;47m\]$(parse_languages)\[\e[0;0m\]\$ "
PS1="${debian_chroot:+($debian_chroot)}\[\e[104m\]\t\[\e[0m\]\[\e[46m\] \u \[\e[0m\]\[\e[44m\] \w \[\e[0m\]\$ "
fi

# iTerm integration
Expand All @@ -27,11 +27,7 @@ __update_ps1() {
# rm -f "$INTERACTIVE_BASHPID_TIMER"
# fi

_LANGS_ENV="$(parse_languages)"
export _LANGS_ENV

local mods="cwd,perms,git,shell-var,goenv,docker,docker-context,jobs,exit,root"
local args="-shell-var _LANGS_ENV"

if [ -n "$SSH_CONNECTION" ]; then
mods="termtitle,time,cwd,perms,load,shell-var,dotenv,host,user,jobs,exit,ssh,root"
Expand Down
21 changes: 1 addition & 20 deletions dotfiles/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ HISTCONTROL=ignoreboth
shopt -s histappend dirspell cdable_vars cdspell direxpand huponexit no_empty_cmd_completion nocaseglob autocd

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=500
HISTSIZE=5000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
Expand Down Expand Up @@ -77,7 +77,6 @@ if [ -f ~/.shell/env ]; then
. ~/.shell/env
fi


# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
Expand Down Expand Up @@ -106,26 +105,8 @@ if [[ "$_OS_NAME" == "Darwin" ]]; then
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"

[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

[[ -r '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc' ]] && . '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc'

# The next line enables shell command completion for gcloud.
[[ -r '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc' ]] && . '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc'

# The next line updates PATH for Yandex Cloud CLI.
[ -f "$HOME/yandex-cloud/path.bash.inc" ] && . "$HOME/yandex-cloud/path.bash.inc"

# The next line enables shell command completion for yc.
[ -f "$HOME/yandex-cloud/completion.bash.inc" ] && . "$HOME/yandex-cloud/completion.bash.inc"
fi

# Base16 Shell
BASE16_SHELL="$HOME/.config/base16-shell/"
[ -n "$PS1" ] &&
[ -s "$BASE16_SHELL/profile_helper.sh" ] &&
eval "$("$BASE16_SHELL/profile_helper.sh")"


#### PATH without duplicates
_dedup_path
#################################
Loading

0 comments on commit d7dbc7a

Please sign in to comment.