From 8261335e9227b1d300fb2b1fdd4909261880b7b4 Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Sun, 24 Sep 2023 17:59:05 +0200 Subject: [PATCH 1/3] Fix pyenv initialization --- rc.local/pyenv.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rc.local/pyenv.sh b/rc.local/pyenv.sh index 92daa16..da74e7c 100644 --- a/rc.local/pyenv.sh +++ b/rc.local/pyenv.sh @@ -1,8 +1,12 @@ -# Initializae pyenv +# Initialize pyenv if (( ! $LWS_FAST )); then - if can_run pyenv; then - export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv} + PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}" + if [[ -d "$PYENV_ROOT" ]]; then + export PYENV_ROOT + if ! can_run pyenv; then + append_path "$PYENV_ROOT/bin" + fi eval "$(pyenv init -)" fi fi From f31c44630eb3cd911421b53d32a32f74bdef3276 Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Sun, 24 Sep 2023 19:21:39 +0200 Subject: [PATCH 2/3] Cleaning for github publishing --- .editorconfig | 3 +++ README.md | 13 ++++++------- functions.sh | 10 +++++++++- rc.local/pyenv.sh | 2 +- rc/direnv.sh | 2 +- rc/thefuck.sh | 6 ++---- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6084332..6ea1d21 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,9 @@ end_of_line=lf indent_size = 4 indent_style = space +[*.sh] +indent_size = 2 + [*.md] trim_trailing_whitespace = false indent_size = 2 diff --git a/README.md b/README.md index eb1a404..144d157 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Repository of config files, scripts and other staff to enable quick and easy configuring a new computer. ## Quick start + Add to $HOME/.bashrc file: `source /bashrc` @@ -15,13 +16,11 @@ For debug log enabled `LWS_DEBUG=1` ## Quick commands -``` + +```bash # reload full configuration reload-workspace -# home directory of project -$LWS -``` -### TODO -- vim configuration -- debian packages installation +# home directory of project +echo $LWS +``` diff --git a/functions.sh b/functions.sh index 3cd65ef..fd2844b 100644 --- a/functions.sh +++ b/functions.sh @@ -1,9 +1,17 @@ # Linux Workspace Functions if [ -z "$time_ms" ]; then - readonly time_ms='date +%s%3N' + readonly time_ms='date +%s%3N' fi +function is_fast_init() { + (( $LWS_FAST )) +} + +function is_slow_init() { + ! is_fast_init +} + function xlog() { if true_false "$LWS_DEBUG"; then echo "$@" diff --git a/rc.local/pyenv.sh b/rc.local/pyenv.sh index da74e7c..db137f7 100644 --- a/rc.local/pyenv.sh +++ b/rc.local/pyenv.sh @@ -1,6 +1,6 @@ # Initialize pyenv -if (( ! $LWS_FAST )); then +if is_slow_init; then PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}" if [[ -d "$PYENV_ROOT" ]]; then export PYENV_ROOT diff --git a/rc/direnv.sh b/rc/direnv.sh index b8538f1..aa91c00 100644 --- a/rc/direnv.sh +++ b/rc/direnv.sh @@ -1,5 +1,5 @@ # Loading direnv bash hook -if command -v direnv > /dev/null; then +if can_run direnv; then eval "$(direnv hook bash)" fi diff --git a/rc/thefuck.sh b/rc/thefuck.sh index a10c663..aa16166 100644 --- a/rc/thefuck.sh +++ b/rc/thefuck.sh @@ -1,5 +1,3 @@ -if [[ -z "$LWS_FAST" ]]; then - if can_run thefuck; then - eval "$(thefuck --alias)" - fi +if is_slow_init && can_run thefuck; then + eval "$(thefuck --alias)" fi From cd27b2464a577b35e6191efb2874dbddf968b7a0 Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Wed, 27 Sep 2023 18:44:58 +0200 Subject: [PATCH 3/3] Improve uniq_path function --- functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.sh b/functions.sh index fd2844b..14e4071 100644 --- a/functions.sh +++ b/functions.sh @@ -78,7 +78,7 @@ function remove_path() { } function uniq_path() { - echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g' + path | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g' } function set_uniq_path() {