Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd27b2464a | |||
| f31c44630e | |||
| 8261335e92 | |||
|
|
7cd2ac70cb | ||
|
|
4382f72b7c | ||
|
|
fbe35a8fa9 | ||
|
|
dbe870ab5f | ||
|
|
5c689e4c16 | ||
|
|
01f1f95c00 | ||
|
|
85eb30eb96 | ||
|
|
e3920af719 | ||
|
|
d165040dd0 | ||
|
|
2df9c7a2e9 | ||
|
|
a76638856a | ||
|
|
db8960ea6a | ||
|
|
7133130eb5 | ||
|
|
77ec65376b |
@@ -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
|
||||
|
||||
13
README.md
13
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 <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
9
bashrc
@@ -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
|
||||
|
||||
|
||||
2
bin/dcm
2
bin/dcm
@@ -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)
|
||||
|
||||
@@ -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)$ ]]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
4
scripts/detect-x.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $XDG_SESSION_TYPE
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
10
scripts/rust-install.sh
Executable 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
11
scripts/sudo-user.sh
Executable 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
|
||||
Reference in New Issue
Block a user