Canges
This commit is contained in:
parent
1f051d6e6b
commit
6a2f012a99
|
@ -2,16 +2,16 @@
|
|||
# ex: set ts=4 sw=4 ft=sh
|
||||
|
||||
# Enable Touchpad While Typing
|
||||
# xinput |
|
||||
# grep Touchpad |
|
||||
# awk '{print $6}' |
|
||||
# sed "s/id=//" - |
|
||||
# {
|
||||
# read iid; xinput list-props $iid |
|
||||
# grep "Typing Enabled (" |
|
||||
# awk '{gsub(/\(|\)|:/,""); print $6}' |
|
||||
# xargs -I pid xinput set-prop "$iid" pid 0;
|
||||
# }
|
||||
xinput |
|
||||
grep Touchpad |
|
||||
awk '{print $6}' |
|
||||
sed "s/id=//" - |
|
||||
{
|
||||
read iid; xinput list-props $iid |
|
||||
grep "Typing Enabled (" |
|
||||
awk '{gsub(/\(|\)|:/,""); print $6}' |
|
||||
xargs -I pid xinput set-prop "$iid" pid 0;
|
||||
}
|
||||
|
||||
setxkbmap -layout us
|
||||
three-mon
|
||||
|
@ -19,6 +19,8 @@ updatebar
|
|||
2>/dev/null 1>&2 nohup picom &
|
||||
2>/dev/null 1>&2 startlxde &
|
||||
|
||||
export XDG_SESSION_TYPE=x11
|
||||
|
||||
while : ; do
|
||||
2>>/home/tosuman/.xinit.log 1>&2 dwm
|
||||
sleep 0.5
|
||||
|
|
262
.bashrc
262
.bashrc
|
@ -29,51 +29,44 @@ hash -r
|
|||
unalias -a
|
||||
unset -v POSIXLY_CORRECT
|
||||
|
||||
#################################### utils #####################################
|
||||
# import_bash_functions () {
|
||||
# __func_str=
|
||||
# __func_name=
|
||||
# while IFS= read -r line ; do
|
||||
# case "${line}" in
|
||||
# BASH_FUNC_*"_PERCENT_PERCENT=() { "*)
|
||||
# __func_str="$(printf %s "${line#BASH_FUNC_}" | sed -e 's/_PERCENT_PERCENT=/ /')"
|
||||
# __func_name="${line#BASH_FUNC_}"
|
||||
# __func_name="${__func_name%%_PERCENT_PERCENT=*}"
|
||||
# ;;
|
||||
# "}BASH_FUNC_END")
|
||||
# eval "${__func_str}
|
||||
# }"
|
||||
# export -f -- "${__func_name}"
|
||||
# __func_str=
|
||||
# __func_name=
|
||||
# ;;
|
||||
# *)
|
||||
# if [ -n "${__func_str}" ] && [ -n "${__func_name}" ] ; then
|
||||
# __func_str="${__func_str}
|
||||
# ${line}"
|
||||
# fi
|
||||
# ;;
|
||||
# esac
|
||||
# done << __ENV
|
||||
# $(env)
|
||||
# __ENV
|
||||
# unset -v __func_str __func_name
|
||||
# }
|
||||
|
||||
# import_bash_functions
|
||||
|
||||
__path_lookup () { type -P "${1-}" ; } && export -f __path_lookup # adapted for bash.
|
||||
__have_all () { while [ "${#}" -gt "0" ] ; do [ -x "$(__path_lookup "${1-}")" ] || return 1 ; shift ; done ; } && export -f __have_all
|
||||
__have () { __have_all "${1-}" ; } && export -f __have
|
||||
__source_if () { [ -f "${1-}" ] && [ -r "${1-}" ] && . "${1-}" ; } && export -f __source_if
|
||||
|
||||
|
||||
####################### per session environment (posix) ########################
|
||||
import_bash_functions () {
|
||||
__func_str=
|
||||
__func_name=
|
||||
while IFS= read -r line ; do
|
||||
case "${line}" in
|
||||
BASH_FUNC_*"_PERCENT_PERCENT=() { "*)
|
||||
__func_str="$(printf %s "${line#BASH_FUNC_}" | sed -e 's/_PERCENT_PERCENT=/ /')"
|
||||
__func_name="${line#BASH_FUNC_}"
|
||||
__func_name="${__func_name%%_PERCENT_PERCENT=*}"
|
||||
;;
|
||||
"}BASH_FUNC_END")
|
||||
eval "${__func_str}
|
||||
}"
|
||||
export -f -- "${__func_name}"
|
||||
__func_str=
|
||||
__func_name=
|
||||
;;
|
||||
*)
|
||||
if [ -n "${__func_str}" ] && [ -n "${__func_name}" ] ; then
|
||||
__func_str="${__func_str}
|
||||
${line}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done << __ENV
|
||||
$(env)
|
||||
__ENV
|
||||
unset -v __func_str __func_name
|
||||
}
|
||||
|
||||
import_bash_functions
|
||||
|
||||
set | grep -sq '^\(TMUX_PANE\|SSH_CONNECTION\)' && exec 2>/dev/null
|
||||
[ -n "${DISPLAY-}" ] || log.warn 'DISPLAY not set'
|
||||
set | grep -sq '^\(TMUX_PANE\|SSH_CONNECTION\)' && exec 2>/dev/tty
|
||||
|
||||
BAT_THEME='gruvbox-dark' || BAT_THEME='gruvbox-light'
|
||||
BAT_THEME='gruvbox-dark' # BAT_THEME='gruvbox-light'
|
||||
GPG_TTY="$(tty)"
|
||||
|
||||
if [ ! "${TERM-}" = "linux" ] ; then
|
||||
|
@ -88,13 +81,12 @@ if [ ! "${TERM-}" = "linux" ] ; then
|
|||
__scope
|
||||
unset -f __scope
|
||||
fi
|
||||
MANPAGER='less -X'
|
||||
|
||||
# ensure exported
|
||||
export USER HOME PWD PATH LD_LIBRARY_PATH TERM LANG DISPLAY EDITOR VISUAL \
|
||||
XDG_RUNTIME_DIR MAIL GOPATH SUDO_EDITOR SSH_AUTH_SOCK MANPAGER \
|
||||
GIT_SSH_COMMAND GIT_CONFIG_GLOBAL GPG_TTY BAT_THEME _JAVA_AWT_WM_NONREPARENTING \
|
||||
USER42 EMAIL42 CDPATH
|
||||
USER42 EMAIL42
|
||||
|
||||
################################# bash options #################################
|
||||
shopt -s autocd
|
||||
|
@ -130,20 +122,23 @@ write_history () {
|
|||
} && trap 'write_history' EXIT
|
||||
|
||||
############################# vim aliases (posix) ##############################
|
||||
if __have nvim ; then
|
||||
alias vi="$(__path_lookup nvim)"
|
||||
elif __have vim ; then
|
||||
alias vi="$(__path_lookup vim)"
|
||||
elif __have nvi ; then
|
||||
alias vi="$(__path_lookup nvi)"
|
||||
elif __have vi ; then
|
||||
alias vi="$(__path_lookup vi)"
|
||||
elif __have nano ; then
|
||||
alias vi="$(__path_lookup nano)"
|
||||
fi
|
||||
alias v='log.err use vi; sleep 5 #'
|
||||
alias vim='log.err use vi; sleep 5 #'
|
||||
alias nvim='log.err use vi; sleep 5 #'
|
||||
# if __have nvim ; then
|
||||
# alias vi="$(__path_lookup nvim)"
|
||||
# elif __have vim ; then
|
||||
# alias vi="$(__path_lookup vim)"
|
||||
# elif __have nvi ; then
|
||||
# alias vi="$(__path_lookup nvi)"
|
||||
# elif __have vi ; then
|
||||
# alias vi="$(__path_lookup vi)"
|
||||
# elif __have nano ; then
|
||||
# alias vi="$(__path_lookup nano)"
|
||||
# fi
|
||||
# alias v='log.err use vi'
|
||||
# alias vim='log.err use vi'
|
||||
# alias nvim='log.err use vi'
|
||||
alias v='nvim'
|
||||
alias vi='nvim'
|
||||
alias vim='nvim'
|
||||
|
||||
######################## default-option aliases (posix) ########################
|
||||
alias gdb='gdb -q'
|
||||
|
@ -162,10 +157,9 @@ alias objdump='objdump --disassembler-color=extended-color -Mintel'
|
|||
alias dmesg='dmesg --color=auto --reltime --human --nopager --decode'
|
||||
alias sudo='sudo ' # trailing space means complete aliases
|
||||
alias watch='watch -tcn.1 ' # trailing space means complete aliases
|
||||
alias rm='rm -Iv'
|
||||
|
||||
########################## overwrite aliases (posix) ###########################
|
||||
alias make='compiledb make -j'
|
||||
alias make='compiledb make -j$(nproc)'
|
||||
alias cat='bat'
|
||||
|
||||
########################## navigation aliases (posix) ##########################
|
||||
|
@ -179,32 +173,20 @@ alias svi='sudo vi'
|
|||
alias open='xdg-open'
|
||||
alias dp='declare -p'
|
||||
alias wttr='curl -sfkSL wttr.in'
|
||||
alias wttrb='curl -sfkSL wttr.in/berlin'
|
||||
alias ipa='ip -br -color=auto a'
|
||||
alias xcopy='xsel --clipboard --input'
|
||||
alias xpaste='xsel --clipboard --output'
|
||||
alias paco='"${HOME-}/francinette/tester.sh"'
|
||||
alias pcker='vi "${HOME-}/.config/nvim/lua/"*'
|
||||
alias pcker='nvim "${HOME-}/.config/nvim/lua/"*'
|
||||
alias francinette='"${HOME-}/francinette/tester.sh"'
|
||||
alias q-dig='docker run --rm -it ghcr.io/natesales/q'
|
||||
alias q='duck'
|
||||
alias after='vi "${HOME-}/.config/nvim/after/plugin"'
|
||||
alias after='nvim "${HOME-}/.config/nvim/after/plugin"'
|
||||
alias dotconf='git --git-dir="${HOME-}/.dotfiles/" --work-tree="${HOME-}"'
|
||||
alias ll='\ls --width="${COLUMNS:-80}" --sort=time --time=mtime --color=auto --fu -bharZ1l'
|
||||
alias l='\ls --width="${COLUMNS:-80}" --sort=time --time=mtime --color=auto --time-style=long-iso -bharZ1l'
|
||||
alias colors='bash -c "$(curl -sfkSL "https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw")"'
|
||||
alias s='echo sudo $(fc -nl -2 | head -1 | cut -c3-) ; eval sudo $(fc -nl -2 | head -1 | cut -c3-)' # cut -c2- for bash posix mode
|
||||
alias mstest="bash /home/tosuman/42_minishell_tester/tester.sh"
|
||||
alias rootshell='sudo python3 -c '\''import pty, os, fcntl, termios, struct;
|
||||
rows, cols = struct.unpack("hh", fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack("hh", 0, 0)));
|
||||
def set_winsize(fd, rows, cols):
|
||||
fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack("HHHH", rows, cols, 0, 0))
|
||||
def read(fd):
|
||||
set_winsize(fd, rows, cols)
|
||||
return os.read(fd, 1024)
|
||||
pty.spawn("/bin/bash", read)'\'''
|
||||
alias night='1>/dev/null redshift -g 1:0.99:0.99 -O 5500'
|
||||
alias day='1>/dev/null redshift -x'
|
||||
|
||||
############################### CDPATHS (posix) ################################
|
||||
CDPATH="."\
|
||||
|
@ -217,26 +199,11 @@ CDPATH="."\
|
|||
":${HOME}/projects/aoc/2023"
|
||||
|
||||
################################## FUNCTIONS ###################################
|
||||
################################ man (wrapper) #################################
|
||||
# Depends on mktemp, nvim, man
|
||||
man () (
|
||||
__have mktemp || { log.err 'mktemp missing' ; exit 1 ; }
|
||||
__have nvim || { log.err 'nvim missing' ; exit 2 ; }
|
||||
__have man || { log.err 'man missing' ; exit 3 ; }
|
||||
|
||||
set -euo pipefail
|
||||
trap '/bin/rm -f -- "${raw_manpage}"' EXIT
|
||||
raw_manpage="$(mktemp)"
|
||||
2>/dev/null MANPAGER=cat command man "$@" > "${raw_manpage}"
|
||||
command nvim +Man! -- "${raw_manpage}"
|
||||
command rm -f -- "${raw_manpage}"
|
||||
)
|
||||
|
||||
################################# vix (posix) ##################################
|
||||
vix () {
|
||||
__have vi || { log.err 'vi missing' ; return 1 ; }
|
||||
|
||||
[ "${#}" -lt "1" ] && { log.info "Usage: vix FILE [[N]VI[M]_ARGS...]" ; return 1 ; }
|
||||
[ "${#}" -lt "1" ] && { log.info "Usage: vix FILE [VIM_ARGS...]" ; return 1 ; }
|
||||
|
||||
file="${1-}"
|
||||
shift
|
||||
|
@ -257,26 +224,25 @@ cd () {
|
|||
pwd="${PWD}"
|
||||
1>/dev/null command cd - || return 1
|
||||
1>/dev/null pushd "${pwd}" || return 1
|
||||
l
|
||||
}
|
||||
|
||||
################################# viw (posix) ##################################
|
||||
############################## vimw (posix) ###############################
|
||||
# Roughly equivalent to vi "$(which "$1")", but also allowing for args after $1
|
||||
viw () {
|
||||
vimw () {
|
||||
__have vi || { log.err 'vi missing' ; return 1 ; }
|
||||
|
||||
[ -z "${1-}" ] && { log.info "Usage: viw FILE [[N]VI[M]_ARGS...]" ; return 2 ; }
|
||||
[ -z "${1-}" ] && { log.info "Usage: vimw FILE [VIM_ARGS...]" ; return 2 ; }
|
||||
|
||||
first="${1-}"
|
||||
shift
|
||||
vi "${@}" "$(type -P "${first}")"
|
||||
}
|
||||
|
||||
################################# yolo (posix) #################################
|
||||
#################################### paruuu (posix) ####################################
|
||||
# Update arch linux system with pacman, paru and ssid whitelist
|
||||
# Clears cache and removes orphans. Arguably dangerous, but YOLO
|
||||
# Clears cache and removes orphans. Arguably dangerous.
|
||||
# Depends on iw, paru, pacman, rankmirrors, sudo, curl
|
||||
yolo () {
|
||||
paruuu () {
|
||||
__have iw || { log.err 'iw missing' ; exit 1 ; }
|
||||
__have paru || { log.err 'paru missing' ; exit 2 ; }
|
||||
__have pacman || { log.err 'pacman missing' ; exit 3 ; }
|
||||
|
@ -525,7 +491,7 @@ _PS1_1="${_PS1_1-}\h\[\033[m\]"
|
|||
_PS1_1="${_PS1_1-}${_PS1_SSH-}${_PS1_TMUX-} "
|
||||
_PS1_1="${_PS1_1-}${_PS1_CWD_CLR-}"
|
||||
_PS1_1="${_PS1_1-}[\w]\${TOOK_STRING-}"
|
||||
_PS1_GIT='\[\033[m\]\[\033[36m\]$(__git_ps1 " (%s)")'
|
||||
_PS1_GIT='\[\033[m\]\[\033[36m\]$(: __git_ps1 " (%s)")'
|
||||
# _PS1_2='\[\033[m\]\[\033[36m\]$(__norm)\[\033[m\]\n\[\033[35m\]~\$\[\033[m\] '
|
||||
_PS1_2='\[\033[m\]\[\033[36m\]\[\033[m\]\n\[\033[35m\]~\$\[\033[m\] '
|
||||
|
||||
|
@ -551,7 +517,7 @@ fi
|
|||
# TODO: put into script
|
||||
export AOC_DIR="${HOME}/projects/aoc" # remember to change this to whatever your AOC directory is
|
||||
alias aos='< in.txt python3 solution.py'
|
||||
alias aot='< test.txt printf '\033[34m' ; python3 solution.py ; printf '\033[m''
|
||||
alias aot='printf "\033[34m" ; < test.txt python3 solution.py ; printf "\033[m"'
|
||||
alias aoc='aot ; echo ; aos'
|
||||
|
||||
################################### aocload ####################################
|
||||
|
@ -606,59 +572,69 @@ aocload () {
|
|||
|
||||
if [ ! -f './solution.py' ] ; then
|
||||
cat <<- TEMPLATE >> './solution.py'
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env pypy3
|
||||
|
||||
print()
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import math
|
||||
import multiprocessing as mp
|
||||
from copy import copy, deepcopy
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
import more_itertools as miter
|
||||
from functools import cache, lru_cache, reduce
|
||||
from collections import deque, defaultdict, Counter
|
||||
from itertools import (
|
||||
repeat, cycle, combinations, combinations_with_replacement,
|
||||
permutations, tee, pairwise, zip_longest, islice, takewhile,
|
||||
filterfalse, starmap
|
||||
)
|
||||
e=enumerate
|
||||
|
||||
data = open(0).read().strip().splitlines()
|
||||
R = len(data)
|
||||
C = len(data[0])
|
||||
def parse_grid(data: list[str]) -> Any:
|
||||
for r in range(R):
|
||||
for c in range(C):
|
||||
pass
|
||||
def parse_lines(data: list[str]) -> Any:
|
||||
for line in data:
|
||||
line = line.split()
|
||||
def parse_line(data: list[str]) -> Any:
|
||||
return data[0].split()
|
||||
# data = parse_line(data)
|
||||
# data = parse_lines(data)
|
||||
data = parse_grid(data)
|
||||
|
||||
t = 0
|
||||
for line in data:
|
||||
n = 0
|
||||
t += n
|
||||
print(t)
|
||||
open(0)
|
||||
TEMPLATE
|
||||
# cat <<- TEMPLATE >> './solution.py'
|
||||
# #!/usr/bin/env pypy3
|
||||
|
||||
# print()
|
||||
|
||||
# import os
|
||||
# import re
|
||||
# import sys
|
||||
# import math
|
||||
# import multiprocessing as mp
|
||||
# from copy import copy, deepcopy
|
||||
# from typing import Any
|
||||
# import numpy as np
|
||||
# import more_itertools as miter
|
||||
# from functools import cache, lru_cache, reduce
|
||||
# from collections import deque, defaultdict, Counter
|
||||
# from itertools import (
|
||||
# repeat, cycle, combinations, combinations_with_replacement,
|
||||
# permutations, tee, pairwise, zip_longest, islice, takewhile,
|
||||
# filterfalse, starmap
|
||||
# )
|
||||
# e=enumerate
|
||||
|
||||
# data = open(0).read().strip().splitlines()
|
||||
# R = len(data)
|
||||
# C = len(data[0])
|
||||
# def parse_grid(data: list[str]) -> Any:
|
||||
# grid = []
|
||||
# for r in range(R):
|
||||
# for c in range(C):
|
||||
# pass
|
||||
# return grid
|
||||
|
||||
# def parse_lines(data: list[str]) -> Any:
|
||||
# new_data = []
|
||||
# for line in data:
|
||||
# new_data.append(line.split())
|
||||
# return new_data
|
||||
|
||||
# def parse_line(data: list[str]) -> Any:
|
||||
# return data[0].split()
|
||||
# # data = parse_line(data)
|
||||
# data = parse_lines(data)
|
||||
# # data = parse_grid(data)
|
||||
|
||||
# t = 0
|
||||
# for line in data:
|
||||
# n = 0
|
||||
# t += n
|
||||
# print(t)
|
||||
# TEMPLATE
|
||||
fi
|
||||
|
||||
chmod +x './solution.py'
|
||||
tmux splitw -v -c "${dir}"
|
||||
tmux send-keys "vi '+normal gg0' './in.txt'" ENTER
|
||||
tmux send-keys "nvim '+normal gg0' './in.txt'" ENTER
|
||||
tmux select-pane -l
|
||||
tmux send-keys "vi './solution.py'" ENTER
|
||||
tmux send-keys "nvim './solution.py'" ENTER
|
||||
}
|
||||
|
||||
############################## terminal settings ###############################
|
||||
tabs -4
|
||||
set -o emacs
|
||||
|
@ -672,7 +648,7 @@ __have xset && 2>/dev/null xset r rate 200 60
|
|||
__have xset && 2>/dev/null xset -b
|
||||
|
||||
################################# completions ##################################
|
||||
complete -F _command viw
|
||||
complete -F _command vimw
|
||||
complete -C backup_dir backup_dir
|
||||
complete -C backup_file backup_file
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
live_config_reload = true
|
||||
|
||||
[bell]
|
||||
animation = "EaseOutExpo"
|
||||
|
@ -402,7 +401,7 @@ multiplier = 3
|
|||
save_to_clipboard = false
|
||||
semantic_escape_chars = ",│`|:\"' ()[]{}<>"
|
||||
|
||||
[shell]
|
||||
[terminal.shell]
|
||||
args = ["-c", "stdout=\"$(tmux ls -F '#{session_name}|#{?session_attached,attached,not attached}' | grep 'not attached$')\"; [ \"$?\" = \"0\" ] && tmux -2 attach -t \"$(printf ${stdout} | tail -1 | cut -d'|' -f1)\" || tmux"]
|
||||
program = "/bin/sh"
|
||||
|
||||
|
@ -419,3 +418,8 @@ lines = 25
|
|||
[window.padding]
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
[general]
|
||||
live_config_reload = true
|
||||
|
||||
[terminal]
|
||||
|
|
|
@ -23,7 +23,7 @@ require('lspconfig').clangd.setup{
|
|||
|
||||
lsp.ensure_installed({
|
||||
'clangd',
|
||||
'tsserver',
|
||||
'ts_ls',
|
||||
'eslint',
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
|
|
|
@ -26,7 +26,7 @@ return require('packer').startup(function(use)
|
|||
use('vim-airline/vim-airline-themes')
|
||||
use('cacharle/c_formatter_42.vim')
|
||||
-- use('m4xshen/autoclose.nvim')
|
||||
-- use('takac/vim-hardtime')
|
||||
use('takac/vim-hardtime')
|
||||
use{
|
||||
'm4xshen/hardtime.nvim',
|
||||
requires = { { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" } }
|
||||
|
|
|
@ -49,8 +49,8 @@ local function save_profiles(threshold)
|
|||
end
|
||||
|
||||
time([[Luarocks path setup]], true)
|
||||
local package_path_str = "/home/tosuman/.cache/nvim/packer_hererocks/2.1.1720049189/share/lua/5.1/?.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1720049189/share/lua/5.1/?/init.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1720049189/lib/luarocks/rocks-5.1/?.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1720049189/lib/luarocks/rocks-5.1/?/init.lua"
|
||||
local install_cpath_pattern = "/home/tosuman/.cache/nvim/packer_hererocks/2.1.1720049189/lib/lua/5.1/?.so"
|
||||
local package_path_str = "/home/tosuman/.cache/nvim/packer_hererocks/2.1.1725453128/share/lua/5.1/?.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1725453128/share/lua/5.1/?/init.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1725453128/lib/luarocks/rocks-5.1/?.lua;/home/tosuman/.cache/nvim/packer_hererocks/2.1.1725453128/lib/luarocks/rocks-5.1/?/init.lua"
|
||||
local install_cpath_pattern = "/home/tosuman/.cache/nvim/packer_hererocks/2.1.1725453128/lib/lua/5.1/?.so"
|
||||
if not string.find(package.path, package_path_str, 1, true) then
|
||||
package.path = package.path .. ';' .. package_path_str
|
||||
end
|
||||
|
@ -198,6 +198,11 @@ _G.packer_plugins = {
|
|||
loaded = true,
|
||||
path = "/home/tosuman/.local/share/nvim/site/pack/packer/start/vim-fugitive",
|
||||
url = "https://github.com/tpope/vim-fugitive"
|
||||
},
|
||||
["vim-hardtime"] = {
|
||||
loaded = true,
|
||||
path = "/home/tosuman/.local/share/nvim/site/pack/packer/start/vim-hardtime",
|
||||
url = "https://github.com/takac/vim-hardtime"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
other_identifier = 'other'
|
||||
|
||||
occf_template = """\
|
||||
class {{class_name}} {
|
||||
public:
|
||||
~{{class_name}}();
|
||||
{{class_name}}();
|
||||
{{class_name}}(const {{class_name}}&);
|
||||
{{class_name}}& operator=(const {{class_name}}&);
|
||||
{{private_member_decls}}};
|
||||
|
||||
{{class_name}}::{{class_name}}() {
|
||||
std::cout << "{{class_name}}: default ctor\\n";
|
||||
}
|
||||
|
||||
{{class_name}}::{{class_name}}(const {{class_name}}& {{instance_other}}) {
|
||||
std::cout << "{{class_name}}: copy ctor\\n";
|
||||
*this = {{instance_other}};
|
||||
}
|
||||
|
||||
{{class_name}}& {{class_name}}::operator=(const {{class_name}}& {{instance_other}}) {
|
||||
std::cout << "{{class_name}}: copy-assignment operator\\n";
|
||||
{{private_member_copy_assigns}}return *this;
|
||||
}
|
||||
"""
|
||||
|
||||
def gen_private_member_decls(decls: list[tuple[str, str, str]]) -> str:
|
||||
result = 'private:\n'
|
||||
for decl in decls:
|
||||
decl_type, identifier, default_value = decl
|
||||
if default_value:
|
||||
result += f'\t{decl_type} {identifier} = {default_value};\n'
|
||||
else:
|
||||
result += f'\t{decl_type} {identifier};\n'
|
||||
if result == 'private:\n':
|
||||
return ''
|
||||
return result
|
||||
|
||||
def gen_private_member_copy_assigns(decls: list[tuple[str, str, str]]) -> str:
|
||||
result = '\tif \x28this = &{{instance_other}}) \x7b\n'
|
||||
for decl in decls:
|
||||
_, identifier, _ = decl
|
||||
result += f'\t\t{identifier} = {other_identifier}.{identifier};\n'
|
||||
if result == '\tif \x28this = &{{instance_other}}) \x7b\n':
|
||||
return '\t'
|
||||
result += '\t}\n\t'
|
||||
return result
|
||||
|
||||
def gen_occf(class_name: str, decls: list[tuple[str, str, str]]) -> str:
|
||||
result = occf_template.replace("{{class_name}}", class_name)
|
||||
result = result.replace("{{instance_other}}", f"{other_identifier}")
|
||||
result = result.replace("{{private_member_decls}}", gen_private_member_decls(decls))
|
||||
result = result.replace("{{private_member_copy_assigns}}", gen_private_member_copy_assigns(decls))
|
||||
return result
|
||||
|
||||
def parse_class_name(s: str) -> str:
|
||||
if (m := re.match(r'[a-zA-Z_][a-zA-Z_0-9]*', s.strip())):
|
||||
return m[0]
|
||||
return ''
|
||||
|
||||
def parse_decl(s: str) -> tuple[str, str, str]:
|
||||
# examples: std::string Bla_123 "hello"
|
||||
# int i
|
||||
# ::mystr __h1iegh
|
||||
m = re.match(r'((?:(?:[a-zA-Z_][a-zA-Z_0-9]*)?::)?[a-zA-Z_][a-zA-Z_0-9]*)(?:\s+)([a-zA-Z_][a-zA-Z_0-9]*)(?:(?:\s+)((?:[0-9]+)|(?:"[^"]*")))?', s)
|
||||
if not m:
|
||||
return '', '', ''
|
||||
return m[1], '_' + m[2], m[3]
|
||||
|
||||
def parse_decls(decls: list[str]) -> list[tuple[str, str, str]]:
|
||||
parsed_decls = []
|
||||
for decl in decls:
|
||||
parsed_decl = parse_decl(decl)
|
||||
if not parsed_decl[0]:
|
||||
return []
|
||||
parsed_decls.append(parsed_decl)
|
||||
if not parsed_decls:
|
||||
return [('','','')]
|
||||
return parsed_decls
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) <= 1:
|
||||
print(f"Usage: {sys.argv[0]} <class_name> [<declarations>...]")
|
||||
sys.exit(1)
|
||||
if not (class_name := parse_class_name(sys.argv[1])):
|
||||
print("Class name invalid")
|
||||
sys.exit(1)
|
||||
if not (decls := parse_decls(sys.argv[2:])):
|
||||
print("One of the private member declarations is invalid")
|
||||
sys.exit(1)
|
||||
if not decls[0][0]:
|
||||
decls.pop()
|
||||
print(gen_occf(class_name, decls))
|
|
@ -68,12 +68,21 @@ getEth () {
|
|||
printf '%s' "${eth}"
|
||||
}
|
||||
|
||||
getGoku() {
|
||||
# return 1
|
||||
goku="$(ip address | grep -q goku: && echo "Goku active")"
|
||||
fontColor="$(getColor '7ef000')"
|
||||
# [ -n "${goku}" ] && goku="${dlm}^c#${fontColor}^嬨 ${goku}^d^"
|
||||
[ -n "${goku}" ] && goku="${dlm}^c#${fontColor}^🛡️ ${goku}^d^"
|
||||
printf '%s' "${goku}"
|
||||
}
|
||||
|
||||
getNord() {
|
||||
# return 1
|
||||
nord="$(nordvpn status | grep Status | sed 's/.*Status: //')"
|
||||
fontColor="$(getColor '8fbcbb')"
|
||||
nord="$(nordvpn status | grep -q "Status: Connected" && echo "NordVPN active")"
|
||||
fontColor="$(getColor '0e80f0')"
|
||||
# [ -n "${nord}" ] && nord="${dlm}^c#${fontColor}^嬨 ${nord}^d^"
|
||||
[ -n "${nord}" ] && nord="${dlm}^c#${fontColor}^🌐 ${nord}^d^"
|
||||
[ -n "${nord}" ] && nord="${dlm}^c#${fontColor}^🛡️ ${nord}^d^"
|
||||
printf '%s' "${nord}"
|
||||
}
|
||||
|
||||
|
@ -107,6 +116,7 @@ getCpuTemp() {
|
|||
}
|
||||
|
||||
getWattage() {
|
||||
return 1
|
||||
wattage="$(awk '{printf "%.0f", $1*10^-6}' /sys/class/power_supply/BAT1/power_now)"
|
||||
fontColor="$(getColor '5e81ac')"
|
||||
[ -n "${wattage}" ] && wattage="${dlm}^c#${fontColor}^⚡ ${wattage}W^d^"
|
||||
|
@ -130,7 +140,7 @@ getNumberOfTmuxSessions() {
|
|||
|
||||
while : ; do
|
||||
if [ -n "${DISPLAY}" ] ; then
|
||||
root="$(getNumberOfTmuxSessions)$(getDate)$(getBattery)$(getWattage)$(getCpuTemp)$(getVolume)$(getBrightness)$(getLayout)$(getWifi)$(getEth)$(getRates)$(getNord)$(getBluetooth)"
|
||||
root="$(getNumberOfTmuxSessions)$(getDate)$(getBattery)$(getWattage)$(getCpuTemp)$(getVolume)$(getBrightness)$(getLayout)$(getWifi)$(getEth)$(getRates)$(getNord)$(getGoku)$(getBluetooth)"
|
||||
root="$(printf '%s' "${root}" | cut -c3-)"
|
||||
xsetroot -name "${root}"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue