8 Commits

Author SHA1 Message Date
Martin Blazik
7de1042823 Smazani pojmenovane unix pipe kdyz nebezi ssh-agent 2025-10-20 10:57:02 +02:00
Martin Blazik
6982026a88 Fix fish installation 2025-10-11 13:29:34 +02:00
Martin Blazik
d96ef0af90 Basic settings for fish shell 2025-10-09 10:35:20 +02:00
lachtan
3049391a4f Better version ssh-agent for WSL 2025-09-19 05:59:07 +02:00
lachtan
138d76a19f Sample wsl.conf 2025-09-19 05:02:11 +02:00
lachtan
57d0ebda20 Make things simpler 2025-09-18 20:22:02 +02:00
lachtan
726e6098b2 Oprava ssh agenta ve WSL 2025-09-03 20:19:22 +02:00
lachtan obecny
6b963ee277 JS nvm initialization 2025-06-29 15:43:15 +02:00
10 changed files with 116 additions and 23 deletions

21
conf/wsl.conf Normal file
View File

@@ -0,0 +1,21 @@
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config
[boot]
systemd=false
[user]
default=lachtan
[automount]
enabled = true
[network]
generateHosts = true
generateResolvConf = false
[interop]
enabled = false
appendWindowsPath = false
[gpu]
enabled = true

11
fishrc Normal file
View File

@@ -0,0 +1,11 @@
# ~/.config/fish/config.fish
# echo "source $LWS/fishrc" > $__fish_config_dir/conf.d/lws.fish
# $__fish_config_dir/conf.d (by default, ~/.config/fish/conf.d/)
# $__fish_sysconf_dir/conf.d (by default, /etc/fish/conf.d/)
set -gx PAGER less
set -g fish_prompt_pwd_dir_length 0
# set -g fish_autosuggestion_enabled 0
# fish_config theme choose "fish default"

View File

@@ -134,3 +134,7 @@ function true_false() {
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
}
function is_wsl() {
grep -q -i wsl /proc/version
}

View File

@@ -2,11 +2,29 @@
set -E -o errexit -o nounset -o pipefail
if grep -q -e 'source\s+.*/linux-workspace/bashrc\s*$' $HOME/.bashrc; then
echo "Linux Workspace configuration already exists in .bashrc !"
exit 1
else
readonly SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
echo "Adding to $HOME/.bashrc"
echo "source '$SCRIPT_DIR/bashrc'" >> "$HOME/.bashrc"
fi
function install_lws() {
local LWS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
if grep -q -e "source.*$LWS_DIR/bashrc" $HOME/.bashrc; then
echo "SKIP: Linux Workspace configuration already exists in $HOME/.bashrc !"
else
echo "Adding to $HOME/.bashrc"
echo "source '$LWS_DIR/bashrc'" >> "$HOME/.bashrc"
fi
local FISH_CONF_DIR="$HOME/.config/fish"
local FISH_CONF_LWS="$FISH_CONF_DIR/conf.d/lws.fish"
if [[ -d "$FISH_CONF_DIR" ]]; then
if [[ -f "$FISH_CONF_LWS" ]]; then
echo "SKIP: Linux Workspace configuration already exists in $FISH_CONF_LWS !"
else
echo "Adding to $FISH_CONF_LWS"
echo "source $LWS_DIR/fishrc" > "$FISH_CONF_LWS"
fi
else
echo "Fish configuration directory not found, skipping fish setup."
fi
}
install_lws

0
rc/01-init.fish Normal file
View File

View File

@@ -1 +1,2 @@
prepend_path_try "$HOME/.local/bin"
prepend_path_try "$HOME/bin"

View File

@@ -1,3 +1 @@
if [[ -f "$HOME/.cargo/env" ]]; then
source "$HOME/.cargo/env"
fi
source_try "$HOME/.cargo/env"

8
rc/nvm.sh Normal file
View File

@@ -0,0 +1,8 @@
NVM_DIR="$HOME/.nvm"
if [ -d "$NVM_DIR" ]; then
export NVM_DIR
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
else
unset NVM_DIR
fi

View File

@@ -1,9 +1,51 @@
# Start ssh agent for private key
function _log() {
xlog "[ssh-agent] $*"
}
_SSH_AGENT_NO_KEYS=1
_SSH_AGENT_NOT_RUNNING=2
for key in id_ecdsa id_rsa; do
key_filename="$HOME/.ssh/$key"
if [ -f $key_filename ]; then
eval $(keychain --eval --quiet --agents ssh $key)
if [ -f "$key_filename" ]; then
_log "SSH key: $key_filename"
if is_wsl; then
_log "WSL ON"
if [ -z "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK=$HOME/.ssh/ssh-agent.sock
fi
_log "SSH_AUTH_SOCK: $SSH_AUTH_SOCK"
ssh-add -L &> /dev/null
ssh_add_status=$?
if [[ -S "$SSH_AUTH_SOCK" && $ssh_add_status -eq $_SSH_AGENT_NOT_RUNNING ]]; then
_log "SSH agent does not running, delete $SSH_AUTH_SOCK"
rm -f "$SSH_AUTH_SOCK"
fi
if [[ ! -S "$SSH_AUTH_SOCK" || $ssh_add_status -eq $_SSH_AGENT_NOT_RUNNING ]]; then
_log "Starting ssh-agent"
eval "$(ssh-agent -s -a "$SSH_AUTH_SOCK")"
fi
ssh-add -L &> /dev/null
ssh_add_status=$?
if [[ $ssh_add_status -eq $_SSH_AGENT_NO_KEYS ]]; then
_log "Adding SSH key to agent"
ssh-add "$key_filename"
fi
else
eval "$(keychain --eval --quiet --agents ssh $key)"
fi
break
fi
done

View File

@@ -1,10 +0,0 @@
function is_wsl()
{
grep -q -i wsl /proc/version
}
if is_wsl; then
prepend_path_try "$HOME/.local/bin"
append_path_try "$HOME/.arkade/bin"
append_path_try "$HOME/.cargo/bin"
fi