mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-15 06:53:30 +00:00
shell: have, path_(append|prepend|remove)
- have: command -v shorthand - path_append: appends dir to PATH - path_prepend: prepends dir to PATH - path_remove: removes dir from PATH
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
Brewfile.lock.json
|
Brewfile.lock.json
|
||||||
*.log
|
*.log
|
||||||
*-secret
|
*-secret
|
||||||
|
*cache
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
|||||||
10
base/zshrc
10
base/zshrc
@@ -6,6 +6,8 @@ colors
|
|||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
export DOTFILES="$HOME/.dotfiles"
|
export DOTFILES="$HOME/.dotfiles"
|
||||||
|
# shellcheck source=shared.sh
|
||||||
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
|
||||||
# Run x-load-configs in your terminal to reload the files.
|
# Run x-load-configs in your terminal to reload the files.
|
||||||
function x-load-configs()
|
function x-load-configs()
|
||||||
@@ -28,14 +30,14 @@ ANTIGEN_ZSH_PATH="$XDG_BIN_HOME/antigen.zsh"
|
|||||||
[[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH"
|
[[ -f "$ANTIGEN_ZSH_PATH" ]] && source "$ANTIGEN_ZSH_PATH"
|
||||||
|
|
||||||
# antigen is present
|
# antigen is present
|
||||||
if command -v antigen &> /dev/null; then
|
have antigen && {
|
||||||
antigen use oh-my-zsh
|
antigen use oh-my-zsh
|
||||||
|
|
||||||
# config/functions
|
# config/functions
|
||||||
x-default-antigen-bundles
|
x-default-antigen-bundles
|
||||||
|
|
||||||
antigen apply
|
antigen apply
|
||||||
fi
|
}
|
||||||
|
|
||||||
eval "$(starship init zsh)"
|
|
||||||
|
|
||||||
|
# starship is present
|
||||||
|
have starship && eval "$(starship init zsh)"
|
||||||
|
|||||||
10
config/alias
10
config/alias
@@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck source="../scripts/shared.sh"
|
||||||
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
|
||||||
# Get installed php versions from brew and setup aliases
|
# Get installed php versions from brew and setup aliases
|
||||||
function x-set-php-aliases
|
function x-set-php-aliases
|
||||||
{
|
{
|
||||||
if command -v brew &> /dev/null; then
|
have brew && {
|
||||||
local php_versions=()
|
local php_versions=()
|
||||||
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php')
|
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php')
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ function x-set-php-aliases
|
|||||||
# shellcheck disable=SC2139,SC2140
|
# shellcheck disable=SC2139,SC2140
|
||||||
alias "${php_alias}c"="$php_exec $php_error_reporting $(which composer)"
|
alias "${php_alias}c"="$php_exec $php_error_reporting $(which composer)"
|
||||||
done
|
done
|
||||||
fi
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $(uname) == 'Darwin' ]]; then
|
if [[ $(uname) == 'Darwin' ]]; then
|
||||||
@@ -74,10 +76,8 @@ alias code_scanner='docker run
|
|||||||
|
|
||||||
alias zedit='$EDITOR ~/.dotfiles'
|
alias zedit='$EDITOR ~/.dotfiles'
|
||||||
|
|
||||||
if hash irssi 2> /dev/null; then
|
have irssi && \
|
||||||
# shellcheck disable=2139
|
|
||||||
alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
|
alias irssi="irssi --config='$IRSSI_CONFIG_FILE' --home='$IRSSI_CONFIG_HOME'"
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f "$HOME/.aliases.local" ]]; then
|
if [[ -f "$HOME/.aliases.local" ]]; then
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
# vim: filetype=zsh
|
# vim: filetype=zsh
|
||||||
|
|
||||||
export DOTFILES="$HOME/.dotfiles"
|
export DOTFILES="$HOME/.dotfiles"
|
||||||
export PATH="$DOTFILES/local/bin:$PATH"
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
path_append "$DOTFILES/local/bin"
|
||||||
|
|
||||||
# Explicitly set XDG folders
|
# Explicitly set XDG folders
|
||||||
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
@@ -23,21 +24,20 @@ export HOMEBREW_SBIN="$HOMEBREW/sbin"
|
|||||||
export HOMEBREW_PKG="$HOMEBREW/opt"
|
export HOMEBREW_PKG="$HOMEBREW/opt"
|
||||||
export HOMEBREW_NO_ENV_HINTS=1
|
export HOMEBREW_NO_ENV_HINTS=1
|
||||||
|
|
||||||
export PATH="$XDG_BIN_HOME:$HOMEBREW_BIN:$HOMEBREW_SBIN:/usr/local/sbin:$PATH"
|
path_append "/usr/local/bin"
|
||||||
|
path_append "$HOMEBREW_SBIN"
|
||||||
|
path_append "$HOMEBREW_BIN"
|
||||||
|
path_append "$XDG_BIN_HOME"
|
||||||
|
|
||||||
# brew, https://brew.sh
|
# brew, https://brew.sh
|
||||||
if command -v brew &> /dev/null; then
|
have brew && {
|
||||||
BREW_PYTHON=$(brew --prefix python)/bin
|
path_append "$(brew --prefix python)/bin"
|
||||||
GNUBIN_DIR=$(brew --prefix coreutils)/libexec/gnubin
|
path_append "$(brew --prefix coreutils)/libexec/gnubin"
|
||||||
BREW_RUBY=$(brew --prefix ruby)/bin
|
path_append "$(brew --prefix ruby)/bin"
|
||||||
BREW_GEMS=$(gem environment gemdir)/bin
|
path_append "$(gem environment gemdir)/bin"
|
||||||
|
}
|
||||||
export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
source "$DOTFILES/config/exports-shell"
|
source "$DOTFILES/config/exports-shell"
|
||||||
source "$DOTFILES/config/exports-apps"
|
source "$DOTFILES/config/exports-apps"
|
||||||
|
|
||||||
if command -v nvim &> /dev/null; then
|
have nvim && export EDITOR="nvim"
|
||||||
export EDITOR="nvim"
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck enable=external-sources
|
# shellcheck enable=external-sources
|
||||||
# vim: filetype=zsh
|
# vim: filetype=zsh
|
||||||
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
|
||||||
# Antigen configuration
|
# Antigen configuration
|
||||||
# https://github.com/zsh-users/antigen/wiki/Configuration
|
# https://github.com/zsh-users/antigen/wiki/Configuration
|
||||||
@@ -11,61 +12,62 @@ export ANTIGEN_PLUGIN_RECEIPT_F=".local/share/antigen/antigen_plugin_lastupdate"
|
|||||||
|
|
||||||
# Ansible configuration
|
# Ansible configuration
|
||||||
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
|
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
|
||||||
if hash ansible 2> /dev/null; then
|
have ansible && {
|
||||||
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
|
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
|
||||||
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
|
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
|
||||||
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
|
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
|
||||||
x-dc "$ANSIBLE_HOME"
|
x-dc "$ANSIBLE_HOME"
|
||||||
x-dc "$ANSIBLE_GALAXY_CACHE_DIR"
|
x-dc "$ANSIBLE_GALAXY_CACHE_DIR"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# composer, https://getcomposer.org/
|
# composer, https://getcomposer.org/
|
||||||
if command -v composer &> /dev/null; then
|
have composer && {
|
||||||
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
|
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
|
||||||
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
|
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
|
||||||
export PATH="$COMPOSER_BIN:$PATH"
|
export PATH="$COMPOSER_BIN:$PATH"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# docker, https://docs.docker.com/engine/reference/commandline/cli/
|
# docker, https://docs.docker.com/engine/reference/commandline/cli/
|
||||||
if command -v docker &> /dev/null; then
|
have docker && {
|
||||||
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
|
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
|
||||||
x-dc "$DOCKER_CONFIG"
|
x-dc "$DOCKER_CONFIG"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# ffmpeg
|
# ffmpeg
|
||||||
if hash ffmpeg 2> /dev/null; then
|
have ffmpeg && {
|
||||||
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
|
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
|
||||||
x-dc "$FFMPEG_DATADIR"
|
x-dc "$FFMPEG_DATADIR"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# gcloud
|
# gcloud
|
||||||
if hash gcloud 2> /dev/null; then
|
have gcloud && {
|
||||||
GCLOUD_LOC=$(gcloud info --format="value(installation.sdk_root)" --quiet)
|
GCLOUD_LOC=$(gcloud info --format="value(installation.sdk_root)" --quiet)
|
||||||
[[ -f "$GCLOUD_LOC/path.zsh.inc" ]] && builtin source "$GCLOUD_LOC/path.zsh.inc"
|
[[ -f "$GCLOUD_LOC/path.zsh.inc" ]] && builtin source "$GCLOUD_LOC/path.zsh.inc"
|
||||||
[[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc"
|
[[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# gem, rubygems
|
# gem, rubygems
|
||||||
if command -v gem &> /dev/null; then
|
have gem && {
|
||||||
export GEM_HOME="$XDG_STATE_HOME/gem"
|
export GEM_HOME="$XDG_STATE_HOME/gem"
|
||||||
export GEM_PATH="$XDG_STATE_HOME/gem"
|
export GEM_PATH="$XDG_STATE_HOME/gem"
|
||||||
export PATH="$GEM_HOME/bin:$PATH"
|
export PATH="$GEM_HOME/bin:$PATH"
|
||||||
fi
|
path_append "$GEM_PATH/bin"
|
||||||
|
}
|
||||||
|
|
||||||
# If we have go packages, include them to the PATH
|
# If we have go packages, include them to the PATH
|
||||||
if command -v go &> /dev/null; then
|
have go && {
|
||||||
export GOPATH="$XDG_DATA_HOME/go"
|
export GOPATH="$XDG_DATA_HOME/go"
|
||||||
export GOBIN="$XDG_BIN_HOME"
|
export GOBIN="$XDG_BIN_HOME"
|
||||||
x-dc "$GOPATH"
|
x-dc "$GOPATH"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# irssi
|
# irssi
|
||||||
if hash irssi 2> /dev/null; then
|
have irssi && {
|
||||||
# These variables are used in ./alias with --config and --home
|
# These variables are used in ./alias with --config and --home
|
||||||
export IRSSI_CONFIG_HOME="$XDG_CONFIG_HOME/irssi"
|
export IRSSI_CONFIG_HOME="$XDG_CONFIG_HOME/irssi"
|
||||||
export IRSSI_CONFIG_FILE="$IRSSI_CONFIG_HOME/config"
|
export IRSSI_CONFIG_FILE="$IRSSI_CONFIG_HOME/config"
|
||||||
x-dc "$IRSSI_CONFIG_HOME"
|
x-dc "$IRSSI_CONFIG_HOME"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# nvm, the node version manager
|
# nvm, the node version manager
|
||||||
export NVM_LAZY_LOAD=true
|
export NVM_LAZY_LOAD=true
|
||||||
@@ -76,21 +78,21 @@ export NVM_DIR="$XDG_CONFIG_HOME/nvm"
|
|||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||||
|
|
||||||
# op (1Password cli) is present
|
# op (1Password cli) is present
|
||||||
if hash op 2> /dev/null; then
|
have op && {
|
||||||
export OP_CACHE="$XDG_STATE_HOME/1password"
|
export OP_CACHE="$XDG_STATE_HOME/1password"
|
||||||
x-dc "$OP_CACHE"
|
x-dc "$OP_CACHE"
|
||||||
eval "$(op completion zsh)"
|
eval "$(op completion zsh)"
|
||||||
compdef _op op
|
compdef _op op
|
||||||
fi
|
}
|
||||||
|
|
||||||
# pyenv, python environments
|
# pyenv, python environments
|
||||||
if command -v pyenv &> /dev/null; then
|
have pyenv && {
|
||||||
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
|
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
|
||||||
x-dc "$PYENV_ROOT"
|
x-dc "$PYENV_ROOT"
|
||||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
path_append "$PYENV_ROOT/bin"
|
||||||
|
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# wakatime, https://github.com/wakatime/wakatime-cli
|
# wakatime, https://github.com/wakatime/wakatime-cli
|
||||||
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
|
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
|
||||||
@@ -104,4 +106,3 @@ export _Z_DATA="$XDG_STATE_HOME/z"
|
|||||||
export ANDROID_HOME="$XDG_DATA_HOME/android"
|
export ANDROID_HOME="$XDG_DATA_HOME/android"
|
||||||
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
||||||
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"
|
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# vim: filetype=zsh
|
# vim: filetype=zsh
|
||||||
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
|
||||||
export LC_ALL=fi_FI.utf8
|
export LC_ALL=fi_FI.utf8
|
||||||
|
|
||||||
@@ -39,10 +40,7 @@ hash shopt 2> /dev/null && shopt -s checkwinsize
|
|||||||
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
|
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
|
||||||
|
|
||||||
# Set dircolors based on the file, if it exists
|
# Set dircolors based on the file, if it exists
|
||||||
if command -v dircolors &> /dev/null; then
|
have dircolors && eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
|
||||||
# shellcheck disable=SC2046
|
|
||||||
eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If we are using zsh, color our dir lists and such
|
# If we are using zsh, color our dir lists and such
|
||||||
if [ "$SHELL" = "$(which zsh)" ]; then
|
if [ "$SHELL" = "$(which zsh)" ]; then
|
||||||
@@ -52,4 +50,3 @@ if [ "$SHELL" = "$(which zsh)" ]; then
|
|||||||
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
|
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
|
||||||
zstyle ':completion:*' list-colors "$LS_COLORS"
|
zstyle ':completion:*' list-colors "$LS_COLORS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#
|
#
|
||||||
# shell functions
|
# shell functions
|
||||||
#
|
#
|
||||||
|
# shellcheck source="../scripts/shared.sh"
|
||||||
|
source "$DOTFILES/scripts/shared.sh"
|
||||||
|
|
||||||
# Weather in Tampere, or other city
|
# Weather in Tampere, or other city
|
||||||
function weather
|
function weather
|
||||||
@@ -66,29 +68,6 @@ function silent
|
|||||||
"$@" >&/dev/null
|
"$@" >&/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove directory from the PATH variable
|
|
||||||
# usage: path_remove ~/.local/bin
|
|
||||||
function path_remove
|
|
||||||
{
|
|
||||||
PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')
|
|
||||||
}
|
|
||||||
|
|
||||||
# Append directory to the PATH
|
|
||||||
# usage: path_append ~/.local/bin
|
|
||||||
function path_append
|
|
||||||
{
|
|
||||||
path_remove "$1"
|
|
||||||
PATH="${PATH:+"$PATH:"}$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Prepend directory to the PATH
|
|
||||||
# usage: path_prepend ~/.local/bin
|
|
||||||
function path_prepend
|
|
||||||
{
|
|
||||||
path_remove "$1"
|
|
||||||
PATH="$1${PATH:+":$PATH"}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Defines default antigen bundles
|
# Defines default antigen bundles
|
||||||
function x-default-antigen-bundles
|
function x-default-antigen-bundles
|
||||||
{
|
{
|
||||||
@@ -104,13 +83,13 @@ function x-default-antigen-bundles
|
|||||||
antigen bundle zsh-users/zsh-syntax-highlighting
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||||
|
|
||||||
# these should be available if there's need
|
# these should be available if there's need
|
||||||
hash git 2> /dev/null && antigen bundle git
|
have git && antigen bundle git
|
||||||
hash brew 2> /dev/null && antigen bundle brew
|
have brew && antigen bundle brew
|
||||||
hash docker 2> /dev/null && antigen bundle docker
|
have docker && antigen bundle docker
|
||||||
hash docker-compose 2> /dev/null && antigen bundle sroze/docker-compose-zsh-plugin
|
have docker-compose && antigen bundle sroze/docker-compose-zsh-plugin
|
||||||
hash jq 2> /dev/null && antigen bundle reegnz/jq-zsh-plugin
|
have jq && antigen bundle reegnz/jq-zsh-plugin
|
||||||
hash nvm 2> /dev/null && antigen bundle nvm
|
have nvm && antigen bundle nvm
|
||||||
hash php 2> /dev/null && antigen bundle php
|
have php && antigen bundle php
|
||||||
hash python 2> /dev/null && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
|
have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
|
||||||
hash rvm 2> /dev/null && antigen bundle unixorn/rvm-plugin
|
have rvm && antigen bundle unixorn/rvm-plugin
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,9 +125,7 @@ function section_brew
|
|||||||
"autoupdate:Setups brew auto-update and runs it immediately"
|
"autoupdate:Setups brew auto-update and runs it immediately"
|
||||||
)
|
)
|
||||||
|
|
||||||
if ! command -v brew &> /dev/null; then
|
have brew && {
|
||||||
menu_section "$USAGE_PREFIX" "brew not available on this system"
|
|
||||||
else
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
install)
|
install)
|
||||||
brew bundle install --file="$BREWFILE" && msg_yay "Done!"
|
brew bundle install --file="$BREWFILE" && msg_yay "Done!"
|
||||||
@@ -151,7 +149,7 @@ function section_brew
|
|||||||
menu_usage "$USAGE_PREFIX" "${MENU[@]}"
|
menu_usage "$USAGE_PREFIX" "${MENU[@]}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
} || menu_section "$USAGE_PREFIX" "brew not available on this system"
|
||||||
}
|
}
|
||||||
|
|
||||||
function section_dotfiles
|
function section_dotfiles
|
||||||
@@ -188,13 +186,13 @@ function section_dotfiles
|
|||||||
ln -s $DOTFILES/config/astronvim ~/.config/astronvim
|
ln -s $DOTFILES/config/astronvim ~/.config/astronvim
|
||||||
ln -s $DOTFILES/config/nvim ~/.config/nvim
|
ln -s $DOTFILES/config/nvim ~/.config/nvim
|
||||||
msg_ok "Linked nvim and astronvim"
|
msg_ok "Linked nvim and astronvim"
|
||||||
hash npm 2> /dev/null && $0 install npm
|
have npm && $0 install npm
|
||||||
msg_ok "Installed packages"
|
msg_ok "Installed packages"
|
||||||
msg_done "nvim reset!"
|
msg_done "nvim reset!"
|
||||||
;;
|
;;
|
||||||
yamlfmt)
|
yamlfmt)
|
||||||
# format yaml files
|
# format yaml files
|
||||||
yamlfmt -conf "$DOTFILES/.yamlfmt"
|
have yamlfmt && yamlfmt -conf "$DOTFILES/.yamlfmt" || msg_err "yamlfmt not found"
|
||||||
;;
|
;;
|
||||||
shfmt)
|
shfmt)
|
||||||
# Format shell scripts according to following rules.
|
# Format shell scripts according to following rules.
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
# Install PHP Package Manager Composer
|
||||||
|
#
|
||||||
|
# shellcheck source="shared.sh"
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
if command -v php &> /dev/null; then
|
have php && {
|
||||||
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
||||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||||
@@ -16,4 +20,4 @@ if command -v php &> /dev/null; then
|
|||||||
rm composer-setup.php
|
rm composer-setup.php
|
||||||
mv composer.phar ~/.local/bin/composer
|
mv composer.phar ~/.local/bin/composer
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
fi
|
} || msg_err "PHP Not Available, cannot install composer"
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
# shellcheck source="shared.sh"
|
# shellcheck source="shared.sh"
|
||||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
if ! command -v gh &> /dev/null; then
|
have gh && {
|
||||||
msg_run "gh (GitHub Client) could not be found, please install it first"
|
|
||||||
else
|
|
||||||
extensions=(
|
extensions=(
|
||||||
# GitHub CLI extension for generating a report on repository dependencies.
|
# GitHub CLI extension for generating a report on repository dependencies.
|
||||||
andyfeller/gh-dependency-report
|
andyfeller/gh-dependency-report
|
||||||
@@ -41,4 +39,4 @@ else
|
|||||||
done
|
done
|
||||||
|
|
||||||
msg_ok "Done"
|
msg_ok "Done"
|
||||||
fi
|
} || msg_err "gh (GitHub Client) could not be found, please install it first"
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
if ! command -v go &> /dev/null; then
|
have go && {
|
||||||
msg "go hasn't been installed yet."
|
|
||||||
else
|
|
||||||
packages=(
|
packages=(
|
||||||
# sysadmin/scripting utilities, distributed as a single binary
|
# sysadmin/scripting utilities, distributed as a single binary
|
||||||
github.com/skx/sysbox@latest
|
github.com/skx/sysbox@latest
|
||||||
@@ -28,5 +26,4 @@ else
|
|||||||
done
|
done
|
||||||
|
|
||||||
msg_ok "Done"
|
msg_ok "Done"
|
||||||
|
} || msg "go hasn't been installed yet."
|
||||||
fi
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
if ! command -v npm &> /dev/null; then
|
have npm && {
|
||||||
msg_err "npm could not be found."
|
|
||||||
else
|
|
||||||
packages=(
|
packages=(
|
||||||
# This is a tool to check if your files consider your .editorconfig rules.
|
# This is a tool to check if your files consider your .editorconfig rules.
|
||||||
"editorconfig-checker"
|
"editorconfig-checker"
|
||||||
@@ -35,4 +33,4 @@ else
|
|||||||
npm install -g --no-fund --no-progress --no-timing "$pkg"
|
npm install -g --no-fund --no-progress --no-timing "$pkg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
fi
|
} || msg_err "npm could not be found."
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Install ntfy
|
||||||
|
#
|
||||||
|
# shellcheck source=shared.sh
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! command -v ntfy &> /dev/null; then
|
have ntfy && {
|
||||||
|
msg "ntfy already installed"
|
||||||
|
} || {
|
||||||
case $(dfm check arch) in
|
case $(dfm check arch) in
|
||||||
Linux)
|
Linux)
|
||||||
NTFY_ARCH="linux_$(arch)"
|
NTFY_ARCH="linux_$(arch)"
|
||||||
@@ -28,6 +34,4 @@ if ! command -v ntfy &> /dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
|
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
|
||||||
else
|
}
|
||||||
echo "ntfy already installed"
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Install z
|
||||||
|
#
|
||||||
|
# shellcheck source=shared.sh
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
Z_GIT_PATH="https://github.com/rupa/z.git"
|
Z_GIT_PATH="https://github.com/rupa/z.git"
|
||||||
Z_BIN_PATH="$XDG_BIN_HOME/z"
|
Z_BIN_PATH="$XDG_BIN_HOME/z"
|
||||||
@@ -6,5 +11,5 @@ Z_BIN_PATH="$XDG_BIN_HOME/z"
|
|||||||
if [ ! -d "$Z_BIN_PATH" ]; then
|
if [ ! -d "$Z_BIN_PATH" ]; then
|
||||||
git clone "$Z_GIT_PATH" "$Z_BIN_PATH"
|
git clone "$Z_GIT_PATH" "$Z_BIN_PATH"
|
||||||
else
|
else
|
||||||
echo "z ($Z_BIN_PATH/) already installed"
|
msg_done "z ($Z_BIN_PATH/) already installed"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -171,3 +171,33 @@ function menu_usage()
|
|||||||
menu_item "$CMD" "$DESC"
|
menu_item "$CMD" "$DESC"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shorthand for checking if the system has the bin in path.
|
||||||
|
# usage: have php && php -v
|
||||||
|
function have
|
||||||
|
{
|
||||||
|
command -v "$1" >&/dev/null;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove directory from the PATH variable
|
||||||
|
# usage: path_remove ~/.local/bin
|
||||||
|
function path_remove
|
||||||
|
{
|
||||||
|
PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')
|
||||||
|
}
|
||||||
|
|
||||||
|
# Append directory to the PATH
|
||||||
|
# usage: path_append ~/.local/bin
|
||||||
|
function path_append
|
||||||
|
{
|
||||||
|
path_remove "$1"
|
||||||
|
PATH="${PATH:+"$PATH:"}$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prepend directory to the PATH
|
||||||
|
# usage: path_prepend ~/.local/bin
|
||||||
|
function path_prepend
|
||||||
|
{
|
||||||
|
path_remove "$1"
|
||||||
|
PATH="$1${PATH:+":$PATH"}"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user