update, wsl serial console init, basic vimrc

This commit is contained in:
2023-09-25 17:33:56 +02:00
parent 0cbdaf9b1e
commit c69f75d08a
5 changed files with 113 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ alias tmr='tmux attach'
alias ll='ls -lah --color=auto'
alias reload='source ~/.termrc'
alias ssj="ssh -J pi@bst1.chenco.dev"
alias ssj="ssh -J herrcrazi@lan1.chenco.dev"
#alias mc-install-plugin='echo "Installing $2"; echo "Done !"'
alias cls='lxc ls -c ns4DSP'
@@ -38,6 +38,6 @@ alias zfs='sudo zfs'
alias zls='sudo zfs list'
sm() {
tmux new-window -n serial:$(basename ${@:-1}) sudo picocom --baud 921600 --parity n --databits 8 --stopbits 1 --flow n --escape z $@
tmux new-window -n serial:$(basename ${@:-1}) sudo picocom --logfile $SERIAL_LOGS/serial-$(basename ${@:-1})-$(ls $SERIAL_LOGS/serial-*.log 2> /dev/null | wc -l).log --baud 921600 --parity n --databits 8 --stopbits 1 --flow n --escape z $@
}

56
.termrc
View File

@@ -7,6 +7,12 @@ if [ -e $HOME/.tmux/.tmux-aliases ] ; then
source $HOME/.tmux/.tmux-aliases
fi
if [ -n "$WSLENV" ] ; then
HRNX_TMUX_SESSIONNAME="wsl"
else
HRNX_TMUX_SESSIONNAME="main"
fi
# Fix linker errors with gtk3 -- removed since I nuked gtk-nocsd
#export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0
@@ -15,6 +21,11 @@ echo -e '\e[34m [termrc] Config reloaded\e[0m'
# Add Rust crates to path
#export PATH=$PATH:$HOME/.cargo/bin
# Add node global modules to PATH
if nodepath=$(npm root -g); then
export PATH=$PATH:$nodepath
fi
# Usual env vars
export EDITOR=/usr/bin/vim
export LANG="en_US.UTF-8"
@@ -37,15 +48,48 @@ if [ -n "$WSLENV" ] ; then
# Connect serial console port if found
if [ -z "$_SERIAL_INIT" ] ; then
source "$HOME/.usbipd"
# Connect serial console ports
echo "Connecting serial port... (device $USB_SERIAL_HWID)"
usbipd.exe wsl attach --hardware-id $USB_SERIAL_HWID
if [ $? -eq 0 ]; then
echo "Serial port connected"
usbipd.exe wsl list
export _SERIAL_INIT=1
bus_ids=$( usbipd.exe wsl list 2> /dev/null | grep "0403:6001" )
if [ -n "$bus_ids" ] ; then
echo $bus_ids
IFS=$' \t\n'
bus_ids=$( tr -s ' ' <<< $bus_ids | cut -d ' ' -f1 | tr '\n' ' ' )
for bus_id in $=bus_ids ; do
usbipd.exe wsl attach --busid $bus_id 2> /dev/null
if [ $? -eq 0 ]; then
echo "Serial port $bus_id connected"
export _SERIAL_INIT=$(($_SERIAL_INIT+1))
else
echo "Unable to connect serial port (device $USB_SERIAL_HWID, bus $bus_id)"
fi
done
usbipd.exe wsl list 2> /dev/null
else
echo "Unable to connect serial port (device $USB_SERIAL_HWID)"
echo "No serial port found matching device type $USB_SERIAL_HWID"
fi
# Configure serial logs
if [ ! -d $SERIAL_LOGS ] ; then
if mkdir -p $SERIAL_LOGS; then echo "Serial logpath created at $SERIAL_LOGS"
else echo "Unable to create $SERIAL_LOGS"; fi
else
echo "Serial logs will be written to $SERIAL_LOGS"
fi
fi
fi
# Automatically creates and attach a 'main' tmux session. If already created,
# attach in a new window instead. If running from tmux, does nothing.
if [ -z "$TMUX" ] ; then
#if [ tmux ls -F "#S" | grep $HRNX_TMUX_SESSIONNAME ] ; then
tmux new-session -A -s $HRNX_TMUX_SESSIONNAME
fi

55
.vimrc Normal file
View File

@@ -0,0 +1,55 @@
set history=500
" Filetype plugins
filetype plugin on
filetype indent on
" Auto read externally modified files
set autoread
au FocusGained,BufEnter * silent! checktime
" :W sudo saves the file
" (useful for handling the permission-denied error)
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
" Regexes, search
set magic
set incsearch
set showmatch
set smartcase
set ignorecase
set hlsearch
" Line numbers
set number
" Ruler
set ruler
" Colors
syntax enable
set t_Co=256
" Default filetypes
set ffs=unix,dos,mac
" Tabs and indentation
""""""""""""""""""""""
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines

4
.zshrc
View File

@@ -65,3 +65,7 @@ SAVEHIST=100000
setopt autocd beep notify
bindkey -e
# End of lines configured by zsh-newuser-install
# Disable zsh globbing error messages, leave it to the called program
setopt +o nomatch

View File

@@ -22,6 +22,7 @@ bind Enter copy-mode
bind Escape copy-mode
# Copy mode
set -g mode-keys vi # set vim keys
bind C-v paste-buffer
bind -T copy-mode-vi Enter send -X copy-selection-no-clear \; send -X copy-pipe-and-cancel "xclip -i -sel c" \; display " [tmux] copied!"
bind -T copy-mode-vi C-c send -X copy-selection-no-clear \; send -X copy-pipe-and-cancel "xclip -i -sel c" \; display " [tmux] copied!"
@@ -36,7 +37,7 @@ bind -T copy-mode-vi Escape send -X cancel
# Window actions
# bind y rename-window
bind r source-file ~/.tmux.conf; display " [tmux] ♦ Configuration reloaded from .tmux.conf"
bind r source-file ~/.tmux.conf #; display " [tmux] ♦ Configuration reloaded from .tmux.conf"
# Colors
set -g display-panes-active-colour colour71