17 Commits
work ... wood

Author SHA1 Message Date
cd27b2464a Improve uniq_path function 2023-09-27 19:04:57 +02:00
f31c44630e Cleaning for github publishing 2023-09-27 19:04:54 +02:00
8261335e92 Fix pyenv initialization 2023-09-27 19:02:12 +02:00
lachtan
7cd2ac70cb Fix multiple time_ms definition 2023-02-28 09:42:31 +01:00
Martin Blazik
4382f72b7c Rust installation script 2023-02-25 19:21:36 +01:00
Martin Blazik
fbe35a8fa9 Enable call sudo without password 2023-02-25 19:17:27 +01:00
Martin Blazik
dbe870ab5f Initialize LWS_* variables 2023-02-25 14:05:42 +01:00
lachtan
5c689e4c16 Remove doubled code 2023-02-25 14:05:42 +01:00
lachtan
01f1f95c00 Better loading of git-prompt 2023-02-25 14:05:42 +01:00
lachtan
85eb30eb96 Measure loading time of scripts 2023-02-25 14:05:42 +01:00
lachtan
e3920af719 Improve speed of loading scripts 2023-02-25 14:05:40 +01:00
lachtan
d165040dd0 Add bashrc to .editorconfig 2023-02-25 14:02:50 +01:00
Martin Blazik
2df9c7a2e9 Detect X11 or Wayland 2023-02-25 14:02:50 +01:00
Martin Blazik
a76638856a Enable set dc from environment 2023-02-25 14:02:50 +01:00
Martin Blazik
db8960ea6a Improve git-prompt installation script 2023-02-09 17:22:42 +01:00
lachtan obecny
7133130eb5 Fix thefuck init script 2023-02-09 16:22:47 +01:00
lachtan
77ec65376b Git config rewrite ald values 2022-12-10 11:39:20 +01:00
15 changed files with 87 additions and 34 deletions

View File

@@ -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
@@ -29,7 +32,7 @@ indent_size = 2
# Shell
# https://google.github.io/styleguide/shell.xml#Indentation
[*.{bash,sh,zsh}]
[*.{bash,sh,zsh},bashrc]
indent_size = 2
# HTML

View File

@@ -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 <full_path_to_repository>/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
```

9
bashrc
View File

@@ -4,17 +4,18 @@ WORKSPACE_BASHRC=$(realpath $BASH_SOURCE)
export WORKSPACE=$(dirname $WORKSPACE_BASHRC)
export LWS=$WORKSPACE
LWS_DEBUG=${LWS_DEBUG:-0}
LWS_FAST=${LWS_FAST:-0}
echo "Linux Workspace initialization"
if [[ -z $LC_ALL ]]; then
export LC_ALL=en_US.UTF-8
fi
for rc_file in $WORKSPACE/rc/*.sh; do
source $rc_file
done
source "$LWS/functions.sh"
source_directory_sh "$LWS/rc"
append_path "$LWS/bin"
append_path "$LWS/opt/bin"
set_uniq_path

View File

@@ -213,7 +213,7 @@ def try_load_list(name, default):
return default
DOCKER_COMPOSE = "docker-compose"
DOCKER_COMPOSE = os.environ.get("DC", "docker compose")
DEFAULT_DCF = ["docker-compose.yaml"]
DC_FILES = try_load_list("DCF", DEFAULT_DCF)

View File

@@ -1,5 +1,17 @@
# Linux Workspace Functions
if [ -z "$time_ms" ]; then
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 "$@"
@@ -66,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() {
@@ -84,10 +96,17 @@ function can_run() {
function source_directory() {
local mask="$1"
xlog "LOAD DIR $mask"
for file in $mask; do
if [[ -e "$file" ]]; then
xlog "LOAD $file"
source "$file"
if (( $LWS_DEBUG )); then
start=$($time_ms)
source "$file"
stop=$($time_ms)
echo "LOAD FILE $file $((stop - start)) ms"
else
source "$file"
fi
fi
done
}
@@ -115,4 +134,3 @@ function true_false() {
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
}

View File

@@ -1,6 +1,12 @@
# Initializae pyenv
# Initialize pyenv
if can_run pyenv; then
export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
eval "$(pyenv init -)"
if is_slow_init; then
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

View File

@@ -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

View File

@@ -1,9 +1,6 @@
export PAGER=less
export EDITOR=vim
# https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
if can_run bat && ! is_alias bat; then
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
fi
@@ -11,4 +8,3 @@ fi
if ! can_run bat && can_run batcat; then
alias bat=batcat
fi

View File

@@ -1,7 +1,13 @@
export GIT_PROMPT_PATH="$LWS/opt/bash-git-prompt"
if [ -d "$HOME/.bash-git-prompt" ]; then
GIT_PROMPT_PATH="$HOME/.bash-git-prompt"
else
GIT_PROMPT_PATH="$LWS/opt/bash-git-prompt"
fi
GIT_PROMPT_INIT="$GIT_PROMPT_PATH/gitprompt.sh"
if [ -f "$GIT_PROMPT_INIT" ]; then
export GIT_PROMPT_PATH
GIT_PROMPT_ONLY_IN_REPO=1
source "$GIT_PROMPT_INIT"
fi

View File

@@ -1,6 +1,3 @@
if [[ -z "$LWS_FAST" ]]; then
if type thefuck > /dev/null; then
eval "$(thefuck --alias)"
fi
if is_slow_init && can_run thefuck; then
eval "$(thefuck --alias)"
fi

4
scripts/detect-x.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
echo $XDG_SESSION_TYPE

View File

@@ -40,7 +40,7 @@ function git_unalias() {
function git_set() {
local name="$1"
local value="$2"
run git config --global "$name" "$value"
run git config --global --replace-all "$name" "$value"
}
function git_unset() {

View File

@@ -1,7 +1,9 @@
#!/bin/bash
set -E -o errexit -o nounset -o pipefail
set -x
set -u
GIT_PROMPT_PATH=${GIT_PROMPT_PATH:-$LWS/opt/bash-git-prompt}
readonly REPO="https://github.com/magicmonty/bash-git-prompt.git"

10
scripts/rust-install.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
# https://www.rust-lang.org/tools/install
set -E -o errexit -o nounset -o pipefail
sudo apt install curl -y
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustup update

11
scripts/sudo-user.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -E -o errexit -o nounset -o pipefail
USER_FILE="/etc/sudoers.d/$USER"
if [ -f $USER_FILE ]; then
echo "Sudo file $USER_FILE already exists!"
exit 1
fi
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee $USER_FILE