Skip to content

Commit

Permalink
Add random function and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stefaniuk committed May 24, 2023
1 parent 5406f22 commit 9c2be79
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ indent_style = tab
# ==============================================================================

[dot_gitconfig.tmpl]
indent_size = 1
indent_size = 4
indent_style = tab

[dot_gitignore.tmpl]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ githooks-install: # Install git hooks configured in this repository
update-lib-detect-os: # Update the Detect Operating System libarary from source
curl -fsLS \
https://raw.githubusercontent.com/make-ops-tools/detect-operating-system/main/scripts/detect-operating-system.sh \
> ./dot_local/bin/executable_detect-operating-system.sh
chmod +x ./dot_local/bin/executable_detect-operating-system.sh
> ./dot_local/bin/detect-operating-system.sh
chmod +x ./dot_local/bin/detect-operating-system.sh

clean: # Clean development environment
rm -rf \
Expand Down
1 change: 1 addition & 0 deletions assets/02-install-base-packages.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function install {
git \
git-crypt \
git-secrets \
gnu-getopt \
gnu-sed \
gnu-tar \
gnu-which \
Expand Down
13 changes: 13 additions & 0 deletions dot_functions
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ function git-track() {
# ==============================================================================
# Miscellaneous functions

# Generate a random string ('A-Za-z0-9') with the given length
#
# Usage:
# $ ./random 32
#
function random() {

chars='A-Za-z0-9'
length=${1:-32}

cat /dev/urandom | env LC_ALL=C tr -dc $chars | fold -w $length | head -n 1
}

# Convert a decimal number to a byte unit
#
# Usage:
Expand Down
5 changes: 3 additions & 2 deletions dot_gitconfig.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
filemode = true
hidedotfiles = false
ignorecase = false
pager = "diff-so-fancy | less --tabs=4 -RFX" # See https://github.com/so-fancy/diff-so-fancy
pager = "diff-so-fancy | less --tabs=4 -RFX" # See https://github.com/so-fancy/diff-so-fancy
trustctime = false # See http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/

[credential]

Expand Down Expand Up @@ -76,7 +77,7 @@

[rebase]

autoStash = true # Create a temporary stash entry before the operation begins, and apply it after the operation ends
autoStash = true # Create a temporary stash entry before the operation begins, and apply it after the operation ends

[remote "origin"]

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dot_path.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- if eq .chezmoi.os "darwin" -}}
path_homebrew="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/gnu-tar/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/openssl/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/curl/bin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/openssl/bin:/opt/homebrew/bin:/usr/local/Homebrew/bin"
path_homebrew="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/gnu-getopt/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/gnu-tar/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/openssl/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/curl/bin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/gnu-getopt/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/openssl/bin:/opt/homebrew/bin:/usr/local/Homebrew/bin"
path_docker="$HOME/.docker/bin"
path_packages="$path_homebrew:$path_docker"
{{- else if eq .chezmoi.os "linux" }}
path_packages=""
{{- end }}
path_default="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

export PATH="$HOME/.local/bin:$path_packages:$path_default"
export PATH="$HOME/bin:$HOME/.local/bin:$path_packages:$path_default"
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set -e

function main() {

[ -z "$SYSTEM_DIST" ] && eval $(source "$HOME/.local/bin/executable_detect-operating-system.sh")
[ -z "$SYSTEM_DIST" ] && eval $(source "$HOME/.local/bin/detect-operating-system.sh")

install-prerequisites
install-dotfiles
Expand Down
2 changes: 2 additions & 0 deletions run_setup.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

chmod +x $HOME/.local/bin/*

eval $(source "$HOME/.local/bin/detect-operating-system.sh")
source "$HOME/.path"

Expand Down

0 comments on commit 9c2be79

Please sign in to comment.