diff options
Diffstat (limited to 'public')
70 files changed, 4234 insertions, 0 deletions
diff --git a/public/.bash_aliases b/public/.bash_aliases new file mode 100644 index 0000000..5ea253d --- /dev/null +++ b/public/.bash_aliases @@ -0,0 +1,66 @@ +# Bash aliases. +# +# Aliases are recursive (I.e., an alias inside an alias works). + + +# Shortcuts +# ====================================================================== + +alias e="$EDITOR" +alias aliases="$EDITOR ~/.bash_aliases && source ~/.bash_aliases" +# wtf error with Code-OSS +# Ref.: https://stackoverflow.com/a/73317738/7498073 +alias code="code --enable-proposed-api ms-toolsai.jupyter" +alias echopath='echo "$PATH" | tr ":" "\n"' + + +# Common program's options +# ====================================================================== + +# coretools +alias diff2='diff --color=always -ys' # side by side, tell if file identical +alias diff='diff --color=always' +alias dir='dir --color=auto' +alias grep='grep --color=auto -i' # color case-insensitive +# Sort files by ASCII value (override current locale) +alias ls='ls --color=auto --group-directories-first --classify' +alias la='ls -A' +alias ll='ls -l -h' +alias lla='ll -A' +alias ip='ip --color=auto' + +alias gcc='gcc -g -std=c99 -lm' +alias ed='ed -p "* "' + +# https://missing.csail.mit.edu/2020/version-control/ +alias gitlogpretty='git log --all --graph --decorate --abbrev-commit' +# https://stackoverflow.com/a/15606995/7498073 +alias gitshowtrackedfiles='git ls-tree -r master --name-only' + +# Precautionary +alias rm='rm -I' # Promt before removing more than 3 files +alias mv='mv -i' # Promt before overwrite +alias cp='cp -i' # same + +#alias sqlite3='sqlite3 --safe' # Disables some really cool dot-commands + + +# Other program's options +# ====================================================================== + +alias units='units --verbose' +alias tty-clock='tty-clock -cs' + +# Quick tools +alias pdfreduce='gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook' +alias youtube-dl_info='youtube-dl --get-filename --get-format --get-duration --get-description' +alias youtube-dl_fast='youtube-dl --format "best[height<=720][fps<=?30]" -o '\''%(title)s.%(ext)s'\' +alias mpv_webcam='mpv av://v4l2:/dev/video0' # retrived from the Archwiki +alias mpv_nhk_720p='mpv "https://nhkwlive-ojp.akamaized.net/hls/live/2003459/nhkwlive-ojp-en/index_4M.m3u8"' + + +# Cosmetic +# ====================================================================== +alias :q="cowsay -d \"this isn't Vim\"" +alias :w="cowsay -b \"this isn't Vim\"" +alias sl="sl -de -5" diff --git a/public/.bash_profile b/public/.bash_profile new file mode 100644 index 0000000..5545f00 --- /dev/null +++ b/public/.bash_profile @@ -0,0 +1,5 @@ +# +# ~/.bash_profile +# + +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/public/.bashrc b/public/.bashrc new file mode 100644 index 0000000..065e12e --- /dev/null +++ b/public/.bashrc @@ -0,0 +1,158 @@ +# +# ~/.bashrc: executed by bash(1) for interactive shells +# +# Tinkerer's guide to a prettier and colorful CLI: +# https://wiki.archlinux.org/title/Color_output_in_console + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# TROUBLESHOOTING +# =============== + +export TERMINAL=st +export EDITOR=nvim +export VISUAL=nvim +export TERM=xterm-256color # Required for AWS VPS work good when SSHing + +# https://wiki.archlinux.org/title/GnuPG#Configure_pinentry_to_use_the_correct_TTY +export GPG_TTY=$(tty) +gpg-connect-agent updatestartuptty /bye >/dev/null + + +# Bash configuration +# ================== + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. (Isn't this the default behaviour?) +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# Alias definitions. +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# Don't forget to install bash-completion + +# Disable CTRL+S and CTRL+Q keybindings +# (used to pause and resume output to terminal) +# See: https://unix.stackexchange.com/a/137846/347754 +# https://unix.stackexchange.com/a/73499/347754 +stty -ixon + + +# Prompt +# ------ + +# - user@host pwd (git prompt) +# Ref.: https://stackoverflow.com/a/15398153/7498073 +source ~/.git-prompt.sh +PS1='\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ' + + +# Environment +# =========== + +# Add directories to PATH +ds=( + "$HOME/code/tex-live-native/build/bin/x86_64-linux" + "$HOME/.local/share/gem/ruby/3.0.0/bin" + "$HOME/.local/bin" + "$HOME/mahcode/dotfiles/local/bin" +) +for d in "${ds[@]}"; do + if ! echo $PATH | grep -qE "(^|:)$d($|:)"; then + export PATH="$d:$PATH" + fi +done + +export MANPATH="$HOME/code/tex-live-native/build/texmf-dist/doc/man:$MANPATH" +export INFOPATH="$HOME/code/tex-live-native/build/texmf-dist/doc/man:$INFOPATH" + +# XDG = Cross-Desktop Group +# For more info see https://wiki.archlinux.org/index.php/XDG_Base_Directory +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_STATE_HOME="$HOME/.local/state" + +# This is already in .xinitrc +# fcitx5 (input method) +#export GTK_IM_MODULE=fcitx +#export QT_IM_MODULE=fcitx +#export XMODIFIERS=@im=fcitx + +# less +LESS="-i " # ignore case +LESS+="-S " # don't chop long lines +LESS+="--RAW-CONTROL-CHARS" +export LESS + +# better `ls` (and other programs like `tree`) colors +eval "$(dircolors)" + + +# Extra programs +# -------------- + +# tldr +[ -f /usr/bin/tldr ] && export TLDR_CONFIG_DIR="$XDG_CONFIG_HOME" + +# nvm +#source /usr/share/nvm/init-nvm.sh + +# Pandoc: Bash completition for pandoc +if [ -f /usr/bin/pandoc ]; then + eval "$(pandoc --bash-completion)" +fi + +# Node.js +#export NODE_PATH=~/code/nodejs/node-v16.15.1-linux-x64/lib/node_modules + +# Rust +#. "$HOME/.cargo/env" + +# Ruby on Rails +#https://stackoverflow.com/a/19072136/7498073 +#gempath="$HOME/.local/share/gem/ruby/3.0.0/bin" +#export GEM_HOME="$(ruby -e 'puts Gem.user_dir')" +#if [[ -d $gempath ]]; then +# export PATH="$PATH:$GEM_HOME/bin" +#fi + + +# Fun +# ================ + +# Greeting or salute +if [ -f /usr/games/cowsay ] || [ -f /usr/bin/cowsay ]; then + #cowsay -f flaming-sheep "oh no" # original + #cowsay $(fortune -e 30% debian-hints 20% linux 20% science \ + #cowsay $(fortune 30% debian-hints 20% linux 20% science \ + # 20% off/linux 10% off/black-humor) + cowsay $(fortune) + #fortune ascii-art +else + echo "Welcome back $LOGNAME" +fi diff --git a/public/.config/git/config b/public/.config/git/config new file mode 100644 index 0000000..ec672da --- /dev/null +++ b/public/.config/git/config @@ -0,0 +1,15 @@ +[user] + email = [email protected] + name = Mitsuo Tokumori +[diff] + # used with $ git difftool + tool = nvim -d + submodule = log +[merge] + tool = nvim -d +[gitweb] + owner = Mitsuo Tokumori <[email protected]> +[init] + defaultBranch = master +[pull] + ff = only diff --git a/public/.config/git/ignore b/public/.config/git/ignore new file mode 100644 index 0000000..81f3e57 --- /dev/null +++ b/public/.config/git/ignore @@ -0,0 +1,10 @@ +# gitconfig file in ~/.config/git/config (if not in ~/.gitconfig) + +# Vim +*.swp + +# KDE +.directory + +# Python +config.py diff --git a/public/.config/gtk-3.0/settings.ini b/public/.config/gtk-3.0/settings.ini new file mode 100644 index 0000000..7033423 --- /dev/null +++ b/public/.config/gtk-3.0/settings.ini @@ -0,0 +1,15 @@ +[Settings] +gtk-application-prefer-dark-theme=false +gtk-button-images=true +gtk-cursor-theme-name=breeze_cursors +gtk-cursor-theme-size=24 +gtk-decoration-layout=icon:minimize,maximize,close +gtk-enable-animations=true +gtk-font-name=Noto Sans, 12 +gtk-icon-theme-name=breeze +gtk-menu-images=true +gtk-modules=colorreload-gtk-module:window-decorations-gtk-module +gtk-primary-button-warps-slider=false +gtk-theme-name=Breeze +gtk-toolbar-style=3 +gtk-xft-dpi=98304 diff --git a/public/.config/intellijidea/ideavimrc b/public/.config/intellijidea/ideavimrc new file mode 100644 index 0000000..c746971 --- /dev/null +++ b/public/.config/intellijidea/ideavimrc @@ -0,0 +1,51 @@ +"" Source your .vimrc +"source ~/.vimrc + +"" -- Suggested options -- +" Show a few lines of context around the cursor. Note that this makes the +" text scroll if you mouse-click near the start or end of the window. +set scrolloff=5 + +" Do incremental searching. +set incsearch + +" Don't use Ex mode, use Q for formatting. +"map Q gq + + +"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t +"" Map \r to the Reformat Code action +"map \r <Action>(ReformatCode) + +"" Map <leader>d to start debug +"map <leader>d <Action>(Debug) + +"" Map \b to toggle the breakpoint on the current line +"map \b <Action>(ToggleLineBreakpoint) + + +" Find more examples here: https://jb.gg/share-ideavimrc + +""" My stuff +set hlsearch +set ignorecase +set smartcase +set showmode +nnoremap <C-L> :nohl<CR><C-L> +nnoremap <F7> :tabp<CR> +nnoremap <F8> :tabn<CR> + +""" IdeaVim options +" Join and justify paragraphs/lines +set ideajoin " smartjoin +vnoremap gq :action FillParagraph<CR> +" Thank you: https://stackoverflow.com/a/37842786/7498073 +" TIP: Got the action name by listing all actions that contain the word fill +" `:actionlist fill` +"set ideamarks + +""" Plugins +" Couldn't make it to work well :( +" https://github.com/abrookins/WrapToColumn +" vnoremap gq :action com.andrewbrookins.idea.wrap.WrapParagraphAction<CR> + diff --git a/public/.config/locale.conf b/public/.config/locale.conf new file mode 100644 index 0000000..b827928 --- /dev/null +++ b/public/.config/locale.conf @@ -0,0 +1,5 @@ +LANG=C.UTF-8 +LC_COLLATE=C.UTF-8 +LC_MEASUREMENT=ja_JP.UTF-8 +LC_TIME=ja_JP.UTF-8 +LC_PAPER=ja_JP.UTF-8 diff --git a/public/.config/mpv/mpv.conf b/public/.config/mpv/mpv.conf new file mode 100644 index 0000000..23b612d --- /dev/null +++ b/public/.config/mpv/mpv.conf @@ -0,0 +1,5 @@ +# ~/.config/mpv/mpv.conf + +# Screenshots +screenshot-template="%f-%P" +screenshot-directory="~/media/Pictures/Screenshots/mpv" diff --git a/public/.config/nsxiv/exec/image-info b/public/.config/nsxiv/exec/image-info new file mode 100755 index 0000000..5f06123 --- /dev/null +++ b/public/.config/nsxiv/exec/image-info @@ -0,0 +1,21 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/image-info +# Called by nsxiv(1) whenever an image gets loaded. +# The output is displayed in nsxiv's status bar. +# Arguments: +# $1: path to image file (as provided by the user) +# $2: image width +# $3: image height +# $4: fully resolved path to the image file + +s=" " # field separator + +exec 2>/dev/null + +filename=$(basename -- "$1") +filesize=$(du -Hh -- "$1" | cut -f 1) +geometry="${2}x${3}" + +echo "${filesize}${s}${geometry}${s}${filename}" + diff --git a/public/.config/nsxiv/exec/thumb-info b/public/.config/nsxiv/exec/thumb-info new file mode 100755 index 0000000..b422f9c --- /dev/null +++ b/public/.config/nsxiv/exec/thumb-info @@ -0,0 +1,20 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/thumb-info +# Called by nsxiv(1) whenever the selected thumbnail changes. +# The output is displayed in nsxiv's status bar. +# Arguments: +# $1: path to image file (as provided by the user) +# $2: empty +# $3: empty +# $4: fully resolved path to the image file + +s=" " # field separator + +exec 2>/dev/null + +filename=$(basename -- "$4") +filesize=$(du -Hh -- "$4" | cut -f 1) + +echo "${filesize}${s}${filename}" + diff --git a/public/.config/nvim/colors/mac_classic.vim b/public/.config/nvim/colors/mac_classic.vim new file mode 100644 index 0000000..9382bde --- /dev/null +++ b/public/.config/nvim/colors/mac_classic.vim @@ -0,0 +1,226 @@ +" Vim color scheme +" +" Name: mac_classic.vim +" Maintainer: Drew Neil <[email protected]> +" License: public domain +" Version: 0.1 + +" Boilerplate: {{{1 +set background=light +highlight clear + +if exists("syntax_on") + syntax reset +endif + +let g:colors_name = "mac_classic" + + +" Colors: {{{1 +" TODO figure out how to not highlight TODO +" +" #000000 +" #3C4C72 - BLUE/GREY - cursor, rails helpers +" #0000A2 - D.BLUE - numbers & function names +" #1E39F6 - BLUE +" #0066FF - L.BLUE - Comments, TODOs and folds +" #6E79F1 - L.PURPLE - Booleans, Ruby Constants & CSS definitions +" #318495 - BLUE/GREEN - Ruby instance/global/pseudo variables +" #007B22 - D.GREEN - Strings, Labels and code blocks in Markdown +" #00BC41 - L.GREEN - CSS common attributes & ruby interpolation +" #990000 - BURGUNDY - Errors and Warnings +" #D51015 - RED for constants, symbols, numbers +" #E18AC7 - PINK RegularExpressions in Ruby +" #FFCE77 - ORANGE - Incremental Search +" #FFE6BB - L.ORANGE - Search +" #C6DEFF - VL.BLUE Visual, Current StatusLine & AutoComplete selection +" #808080 - Line numbers +" #CFCFCF - VerticalSplit separator +" #DFDFDF - Invisible Characters +" #EFEFEF - LineNumber & Non-Current StatusLine +" #F0F6FF - CursorLine & CursorColumn +" #FFFFFF - WHITE +" }}} + +" GUI: {{{1 +hi Cursor guifg=#FFFFFF ctermfg=15 guibg=#3C4C72 ctermbg=240 +hi Visual guibg=#C6DEFF ctermbg=189 +hi CursorLine guibg=#F0F6FF ctermbg=15 +hi CursorColumn guibg=#F0F6FF ctermbg=15 +hi LineNr guifg=#808080 ctermfg=244 guibg=#EFEFEF ctermbg=7 +hi VertSplit guifg=#FFFFFF ctermfg=15 guibg=#CFCFCF ctermbg=252 gui=NONE +hi MatchParen guifg=#1E39F6 ctermfg=27 guibg=NONE gui=bold +hi Pmenu guibg=#EFEFEF ctermbg=7 +hi PmenuSel guibg=#C6DEFF ctermbg=189 +hi Directory guifg=#D51015 ctermfg=160 gui=bold +hi Folded guifg=#0066FF ctermfg=27 guibg=#FFFFFF ctermbg=15 +" StatusLine: {{{2 +hi StatusLine guifg=#000000 ctermfg=0 guibg=#C6DEFF ctermbg=189 gui=italic +hi StatusLineNC guifg=#000000 ctermfg=0 guibg=#EFEFEF ctermbg=7 gui=NONE + +" Search: {{{2 +" [IncSearch is stronger than Search] +hi IncSearch guifg=NONE guibg=#FFCE77 ctermbg=222 gui=NONE +hi Search guibg=#FFE6BB ctermbg=223 + +" Syntax: {{{1 +hi Normal guifg=#000000 ctermfg=0 guibg=#FFFFFF ctermbg=15 +hi Boolean guifg=#6E79F1 ctermfg=69 gui=bold +hi Character guifg=#D51015 ctermfg=160 gui=bold +hi Comment guifg=#0066FF ctermfg=27 gui=italic +hi Conditional guifg=#1E39F6 ctermfg=27 gui=bold +hi Constant guifg=#D51015 ctermfg=160 gui=bold +hi Define guifg=#1E39F6 ctermfg=27 gui=bold +hi ErrorMsg guifg=#FFFFFF ctermfg=15 guibg=#990000 ctermbg=88 +hi WarningMsg guifg=#FFFFFF ctermfg=15 guibg=#990000 ctermbg=88 +hi Float guifg=#0000A2 ctermfg=19 +hi Function guifg=#0000A2 ctermfg=19 gui=bold +hi Identifier guifg=#1E39F6 ctermfg=27 gui=bold +hi Keyword guifg=#1E39F6 ctermfg=27 gui=bold +hi Label guifg=#007B22 ctermfg=28 +hi Number guifg=#0000A2 ctermfg=19 +hi Operator guifg=#1E39F6 ctermfg=27 gui=bold +hi PreProc guifg=#1E39F6 ctermfg=27 gui=bold +hi Special guifg=#000000 ctermfg=0 +hi Statement guifg=#1E39F6 ctermfg=27 gui=bold +hi StorageClass guifg=#1E39F6 ctermfg=27 gui=bold +hi String guifg=#007B22 ctermfg=28 +hi Title guifg=#000000 ctermfg=0 gui=bold +hi Todo guifg=#0066FF ctermfg=27 gui=inverse,bold,italic +hi Underlined gui=underline + +" Invisible character colors +hi NonText guifg=#DFDFDF ctermfg=253 guibg=#FFFFFF ctermbg=15 +hi SpecialKey guifg=#DFDFDF ctermfg=253 guibg=#FFFFFF ctermbg=15 + +" Diff styles {{{1 +hi diffAdded guifg=#007B22 guibg=#FFFFFF ctermfg=28 ctermbg=15 +hi diffRemoved guifg=#D51015 guibg=#FFFFFF ctermfg=160 ctermbg=15 +hi diffFile guifg=#6E79F1 guibg=#FFFFFF ctermfg=69 ctermbg=15 +hi diffNewFile guifg=#6E79F1 guibg=#FFFFFF ctermfg=69 ctermbg=15 +hi diffLine guifg=#000000 guibg=#FFFFFF ctermfg=0 ctermbg=15 + +hi diffAdd guifg=#007B22 guibg=#FFFFFF ctermfg=28 ctermbg=15 +hi diffChange guifg=#007B22 guibg=#FFFFFF ctermfg=28 ctermbg=15 +hi diffText guifg=#007B22 guibg=#FFFFFF ctermfg=28 ctermbg=15 +hi link diffDelete diffRemoved +" Git styles {{{1 +hi gitcommitFirstLine guifg=#000000 guibg=#FFFFFF ctermfg=0 ctermbg=15 +hi gitcommitSelectedType guifg=#007B22 guibg=#FFFFFF ctermfg=28 ctermbg=15 +hi link gitcommitSelectedFile gitcommitSelectedType +hi gitcommitDiscardedType guifg=#D51015 guibg=#FFFFFF ctermfg=160 ctermbg=15 +hi link gitcommitDiscardedFile gitcommitDiscardedType +hi gitcommitUntrackedFile guifg=#6E79F1 guibg=#FFFFFF ctermfg=69 ctermbg=15 +" Ruby styles {{{1 +hi rubyClass guifg=#1E39F6 ctermfg=27 gui=bold +hi rubyFunction guifg=#0000A2 ctermfg=19 gui=bold +hi rubyInterpolationDelimiter guifg=#00BC41 ctermfg=35 +hi rubyInterpolation guifg=#00BC41 ctermfg=35 +hi rubySymbol guifg=#D51015 ctermfg=160 gui=bold +hi rubyConstant guifg=#6E79F1 ctermfg=69 gui=bold +hi rubyStringDelimiter guifg=#007B22 ctermfg=28 +hi rubyInstanceVariable guifg=#318495 ctermfg=66 +hi rubyInclude guifg=#1E39F6 ctermfg=27 gui=bold +hi rubyGlobalVariable guifg=#318495 ctermfg=66 +hi rubyRegexp guifg=#E18AC7 ctermfg=176 +hi rubyRegexpAnchor guifg=#E18AC7 ctermfg=176 +hi rubyRegexpQuantifier guifg=#E18AC7 ctermfg=176 +hi rubyRegexpParens guifg=#E18AC7 ctermfg=176 +hi rubyRegexpEscape guifg=#00BC41 ctermfg=35 +hi rubyRegexpCharClass guifg=#00BC41 ctermfg=35 +hi rubyRegexpDelimiter guifg=#E18AC7 ctermfg=176 +hi rubyEscape guifg=#00BC41 ctermfg=35 +hi rubyControl guifg=#1E39F6 ctermfg=27 gui=bold +hi rubyOperator guifg=#1E39F6 ctermfg=27 gui=bold +hi rubyException guifg=#1E39F6 ctermfg=27 gui=bold +hi rubyPseudoVariable guifg=#318495 ctermfg=66 +hi rubyRailsUserClass guifg=#6E79F1 ctermfg=69 gui=bold +hi rubyRailsARAssociationMethod guifg=#3C4C72 ctermfg=240 gui=bold +hi rubyRailsARMethod guifg=#3C4C72 ctermfg=240 gui=bold +hi rubyRailsRenderMethod guifg=#3C4C72 ctermfg=240 gui=bold +hi rubyRailsMethod guifg=#3C4C72 ctermfg=240 gui=bold +hi link erubyComment Comment +hi erubyRailsMethod guifg=#3C4C72 ctermfg=240 gui=bold + +" XML: {{{1 +hi link xmlEndTag xmlTag +" HTML: {{{1 +hi htmlTag guifg=#1E39F6 ctermfg=27 +hi link htmlEndTag htmlTag +hi link htmlTagName htmlTag +hi link htmlArg htmlTag +hi htmlSpecialChar guifg=#D51015 ctermfg=160 gui=bold +hi htmlH1 gui=bold +hi link htmlH2 htmlH1 +hi link htmlH3 htmlH1 +hi link htmlH4 htmlH1 +hi link htmlH5 htmlH1 +hi link htmlH6 htmlH1 + +" JavaScript: {{{1 +hi javaScriptFunction guifg=#1E39F6 ctermfg=27 gui=bold +hi javaScriptFuncName guifg=#318495 ctermfg=66 gui=italic +hi javaScriptLabel guifg=#0000A2 ctermfg=19 gui=bold +hi javaScriptRailsFunction guifg=#3C4C72 ctermfg=240 gui=bold +hi javaScriptType guifg=#318495 ctermfg=66 gui=none +hi javaScriptArgument guifg=#318495 ctermfg=66 gui=italic +hi javaScriptRegexpString guifg=#E18AC7 ctermfg=176 gui=NONE +hi javaScriptSpecial guifg=#00BC41 ctermfg=35 gui=NONE +" NOTE: Syntax Highlighting for javascript doesn't match the +" TextMate version very accurately, because the javascript +" syntax file does not create matches for some items. In +" particular: +" * javaScriptArgument - e.g. function(argument) +" * javaScriptFuncName for object literal style functions - e.g.: +" myFunction: function() { ... } + +" YAML: {{{1 +hi yamlAnchor guifg=#318495 ctermfg=66 +hi yamlAlias guifg=#318495 ctermfg=66 +hi yamlDocumentHeader guibg=#F2F2F2 ctermbg=7 + +" CSS: {{{1 +hi cssTagName gui=bold +hi cssIdentifier gui=italic +hi link cssClassName cssIdentifier +hi cssDefinition guifg=#6E79F1 ctermfg=69 +hi link cssRenderProp cssDefinition +hi link cssTextProp cssDefinition +hi link cssFontProp cssDefinition +hi link cssColorProp cssDefinition +hi link cssBoxProp cssDefinition +hi link cssGeneratedContentProp cssDefinition +hi link cssUIProp cssDefinition +hi cssCommonAttr guifg=#00BC41 ctermfg=35 +hi link cssAttr cssCommonAttr +hi link cssRenderAttr cssCommonAttr +hi link cssTextAttr cssCommonAttr +hi link cssFontAttr cssCommonAttr +hi link cssGeneratedContentAttr cssCommonAttr +hi cssURL guifg=#007B22 ctermfg=28 +hi cssFunctionName guifg=#3C4C72 ctermfg=240 gui=bold +hi cssColor guifg=#D51015 ctermfg=160 gui=bold +hi cssValueLength guifg=#0000A2 ctermfg=19 +hi cssImportant guifg=#1E39F6 ctermfg=27 gui=bold + +" Vimscript: {{{1 +hi vimGroup guifg=#007B22 ctermfg=28 gui=bold +hi link vimHiGroup vimGroup +hi vimCommentTitle guifg=#3C4C72 ctermfg=240 gui=bold +hi helpSpecial guifg=#6E79F1 ctermfg=69 + +" Markdown: {{{1 +hi markdownBold gui=bold +hi markdownItalic gui=italic +hi markdownCode guifg=#007B22 ctermfg=28 +hi link markdownCodeBlock markdownCode + +" Outliner: {{{1 +hi BT1 guifg=#808080 ctermfg=244 gui=italic +hi OL1 guifg=#000000 ctermfg=0 gui=bold +hi OL2 guifg=#0000A2 ctermfg=19 gui=bold +hi OL3 guifg=#007B22 ctermfg=28 gui=bold +hi OL4 guifg=#6E79F1 ctermfg=69 gui=NONE +" Modelines: {{{1 +" vim: nowrap fdm=marker +" }}} diff --git a/public/.config/nvim/ftplugin/tex.vim b/public/.config/nvim/ftplugin/tex.vim new file mode 100644 index 0000000..e005eb1 --- /dev/null +++ b/public/.config/nvim/ftplugin/tex.vim @@ -0,0 +1 @@ +nnoremap <buffer> <F6> :!build-latex.sh %<CR> diff --git a/public/.config/nvim/init.vim b/public/.config/nvim/init.vim new file mode 100644 index 0000000..c6d2bb3 --- /dev/null +++ b/public/.config/nvim/init.vim @@ -0,0 +1,193 @@ +" NeoVim init.vim +" +" Differences with good ol' Vim: +" +" NeoVim has so many of the modern and helpful Vim options on by default. I'll +" remove most of the old Vim configurations that now come by default in NeoVim. +" +" Also NeoVim uses XDG directories by default, keeping a clean directory tree. +" +" NeoVim also allows for this file to be written in Lua. I'll stick to using +" Vim script becuase it has more documentation and is more concise configuring +" Vim options. +" +" Instead of viminfo, NeoVim uses shada files (SHared DAta) (different format). +" See shada-file-name. +" +" For some reason, as of version v0.8.3 of NeoVim, Vim internal codes for shift- +" and control- function keys change in NeoVim. <S-F1> changes to <F13>, and +" <C-F1> changes to <F25>. See https://github.com/neovim/neovim/issues/7384 +" +" Plugins: There are a lot of ways to install "plug-in"s in Vim. My prefered +" way is using Vim packages, available since Vim version 8. See packages. +" +" Tips: +" * To show navigate help files: +" K " while on an option to see it's documentation +" CTRL-] " navigation while on a Vim help file +" * To re-indent: +" tab->spaces :set tabstop=n :set expandtab :retab +" spaces->tab :set noexpandtab :set tabstop={softtabstop} :retab! +" * To justify: +" To 'justify' comments or block of text (paragraph) use `gq{motion}` or +" `gp{motion}`, where {motion} can be `[/`, `]/`, `ip`, `i{`, `a{`. +" * To see the last page of previous command: +" `g<` +" * Buffer stuff: +" :ls " shows all buffers +" :b N " Go to buffer N (integer) + + +" Settings +" ---------------------------------------------------------------------- + +" Common +colorscheme industry +filetype plugin on + +" Command line: +set cmdheight=1 +set wildmenu +set wildignore+=*.o,.git,*.class +set path+=./**30 " For gf and :find, add all subdirectories relative to + " current file (30 max) to the "search space" + +" Search +set ignorecase +set smartcase + +" Screen +set nonumber +set scrolloff=5 " show a few lines of context +set colorcolumn=+1 " show ruler at position tabstop+1 +set laststatus=2 +" Add buffer number to the default status line with ruler +set statusline=%<%f\ %h%m%r%=b%02n\ \ %-14.(%l,%c%V%)\ %P + +" TODO: move to ftplugin +" TODO: create tags automatically (:!ctags -R . after :w if ft=c) +" Tag Jumping +" Instructions: create tag index (e.g. $ ctags -R .) +" place cursor on tag +" ^] to jump to definition +" g^] if more than 1 definition +" ^T to return (or ^O) + +"set cindent +"set cinoptions=:0,g0 " See C-indenting + + +" Indentation: 4 spaces +" See also: autoindent, smartindent, cindent, indentexpr +set tabstop=4 " Each '\t' takes 8 virtual (screen) columns +set shiftwidth=0 " (Auto)indentation. Also affects: >>, i_C-T, i_C-D +set expandtab " Expand inserted <Tab>s with <Space> +set smartindent " Smart indenting when starting a new line + +" Formatting: See fo-table +set formatoptions+=t " auto-wrap text (when inserting) +set formatoptions+=c " auto-wrap comments (when inserting) +set formatoptions+=q " Allow formatting of comments with "gq" +set formatoptions+=j " Removes comment leader when joining lines +set formatoptions+=l " Don't break long lines that are already typed +set formatoptions+=r " Insert current leader after <Enter> in Insert mode +set formatoptions+=p " Don't break honorifics like Prof. Smith +set formatoptions+=n " Recognize numbered lists +set formatoptions+=o " Automatically insert the current comment + " leader after `o`. + +" Wrap: Auto-break lines longer than 80 colums +set textwidth=80 +set wrap +set linebreak " Don't break words + +" Mouse +set mouse=a " Enable mouse for all modes + +" Buffers +set hidden " Allow for hidden modified buffers + +" Split +set splitbelow splitright + + +" Mappings +" ---------------------------------------------------------------------- + +let $VIMFILES = split(&rtp, ",")[0] + +map <F5> :source $VIMFILES/init.vim<CR> +map <F17> :e $VIMFILES/init.vim<CR> + +map <F7> :tabp<CR> +map <F8> :tabn<CR> +map <F19> :bNext<LF> +map <F20> :bnext<LF> + +" TODO: move to ftplugin +" C/C++ Programming: +map <F6> :w<CR>:!clear && make<CR> +"map <F10> :!./%:r<CR> +"map <F10> :!./a.out<CR> +map <F11> :cnext<CR> +map <S-F11> :cprev<CR> +" "Run cTags" +map <Leader>rt :!ctags -R .<CR> +map <C-\> :tnext<CR> +" Motion to go to beggining of function while cursor is inside +nmap [f [m[{k0 + +" pandoc (& website): +nnoremap mm :w<CR>:Md2Html<CR><CR><CR> +nmap mM mm:!updatewebsite_zaz<CR><CR> + +" asciidoctor: +nnoremap ma :w<CR>:!asciidoctor %<CR><CR> +nmap mA ma:!updatewebsite.sh<CR><CR> + +" Funcionallity of the following depends on terminal emulator. Needs 8-bit +" input enabled +" for <Meta> = Alt key combos +" From: https://vim.fandom.com/wiki/Get_Alt_key_to_work_in_terminal +nmap <M-H> <C-W>h +nmap <M-J> <C-W>j +nmap <M-K> <C-W>k +nmap <M-L> <C-W>l + +" Go Title Case (and clear highlighted matches) +" Ref.: https://vim.fandom.com +vmap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR><C-L> + +" Autoformat JSON jumbled data +" Ref.: https://stackoverflow.com/questions/26214156/how-to-auto-format-json-on-save-in-vim +nnoremap gJ :%!python3 -m json.tool<CR> + +" Replaces previous WORD arithmetic expression with result (from Vim +" fandom-wiki) +inoremap <C-A> <Esc>diWi<C-R>=<C-R>"<CR> + + +" Views and Sessions (Window layout and Line folding) +" ---------------------------------------------------------------------- +" It is possible to create folds automatically but idk how to do it. +" :mkview so save them :loadview to load them (zo open one, zc close one, +" zR to open all, zM to close all, zx to restore)) + +" Views saves folds. Sessions saves all windows configuration and layout +" Load Sessions with $ vim -S Session.vim + +" To automatically save and restore views for *.c *.cpp files: +"au BufWinLeave *.c mkview +"au BufWinEnter *.c silent loadview +"au BufWinLeave *.cpp mkview +"au BufWinEnter *.cpp silent loadview + + +" Playground +" ---------- +"autocmd FileType tex nnoremap <buffer> <F6> :!./build.sh %<CR> + +"augroup TeX +" autocmd! +" autocmd BufWritePost *.tex !./build.sh % +"augroup END diff --git a/public/.config/nvim/pack/mitsuo/Readme.txt b/public/.config/nvim/pack/mitsuo/Readme.txt new file mode 100644 index 0000000..a9e88cd --- /dev/null +++ b/public/.config/nvim/pack/mitsuo/Readme.txt @@ -0,0 +1 @@ +Vim plugins I use go here. diff --git a/public/.config/nvim/pack/mitsuo/start/fun/Readme.txt b/public/.config/nvim/pack/mitsuo/start/fun/Readme.txt new file mode 100644 index 0000000..2f41d59 --- /dev/null +++ b/public/.config/nvim/pack/mitsuo/start/fun/Readme.txt @@ -0,0 +1 @@ +My special functions :) diff --git a/public/.config/nvim/pack/mitsuo/start/fun/plugin/fun.vim b/public/.config/nvim/pack/mitsuo/start/fun/plugin/fun.vim new file mode 100644 index 0000000..c992f93 --- /dev/null +++ b/public/.config/nvim/pack/mitsuo/start/fun/plugin/fun.vim @@ -0,0 +1,121 @@ +" To call functions use `:call foo()` + +" Echoes longest line number and lenght. +function! LongestLineLength ( ) + let maxlength = 0 + let linenumber= 1 + while linenumber <= line("$") + exe ":".linenumber + let linelength = virtcol("$") + if maxlength < linelength + let maxlength = linelength + let maxlinenumber = linenumber + endif + let linenumber = linenumber+1 + endwhile + +"exe ':0' +"exe 'normal O' +"exe 'normal 0C'.maxlength + exe "normal" . maxlinenumber . "G" + exe ":echo \"" . maxlinenumber . ": " . maxlength . "\"" +endfunction + +command LongestLineLength call LongestLineLength() + + +" Save markdown document and export to pdf using pandoc. +" +" It would be nicer if a default document would be used but I coulnd't made it +" to work even after reading that manual section like 2 times. Also, there are +" variables that are lists of other variables that I don't know how to make them +" work (e.g. geometry=[top=1in, bottom=1in, heightrounded]) +function! Md2Pdf ( ) + exe ":w" + "-N for numbered headers + exe ":! pandoc -o \"" . expand("%:r") . ".pdf\" -t latex --variable classoption=twosides --variable papersize=a4 --variable margin-left=1in --variable margin-right=1in --variable margin-top=1in --variable margin-bottom=1in --variable links-as-notes --variable colorlinks --variable pagestyle=plain --variable documentclass=article -f markdown-implicit_figures \"" . expand("%") . "\"" + echo "pdf saved as \"" . expand("%:p:r") . ".pdf\"" +endfunction + +function! Md2Pdfms ( ) + exe ":w" + exe ":! pandoc -o " . expand("%:r") . ".pdf" . " -t ms -f markdown-implicit_figures \"" . expand("%") . "\"" + echo "pdf saved as " . expand("%:p:r") . ".pdf" +endfunction + +command Md2Pdf call Md2Pdf() +command Md2Pdfms call Md2Pdfms() + + +" Save markdown document and export to html using pandoc +function! Md2Html ( ) + exe ":w" + "exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\"" + exe ":! pandoc --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\"" + echo "html saved as " . expand("%:p:r") . ".html" +endfunction + +command Md2Html call Md2Html() + +" Save markdown as ODT file (.docx is also possible) +function! Md2Odt ( ) + exe ":w" + exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".odt\"" . " \"" . expand("%") . "\"" + echo "ODT saved as " . expand("%:p:r") . ".odt" +endfunction + +command Md2Odt call Md2Odt() + + +" Compiles and Runs a C++ project +" TODO: how to add program's arguments or file redirectioning from command. +function! CompRunProj ( ) + exe ":w" + exe ":! g++ -o " . expand("%:r") . "-g *.cpp" + exe ":! ./" . expand("%:r") +endfunction + +command CompRunProj call CompRunProj() + + +" Function made to give feedback to students code in 1INF01 +" export C code to syntax highlighted pdf +function! C2Pdf ( ) + exe ":set ts=4" + exe ":w" + exe ":ha > %.ps" + exe ":!ps2pdf %.ps" + exe ":!rm %.ps" +endfunction + + +" For printing first export to html and then print using web browser +" Ref.: https://vi.stackexchange.com/questions/12058/printing-unicode-chars +function! ExportHTML (colorscheme="quiet", bg="light") + " Nice colorschemes for printing on paper: quiet, morning, mac_classic + let s:prev_color = g:colors_name + let s:prev_bg = &background + exe "colorscheme" a:colorscheme + exe "set bg=" . a:bg + + exe "TOhtml | w | !xdg-open %" + echo "html export saved as " . expand('%:p') + exe "bd" + + exe "colorscheme" s:prev_color + exe "set bg=" . s:prev_bg +endfunction + +command ExportHTML call ExportHTML() + +" C++ +" Formatting +" Ref.: https://clang.llvm.org/docs/ClangFormat.html +map <C-K> :pyf /usr/share/clang/clang-format.py<cr> +"imap <C-K> <c-o>:py3f /usr/share/clang/clang-format.py<cr> + +"function! Formatonsave() +" let l:formatdiff = 1 +" pyf /usr/share/clang/clang-format.py +"endfunction +"autocmd BufWritePre *.h,*.hpp,*.cc,*.cpp call Formatonsave() diff --git a/public/.config/nvim/pack/mitsuo/start/vim-commentary b/public/.config/nvim/pack/mitsuo/start/vim-commentary new file mode 160000 +Subproject e87cd90dc09c2a203e13af9704bd0ef79303d75 diff --git a/public/.config/pandoc/linuxcolors_style.html b/public/.config/pandoc/linuxcolors_style.html new file mode 100644 index 0000000..e050698 --- /dev/null +++ b/public/.config/pandoc/linuxcolors_style.html @@ -0,0 +1,188 @@ +<style type="text/css"> +:root { + /* Linux Colors (Konsole) + ()normal, (I)ntense, (F)aint + + https://kernel.org + */ + + --color1: rgb(0, 0, 0); /* background */ + --color2: rgb(178, 24, 24); /* red */ + --color3: rgb(24, 178, 24); /* green */ + --color4: rgb(178, 104, 24); /* yellow */ + --color5: rgb(24, 24, 178); /* blue */ + --color6: rgb(178, 24, 178); /* magenta */ + --color7: rgb(24, 178, 178); /* cyan */ + --color8: rgb(178, 178, 178); /* foreground */ + + --color1I: rgb(104, 104, 104); + --color2I: rgb(255, 84, 84); + --color3I: rgb(84, 255, 84); + --color4I: rgb(255, 255, 84); + --color5I: rgb(84, 84, 255); + --color6I: rgb(255, 84, 255); + --color7I: rgb(84, 255, 255); + --color8I: rgb(255, 255, 255); + + --color1F: rgb(0, 0, 0); + --color2F: rgb(101, 0, 0); + --color3F: rgb(0, 101, 0); + --color4F: rgb(101, 94, 0); + --color5F: rgb(0, 0, 101); + --color6F: rgb(101, 0, 101); + --color7F: rgb(0, 101, 101); + --color8F: rgb(101, 101, 101); + + /* + previously (h1-5): + - navy + - navy + - royalblue + - steelblue + - skyblue + */ +} +html { + font-size: 1em; /* (use browser's default, usually 16px) */ +} +body { + margin: auto; + padding-right: 1em; + padding-left: 1em; + max-width: 44em; + min-width: 44em; /* test different values */ + overflow: auto; + + border-left: 1px solid black; + border-right: 1px solid black; + font-family: sans-serif; + font-size: 100%; + line-height: 140%; + color: var(--color8); + background-color: var(--color1); +} +pre { + /* "wrapper" for code element */ + border: 1px solid var(--color8); + padding: 0.25em; + overflow: auto; + font-family: monospace; + /* 1.2 em relative to what? What size of M? I've no idea */ + font-size: 1.1em; + line-height: 1.1em; +} +code { + /* wraps around the lines of code, or something like that. I'm not sure + what is it's function + */ + /* somewhere in pandoc, this element get's white-space: pre-wrap, which + wraps code that doesn't fit in parent element. So I need to overwrite + that setting here. Now the contents overflow, and a scrollbar is + automatically enabled + */ + white-space: pre; +} +/* Definition List <dl>, Definition Title <dt>, Definition Description <dd> */ +dt { + font-weight: bold; +} +dd p { + margin-top: 0; +} +blockquote { + margin-top: 10px; + margin-bottom: 10px; + margin-left: 5px; + padding-left: 15px; + border-left: 3px solid #ccc; +} +h1, h2, h3, h4, h5 { + /* headers use serif font */ + /*font-weight: bold;*/ + font-family: Verdana, serif; +} + +h1 { + /* inspiration: htop table header + use: chapter begin + */ + font-size: 180%; + color: var(--color1); + background-color: var(--color3); + padding: 0.1em; +} + +h2 { + /* inspiration: Wikipedia section + use: section begin + */ + font-size: 160%; + + color: var(--color8I); + border-bottom: 1px solid; +} + +h3 { + /* inspiration: man page header + use: subsection + */ + font-size: 140%; + + color: var(--color8I); + /* UPPERCASE afecta mucho el tamaño :( */ + /*text-transform: uppercase;*/ +} + +h4 { + /* inspiration: man page sub-header + use: subsection + */ + font-size: 120%; + color: var(--color8I); +} + +h5 { + /* inspiration: man page sub-header + use: subsection + */ + font-size: 100%; + /*font-style: italic;*/ + color: var(--color8I); +} + +h1.title { + font-size: 200%; + line-height: 110%; + font-weight: bold; + + color: var(--color1); + background-color: var(--color3); + + border: none; + + padding-top: 0.2em; + padding-bottom: 0.2em; + text-align: center; +} + +p.author, p.date { + text-align: center; +} + +:any-link { + color: var(--color8); + text-decoration: underline; +} + +#footer { + padding-top: 1em; + font-size: 70%; + color: gray; + text-align: center; +} + +/* maybe fix this, make more dynamic */ +img { + max-width: 40em; +} +</style> diff --git a/public/.config/ssh/Readme.txt b/public/.config/ssh/Readme.txt new file mode 100644 index 0000000..c902d49 --- /dev/null +++ b/public/.config/ssh/Readme.txt @@ -0,0 +1,8 @@ +important considerations for ssh: +- Change port to other than default (specially if exposed) +- Rate limit SSH traffic with a firewall (e.g., ufw) +- Disable password authentication (use RSA) +- Disable root login + +sshd_config goes to /etc/sshd_config in ArchLinux +config goes to ~/.ssh/config diff --git a/public/.config/ssh/config b/public/.config/ssh/config new file mode 100644 index 0000000..7979b64 --- /dev/null +++ b/public/.config/ssh/config @@ -0,0 +1,9 @@ +# global options +#User admin + +# host-specific options +Host example.com + Hostname 123.123.123.123 + #Port 22 + User pocoyo + #IdentityFile ~/path/to/key diff --git a/public/.config/ssh/sshd_config b/public/.config/ssh/sshd_config new file mode 100644 index 0000000..1e8358e --- /dev/null +++ b/public/.config/ssh/sshd_config @@ -0,0 +1,117 @@ +# $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/bin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented. Uncommented options override the +# default value. + +Port 22 # set a custom port +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: + +#HostKey /etc/ssh/ssh_host_rsa_key +#HostKey /etc/ssh/ssh_host_ecdsa_key +#HostKey /etc/ssh/ssh_host_ed25519_key + +# Ciphers and keying +#RekeyLimit default none + +# Logging +#SyslogFacility AUTH +#LogLevel INFO + +# Authentication: + +#LoginGraceTime 2m +#PermitRootLogin prohibit-password +PermitRootLogin no +#StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 + +#PubkeyAuthentication yes + +# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 +# but this is overridden so installations will only check .ssh/authorized_keys +AuthorizedKeysFile .ssh/authorized_keys + +#AuthorizedPrincipalsFile none + +#AuthorizedKeysCommand none +#AuthorizedKeysCommandUser nobody + +# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts +#HostbasedAuthentication no +# Change to yes if you don't trust ~/.ssh/known_hosts for +# HostbasedAuthentication +#IgnoreUserKnownHosts no +# Don't read the user's ~/.rhosts and ~/.shosts files +#IgnoreRhosts yes + +# To disable tunneled clear text passwords, change to no here! +PasswordAuthentication no +#PermitEmptyPasswords no + +# Change to no to disable s/key passwords +KbdInteractiveAuthentication no + +# Kerberos options +#KerberosAuthentication no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes +#KerberosGetAFSToken no + +# GSSAPI options +#GSSAPIAuthentication no +#GSSAPICleanupCredentials yes + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the KbdInteractiveAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via KbdInteractiveAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and KbdInteractiveAuthentication to 'no'. +UsePAM yes + +#AllowAgentForwarding yes +#AllowTcpForwarding yes +#GatewayPorts no +#X11Forwarding no +#X11DisplayOffset 10 +#X11UseLocalhost yes +#PermitTTY yes +PrintMotd no # pam does that +#PrintLastLog yes +#TCPKeepAlive yes +#PermitUserEnvironment no +#Compression delayed +#ClientAliveInterval 0 +#ClientAliveCountMax 3 +#UseDNS no +#PidFile /run/sshd.pid +#MaxStartups 10:30:100 +#PermitTunnel no +#ChrootDirectory none +#VersionAddendum none + +# no default banner path +#Banner none + +# override default of no subsystems +Subsystem sftp /usr/lib/ssh/sftp-server + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# PermitTTY no +# ForceCommand cvs server diff --git a/public/.config/tmux/tmux.conf b/public/.config/tmux/tmux.conf new file mode 100644 index 0000000..e5a3e66 --- /dev/null +++ b/public/.config/tmux/tmux.conf @@ -0,0 +1,66 @@ +# Minimal tmux config +# Ref.: https://thevaluable.dev/tmux-config-mouseless/ + +# remap prefix from 'C-b' to 'C-a' +set-option -g prefix C-a +bind-key C-a send-prefix +unbind C-b + +# Start window numbering at 1 +set -g base-index 1 +setw -g pane-base-index 1 + +# Navigate history with vi keybindings +set-window-option -g mode-keys vi +set -g history-limit 10000 + +# From NeoVim advice: +# Fix 'escape-time' from 500ms to 10ms (better experience in Vim) +set-option -sg escape-time 10 +# focus-events (idk what this does) +set-option -g focus-events on + +# Vim friendly tmux config +# Ref.: https://gist.github.com/Lartza/6a7a62466a8a3e436234412d9b1c5066 + +setw -g monitor-activity on +set -g visual-activity on + +# FIXME: https://unix.stackexchange.com/a/131187/347754 +# y and p as in vim +bind Escape copy-mode +unbind p +bind p paste-buffer +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'y' send -X copy-selection +#bind-key -T copy-mode-vi 'Space' send -X halfpage-down +#bind-key -T copy-mode-vi 'Bspace' send -X halfpage-up + +# extra commands for interacting with the ICCCM clipboard +#bind C-c run "tmux save-buffer - | xclip -i -sel clipboard" +#bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer" + +# easy-to-remember split pane commands +#bind | split-window -h +#bind - split-window -v +#unbind '"' +#unbind % +# Thanks: https://unix.stackexchange.com/a/109255/347754 +bind % split-window -h -c "#{pane_current_path}" +bind '"' split-window -v -c "#{pane_current_path}" + +# moving between panes with vim movement keys +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# moving between windows with vim movement keys +bind -r C-h select-window -t :- +bind -r C-l select-window -t :+ + +# resize panes with vim movement keys +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 diff --git a/public/.config/vscode/Readme.adoc b/public/.config/vscode/Readme.adoc new file mode 100644 index 0000000..d14dc6f --- /dev/null +++ b/public/.config/vscode/Readme.adoc @@ -0,0 +1,7 @@ +Preferably use "Code - OSS" instead of VSCode. + +Changes: + +* Light solarized color scheme +* "Old" Activity Bar and Status Bar colors +* Rulers diff --git a/public/.config/vscode/keybindings.json b/public/.config/vscode/keybindings.json new file mode 100644 index 0000000..7c5b25b --- /dev/null +++ b/public/.config/vscode/keybindings.json @@ -0,0 +1,58 @@ +// Place your key bindings in this file to override the defaultsauto[] +[ + { + "key": "f8", + "command": "-editor.action.marker.nextInFiles", + "when": "editorFocus" + }, + { + "key": "f8", + "command": "workbench.action.debug.stepOver", + "when": "debugState == 'stopped'" + }, + { + "key": "f10", + "command": "-workbench.action.debug.stepOver", + "when": "debugState == 'stopped'" + }, + { + "key": "f7", + "command": "-editor.action.diffReview.next", + "when": "isInDiffEditor" + }, + { + "key": "f7", + "command": "-editor.action.wordHighlight.next", + "when": "editorTextFocus && hasWordHighlights" + }, + { + "key": "f7", + "command": "workbench.action.debug.stepInto", + "when": "debugState != 'inactive'" + }, + { + "key": "f11", + "command": "-workbench.action.debug.stepInto", + "when": "debugState != 'inactive'" + }, + { + "key": "shift+f7", + "command": "-editor.action.diffReview.prev", + "when": "isInDiffEditor" + }, + { + "key": "shift+f7", + "command": "-editor.action.wordHighlight.prev", + "when": "editorTextFocus && hasWordHighlights" + }, + { + "key": "shift+f7", + "command": "workbench.action.debug.stepOut", + "when": "debugState == 'stopped'" + }, + { + "key": "shift+f11", + "command": "-workbench.action.debug.stepOut", + "when": "debugState == 'stopped'" + } +]
\ No newline at end of file diff --git a/public/.config/vscode/settings.json b/public/.config/vscode/settings.json new file mode 100644 index 0000000..1c0204d --- /dev/null +++ b/public/.config/vscode/settings.json @@ -0,0 +1,14 @@ +{ + "editor.minimap.enabled": false, + "editor.rulers": [80, 120], + "editor.wordWrap": "on", + "editor.lineNumbers": "off", + + "jupyter.askForKernelRestart": false, + "[python]": { + "editor.formatOnType": true + }, + "terminal.integrated.enableMultiLinePasteWarning": false, + "gitlens.hovers.currentLine.over": "line", + "autoDocstring.docstringFormat": "sphinx-notypes", +} diff --git a/public/.config/zathura/zathurarc b/public/.config/zathura/zathurarc new file mode 100644 index 0000000..4d38c70 --- /dev/null +++ b/public/.config/zathura/zathurarc @@ -0,0 +1,59 @@ +######################### +# Configuracion Zathura # +######################### +# +# para para saber que hace cada huevada +# ver manpage zathurarc(5) +# + +# Default commented shit +# ====================== + +# zoom and scroll step size +# set zoom-setp 20 +# set scroll-setp 80 + +# copy selection to system clipboard +# set selection-clipboard clipboard + +# enable incremental search +# set incremental-search true + +# mapings +# ======= + +# TODO Button 3 is left mouse button, I want to map it to 'hold to pan document' +# which is mapped to mouse 2 (middle button) +#map Button3 + +unmap [normal] <C-n> +map [normal] <C-g> toggle_statusbar +unmap [fullscreen] <C-n> +map [fullscreen] <C-g> toggle_statusbar + +unmap [normal] D +map [normal] D toggle_page_mode +unmap [fullscreen] D +map [fullscreen] D toggle_page_mode + +map [normal] u scroll half-up +map [normal] d scroll half-down +map [fullscreen] u scroll half-up +map [fullscreen] d scroll half-down + +# settings +# ======== + +#set window-width 768 +set window-width 1025 +set window-height 740 +set adjust-open width + +#set smooth-scroll true + +#set first-page-column 2 + +set statusbar-home-tilde true +#set window-title-home-tilde true +set window-title-basename true +set selection-clipboard clipboard diff --git a/public/.git-prompt.sh b/public/.git-prompt.sh new file mode 100644 index 0000000..1435548 --- /dev/null +++ b/public/.git-prompt.sh @@ -0,0 +1,589 @@ +# bash/zsh git prompt support +# +# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> +# Distributed under the GNU General Public License, version 2.0. +# +# This script allows you to see repository status in your prompt. +# +# To enable: +# +# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-prompt.sh +# 3a) Change your PS1 to call __git_ps1 as +# command-substitution: +# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' +# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' +# the optional argument will be used as format string. +# 3b) Alternatively, for a slightly faster prompt, __git_ps1 can +# be used for PROMPT_COMMAND in Bash or for precmd() in Zsh +# with two parameters, <pre> and <post>, which are strings +# you would put in $PS1 before and after the status string +# generated by the git-prompt machinery. e.g. +# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' +# will show username, at-sign, host, colon, cwd, then +# various status string, followed by dollar and SP, as +# your prompt. +# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" } +# will show username, pipe, then various status string, +# followed by colon, cwd, dollar and SP, as your prompt. +# Optionally, you can supply a third argument with a printf +# format string to finetune the output of the branch status +# +# The repository status will be displayed only if you are currently in a +# git repository. The %s token is the placeholder for the shown status. +# +# The prompt status always includes the current branch name. +# +# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value, +# unstaged (*) and staged (+) changes will be shown next to the branch +# name. You can configure this per-repository with the +# bash.showDirtyState variable, which defaults to true once +# GIT_PS1_SHOWDIRTYSTATE is enabled. +# +# You can also see if currently something is stashed, by setting +# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, +# then a '$' will be shown next to the branch name. +# +# If you would like to see if there're untracked files, then you can set +# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked +# files, then a '%' will be shown next to the branch name. You can +# configure this per-repository with the bash.showUntrackedFiles +# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is +# enabled. +# +# If you would like to see the difference between HEAD and its upstream, +# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" +# indicates you are ahead, "<>" indicates you have diverged and "=" +# indicates that there is no difference. You can further control +# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list +# of values: +# +# verbose show number of commits ahead/behind (+/-) upstream +# name if verbose, then also show the upstream abbrev name +# legacy don't use the '--count' option available in recent +# versions of git-rev-list +# git always compare HEAD to @{upstream} +# svn always compare HEAD to your SVN upstream +# +# By default, __git_ps1 will compare HEAD to your SVN upstream if it can +# find one, or @{upstream} otherwise. Once you have set +# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by +# setting the bash.showUpstream config variable. +# +# You can change the separator between the branch name and the above +# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator +# is SP. +# +# When there is an in-progress operation such as a merge, rebase, +# revert, cherry-pick, or bisect, the prompt will include information +# related to the operation, often in the form "|<OPERATION-NAME>". +# +# When the repository has a sparse-checkout, a notification of the form +# "|SPARSE" will be included in the prompt. This can be shortened to a +# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted +# by setting GIT_PS1_OMITSPARSESTATE. +# +# If you would like to see more information about the identity of +# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE +# to one of these values: +# +# contains relative to newer annotated tag (v1.6.3.2~35) +# branch relative to newer tag or branch (master~4) +# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) +# tag relative to any older tag (v1.6.3.1-13-gdd42c2f) +# default exactly matching tag +# +# If you would like a colored hint about the current dirty state, set +# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on +# the colored output of "git status -sb" and are available only when +# using __git_ps1 for PROMPT_COMMAND or precmd in Bash, +# but always available in Zsh. +# +# If you would like __git_ps1 to do nothing in the case when the current +# directory is set up to be ignored by git, then set +# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the +# repository level by setting bash.hideIfPwdIgnored to "false". + +# check whether printf supports -v +__git_printf_supports_v= +printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 + +# stores the divergence from upstream in $p +# used by GIT_PS1_SHOWUPSTREAM +__git_ps1_show_upstream () +{ + local key value + local svn_remote svn_url_pattern count n + local upstream_type=git legacy="" verbose="" name="" + + svn_remote=() + # get some config options from git-config + local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" + while read -r key value; do + case "$key" in + bash.showupstream) + GIT_PS1_SHOWUPSTREAM="$value" + if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then + p="" + return + fi + ;; + svn-remote.*.url) + svn_remote[$((${#svn_remote[@]} + 1))]="$value" + svn_url_pattern="$svn_url_pattern\\|$value" + upstream_type=svn+git # default upstream type is SVN if available, else git + ;; + esac + done <<< "$output" + + # parse configuration values + local option + for option in ${GIT_PS1_SHOWUPSTREAM}; do + case "$option" in + git|svn) upstream_type="$option" ;; + verbose) verbose=1 ;; + legacy) legacy=1 ;; + name) name=1 ;; + esac + done + + # Find our upstream type + case "$upstream_type" in + git) upstream_type="@{upstream}" ;; + svn*) + # get the upstream from the "git-svn-id: ..." in a commit message + # (git-svn uses essentially the same procedure internally) + local -a svn_upstream + svn_upstream=($(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + if [[ 0 -ne ${#svn_upstream[@]} ]]; then + svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} + svn_upstream=${svn_upstream%@*} + local n_stop="${#svn_remote[@]}" + for ((n=1; n <= n_stop; n++)); do + svn_upstream=${svn_upstream#${svn_remote[$n]}} + done + + if [[ -z "$svn_upstream" ]]; then + # default branch name for checkouts with no layout: + upstream_type=${GIT_SVN_ID:-git-svn} + else + upstream_type=${svn_upstream#/} + fi + elif [[ "svn+git" = "$upstream_type" ]]; then + upstream_type="@{upstream}" + fi + ;; + esac + + # Find how many commits we are ahead/behind our upstream + if [[ -z "$legacy" ]]; then + count="$(git rev-list --count --left-right \ + "$upstream_type"...HEAD 2>/dev/null)" + else + # produce equivalent output to --count for older versions of git + local commits + if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)" + then + local commit behind=0 ahead=0 + for commit in $commits + do + case "$commit" in + "<"*) ((behind++)) ;; + *) ((ahead++)) ;; + esac + done + count="$behind $ahead" + else + count="" + fi + fi + + # calculate the result + if [[ -z "$verbose" ]]; then + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p=">" ;; + *" 0") # behind upstream + p="<" ;; + *) # diverged from upstream + p="<>" ;; + esac + else # verbose, set upstream instead of p + case "$count" in + "") # no upstream + upstream="" ;; + "0 0") # equal to upstream + upstream="|u=" ;; + "0 "*) # ahead of upstream + upstream="|u+${count#0 }" ;; + *" 0") # behind upstream + upstream="|u-${count% 0}" ;; + *) # diverged from upstream + upstream="|u+${count#* }-${count% *}" ;; + esac + if [[ -n "$count" && -n "$name" ]]; then + __git_ps1_upstream_name=$(git rev-parse \ + --abbrev-ref "$upstream_type" 2>/dev/null) + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then + upstream="$upstream \${__git_ps1_upstream_name}" + else + upstream="$upstream ${__git_ps1_upstream_name}" + # not needed anymore; keep user's + # environment clean + unset __git_ps1_upstream_name + fi + fi + fi + +} + +# Helper function that is meant to be called from __git_ps1. It +# injects color codes into the appropriate gitstring variables used +# to build a gitstring. Colored variables are responsible for clearing +# their own color. +__git_ps1_colorize_gitstring () +{ + if [[ -n ${ZSH_VERSION-} ]]; then + local c_red='%F{red}' + local c_green='%F{green}' + local c_lblue='%F{blue}' + local c_clear='%f' + else + # Using \[ and \] around colors is necessary to prevent + # issues with command line editing/browsing/completion! + local c_red='\[\e[31m\]' + local c_green='\[\e[32m\]' + local c_lblue='\[\e[1;34m\]' + local c_clear='\[\e[0m\]' + fi + local bad_color=$c_red + local ok_color=$c_green + local flags_color="$c_lblue" + + local branch_color="" + if [ $detached = no ]; then + branch_color="$ok_color" + else + branch_color="$bad_color" + fi + if [ -n "$c" ]; then + c="$branch_color$c$c_clear" + fi + b="$branch_color$b$c_clear" + + if [ -n "$w" ]; then + w="$bad_color$w$c_clear" + fi + if [ -n "$i" ]; then + i="$ok_color$i$c_clear" + fi + if [ -n "$s" ]; then + s="$flags_color$s$c_clear" + fi + if [ -n "$u" ]; then + u="$bad_color$u$c_clear" + fi +} + +# Helper function to read the first line of a file into a variable. +# __git_eread requires 2 arguments, the file path and the name of the +# variable, in that order. +__git_eread () +{ + test -r "$1" && IFS=$'\r\n' read "$2" <"$1" +} + +# see if a cherry-pick or revert is in progress, if the user has committed a +# conflict resolution with 'git commit' in the middle of a sequence of picks or +# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read +# the todo file. +__git_sequencer_status () +{ + local todo + if test -f "$g/CHERRY_PICK_HEAD" + then + r="|CHERRY-PICKING" + return 0; + elif test -f "$g/REVERT_HEAD" + then + r="|REVERTING" + return 0; + elif __git_eread "$g/sequencer/todo" todo + then + case "$todo" in + p[\ \ ]|pick[\ \ ]*) + r="|CHERRY-PICKING" + return 0 + ;; + revert[\ \ ]*) + r="|REVERTING" + return 0 + ;; + esac + fi + return 1 +} + +# __git_ps1 accepts 0 or 1 arguments (i.e., format string) +# when called from PS1 using command substitution +# in this mode it prints text to add to bash PS1 prompt (includes branch name) +# +# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc) +# in that case it _sets_ PS1. The arguments are parts of a PS1 string. +# when two arguments are given, the first is prepended and the second appended +# to the state string when assigned to PS1. +# The optional third parameter will be used as printf format string to further +# customize the output of the git-status string. +# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true +__git_ps1 () +{ + # preserve exit status + local exit=$? + local pcmode=no + local detached=no + local ps1pc_start='\u@\h:\w ' + local ps1pc_end='\$ ' + local printf_format=' (%s)' + + case "$#" in + 2|3) pcmode=yes + ps1pc_start="$1" + ps1pc_end="$2" + printf_format="${3:-$printf_format}" + # set PS1 to a plain prompt so that we can + # simply return early if the prompt should not + # be decorated + PS1="$ps1pc_start$ps1pc_end" + ;; + 0|1) printf_format="${1:-$printf_format}" + ;; + *) return $exit + ;; + esac + + # ps1_expanded: This variable is set to 'yes' if the shell + # subjects the value of PS1 to parameter expansion: + # + # * bash does unless the promptvars option is disabled + # * zsh does not unless the PROMPT_SUBST option is set + # * POSIX shells always do + # + # If the shell would expand the contents of PS1 when drawing + # the prompt, a raw ref name must not be included in PS1. + # This protects the user from arbitrary code execution via + # specially crafted ref names. For example, a ref named + # 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the + # shell to execute 'sudo rm -rf /' when the prompt is drawn. + # + # Instead, the ref name should be placed in a separate global + # variable (in the __git_ps1_* namespace to avoid colliding + # with the user's environment) and that variable should be + # referenced from PS1. For example: + # + # __git_ps1_foo=$(do_something_to_get_ref_name) + # PS1="...stuff...\${__git_ps1_foo}...stuff..." + # + # If the shell does not expand the contents of PS1, the raw + # ref name must be included in PS1. + # + # The value of this variable is only relevant when in pcmode. + # + # Assume that the shell follows the POSIX specification and + # expands PS1 unless determined otherwise. (This is more + # likely to be correct if the user has a non-bash, non-zsh + # shell and safer than the alternative if the assumption is + # incorrect.) + # + local ps1_expanded=yes + [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no + [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no + + local repo_info rev_parse_exit_code + repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ + --is-bare-repository --is-inside-work-tree \ + --short HEAD 2>/dev/null)" + rev_parse_exit_code="$?" + + if [ -z "$repo_info" ]; then + return $exit + fi + + local short_sha="" + if [ "$rev_parse_exit_code" = "0" ]; then + short_sha="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + fi + local inside_worktree="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + local bare_repo="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + local inside_gitdir="${repo_info##*$'\n'}" + local g="${repo_info%$'\n'*}" + + if [ "true" = "$inside_worktree" ] && + [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && + [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && + git check-ignore -q . + then + return $exit + fi + + local sparse="" + if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && + [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] && + [ "$(git config --bool core.sparseCheckout)" = "true" ]; then + sparse="|SPARSE" + fi + + local r="" + local b="" + local step="" + local total="" + if [ -d "$g/rebase-merge" ]; then + __git_eread "$g/rebase-merge/head-name" b + __git_eread "$g/rebase-merge/msgnum" step + __git_eread "$g/rebase-merge/end" total + r="|REBASE" + else + if [ -d "$g/rebase-apply" ]; then + __git_eread "$g/rebase-apply/next" step + __git_eread "$g/rebase-apply/last" total + if [ -f "$g/rebase-apply/rebasing" ]; then + __git_eread "$g/rebase-apply/head-name" b + r="|REBASE" + elif [ -f "$g/rebase-apply/applying" ]; then + r="|AM" + else + r="|AM/REBASE" + fi + elif [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + elif __git_sequencer_status; then + : + elif [ -f "$g/BISECT_LOG" ]; then + r="|BISECTING" + fi + + if [ -n "$b" ]; then + : + elif [ -h "$g/HEAD" ]; then + # symlink symbolic ref + b="$(git symbolic-ref HEAD 2>/dev/null)" + else + local head="" + if ! __git_eread "$g/HEAD" head; then + return $exit + fi + # is it a symbolic ref? + b="${head#ref: }" + if [ "$head" = "$b" ]; then + detached=yes + b="$( + case "${GIT_PS1_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (tag) + git describe --tags HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + b="$short_sha..." + b="($b)" + fi + fi + fi + + if [ -n "$step" ] && [ -n "$total" ]; then + r="$r $step/$total" + fi + + local w="" + local i="" + local s="" + local u="" + local h="" + local c="" + local p="" # short version of upstream state indicator + local upstream="" # verbose version of upstream state indicator + + if [ "true" = "$inside_gitdir" ]; then + if [ "true" = "$bare_repo" ]; then + c="BARE:" + else + b="GIT_DIR!" + fi + elif [ "true" = "$inside_worktree" ]; then + if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && + [ "$(git config --bool bash.showDirtyState)" != "false" ] + then + git diff --no-ext-diff --quiet || w="*" + git diff --no-ext-diff --cached --quiet || i="+" + if [ -z "$short_sha" ] && [ -z "$i" ]; then + i="#" + fi + fi + if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && + git rev-parse --verify --quiet refs/stash >/dev/null + then + s="$" + fi + + if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && + [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && + git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null + then + u="%${ZSH_VERSION+%}" + fi + + if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && + [ "$(git config --bool core.sparseCheckout)" = "true" ]; then + h="?" + fi + + if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then + __git_ps1_show_upstream + fi + fi + + local z="${GIT_PS1_STATESEPARATOR-" "}" + + b=${b##refs/heads/} + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then + __git_ps1_branch_name=$b + b="\${__git_ps1_branch_name}" + fi + + # NO color option unless in PROMPT_COMMAND mode or it's Zsh + if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then + if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then + __git_ps1_colorize_gitstring + fi + fi + + local f="$h$w$i$s$u$p" + local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" + + if [ $pcmode = yes ]; then + if [ "${__git_printf_supports_v-}" != yes ]; then + gitstring=$(printf -- "$printf_format" "$gitstring") + else + printf -v gitstring -- "$printf_format" "$gitstring" + fi + PS1="$ps1pc_start$gitstring$ps1pc_end" + else + printf -- "$printf_format" "$gitstring" + fi + + return $exit +} diff --git a/public/.infokey b/public/.infokey new file mode 100644 index 0000000..5ea8276 --- /dev/null +++ b/public/.infokey @@ -0,0 +1,36 @@ +#info +g first-node +G last-node +j next-line +k prev-line + +f scroll-forward-page-only +^f scroll-forward-page-only +b scroll-backward-page-only +^b scroll-backward-page-only + +\kd down-line +^e down-line +^j down-line +\ku up-line +^y up-line +^k up-line + +d scroll-half-screen-down +^d scroll-half-screen-down +u scroll-half-screen-up +^u scroll-half-screen-up + +n search-next +N search-previous + +^] select-reference-this-line +^o history-node # only backwards, cannot implement ^i + +h get-help-window + +^xn next-node +^xp prev-node +^xu up-node +^xt top-node +^xd dir-node diff --git a/public/.inputrc b/public/.inputrc new file mode 100644 index 0000000..f40f4a2 --- /dev/null +++ b/public/.inputrc @@ -0,0 +1,10 @@ +# Set up "vi input mode" in bash + +set editing-mode vi +$if mode=vi + +set keymap vi-command +Control-l: clear-screen + +set keymap vi-insert +Control-l: clear-screen diff --git a/public/.local/bin/README.txt b/public/.local/bin/README.txt new file mode 100644 index 0000000..280b362 --- /dev/null +++ b/public/.local/bin/README.txt @@ -0,0 +1,17 @@ +My Linux executable scripts. + +NOTES +* Beware of not leaking personal information + +I also use other people's awesome scrips. I store them in `~/code` and then +slink the ones I use in `~/.local/bin`. + +NOTATION +(notation is messed up, I'd be better if only used dashed prefixes) +* All scripts here should end in ".sh" +* `laptop-*` scripts might only work on my current machine +* `sb-*` scripts are meant to be called by dwmblocks +* `*_control` scripts are used in conjunction with xbindkeys(1) and `sb-*` + See also: + https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin/statusbar + https://github.com/LukeSmithxyz/dwmblocks/blob/master/config.h diff --git a/public/.local/bin/audio_control.sh b/public/.local/bin/audio_control.sh new file mode 100755 index 0000000..a257120 --- /dev/null +++ b/public/.local/bin/audio_control.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +delta=${2:-10} +signal=10 + +# signal dwmblocks to update volume block +send_signal() { + pkill -RTMIN+$signal dwmblocks +} + +# WIP: change default sink (speaker). E.g., when connecting HDMI. +change_sink() { + pactl list sinks | grep "Name:" + # Use tab completion if set up interactively + pactl "set-default-sink alsa_output.pci-0000_05_00.6.analog-stereo" +} + +case $1 in + inc) pactl set-sink-volume @DEFAULT_SINK@ +$delta% ;; + dec) pactl set-sink-volume @DEFAULT_SINK@ -$delta% ;; + micinc) pactl set-source-volume @DEFAULT_SOURCE@ +$delta% ;; + micdec) pactl set-source-volume @DEFAULT_SOURCE@ -$delta% ;; + mutetoggle) pactl set-sink-mute @DEFAULT_SINK@ toggle ;; + deafentoggle) pactl set-source-mute @DEFAULT_SOURCE@ toggle ;; + *) + echo Speaker: + pactl get-sink-volume @DEFAULT_SINK@ + pactl get-sink-mute @DEFAULT_SINK@ + echo -e "\nMic:" + pactl get-source-volume @DEFAULT_SOURCE@ + pactl get-source-mute @DEFAULT_SOURCE@ + echo -e "\nApplications:" + pactl list sink-inputs | grep -e 'Sink Input' -e 'application.name' -e 'Volume:' + ;; +esac + +send_signal diff --git a/public/.local/bin/brightness_control.sh b/public/.local/bin/brightness_control.sh new file mode 100755 index 0000000..13345d7 --- /dev/null +++ b/public/.local/bin/brightness_control.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +delta=${2:-10} +signal=11 + +# signal dwmblocks to update block +send_signal() { + pkill -RTMIN+$signal dwmblocks +} + +case $1 in + inc) xbacklight -inc $delta ;; + dec) xbacklight -dec $delta ;; + *) xbacklight -get ;; +esac + +send_signal diff --git a/public/.local/bin/build-latex.sh b/public/.local/bin/build-latex.sh new file mode 100755 index 0000000..7048246 --- /dev/null +++ b/public/.local/bin/build-latex.sh @@ -0,0 +1,21 @@ +# Build single latex file using xelatex + +if [ $# -ne 1 ]; then + echo "Usage: $(basename "$0") FILE" + exit 1 +fi + +cleanup() { + # cleanup of auxiliary files + rm -f *.aux *.fls *.fdb_latexmk + # rm *.log +} + +xelatex $1 || exit # Initial compilation +#bibtex # Bibliography tool +#xelatex $1 || exit # Incorporate bibliography changes +xelatex $1 || exit # Fix cross-references +#xelatex $1 || exit # 4th run just to be safe +cleanup +echo "## Mispelled words:" +pdftotext "${1%.tex}.pdf" - | hunspell -d en_US -i utf-8 -a | sort | uniq diff --git a/public/.local/bin/dmenu-webshortcuts.sh b/public/.local/bin/dmenu-webshortcuts.sh new file mode 100755 index 0000000..e1d233c --- /dev/null +++ b/public/.local/bin/dmenu-webshortcuts.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# Use dmenu and user-defined web shorcuts to query websites faster. +# +# This script tries to mimic Krunner Web Search Keywords functionality. +# See: https://userbase.kde.org/Plasma/Krunner#Browse_websites +# +# TODO: Integrate it to dmenu_run (so that this script doens't require a +# dedicated keybinding) +# +# Mitsuo +# 2023-11-23 + +input=$(echo "" | dmenu -p 'wp:Hello World') +## Set Internal Field Separator, save separated fields as an array in $CMD (-a), +## don't allow backslashes to escape any characters (-r). Feed $input as stdin. +#IFS=':' read -ra CMD <<< "$input" +#keyword=${CMD[0]} +#search_term=${CMD[1]} +keyword="${input%%:*}" +search_term="${input#*:}" + +# Define web shortcuts here +case "$keyword" in + # Search + "dd") xdg-open "https://duckduckgo.com/?t=h_&q=${search_term// /+}" ;; + "gg") xdg-open "https://www.google.com/search?q=$search_term" ;; + "bing") xdg-open "https://www.bing.com/search?q=${search_term// /+}" ;; + "metac") xdg-open "https://www.metacrawler.com/serp?q=${search_term// /+}" ;; + + # Finance + "ggf") xdg-open "https://www.google.com/finance/quote/$search_term?window=1Y" ;; + "yf") xdg-open "https://finance.yahoo.com/quote/$search_term" ;; + "bb") xdg-open "https://www.bloomberg.com/quote/$search_term" ;; + + # Maps + "ggm") xdg-open "https://www.google.com/maps/search/${search_term// /+}" ;; + "osm") xdg-open "https://www.openstreetmap.org/search?query=$search_term" ;; + + # Reference + "wp") xdg-open "https://en.wikipedia.org/wiki/${search_term// /_}" ;; + "wt") xdg-open "https://en.wiktionary.org/wiki/${search_term// /_}" ;; + "wv") xdg-open "https://en.wikivoyage.org/wiki/${search_term// /_}" ;; + "scholar") xdg-open "https://scholar.google.com/scholar?hl=en&q=${search_query// /+}" ;; + "arxiv") xdg-open "https://arxiv.org/search/?query=${search_query// /+}" ;; + + # Computer + "arch") xdg-open "https://wiki.archlinux.org/index.php?search=${search_term// /+}" ;; + "aur") xdg-open "https://aur.archlinux.org/packages?O=0&K=${search_term// /+}" ;; + "so") xdg-open "https://stackoverflow.com/search?q=${search_term// /+}" ;; + "gh") xdg-open "https://github.com/search?q=${search_term// /+}&type=repositories" ;; + "gl") xdg-open "https://about.gitlab.com/search?searchText=$search_term" ;; + "pypi") xdg-open "https://pypi.org/search/?q=${search_term// /+}&o=" ;; + "npm") xdg-open "https://www.npmjs.com/search?q=${search_term// /+}" ;; + + # Media + "yt") xdg-open "https://www.youtube.com/results?search_query=$search_term" ;; + "vm") xdg-open "https://vimeo.com/search?q=$search_term" ;; + "sp") xdg-open "https://open.spotify.com/search/$search_term" ;; + "sc") xdg-open "https://soundcloud.com/search?q=$search_term" ;; + "dz") xdg-open "https://www.deezer.com/search/$search_term" ;; + "imdb") xdg-open "https://www.imdb.com/find/?q=$search_term" ;; + + # Social Media + "x") xdg-open "https://x.com/search?q=$search_term&src=typed_query" ;; + "rd") xdg-open "https://duckduckgo.com/?t=h_&q=site%3Areddit.com+${search_term// /+}&ia=web" ;; + "ig") xdg-open "https://duckduckgo.com/?q=site%3Ainstagram.com+${search_term// /+}&ia=web" ;; + "fb") xdg-open "https://duckduckgo.com/?q=site%3Afacebook.com+${search_term// /+}&ia=web" ;; + + # Shopping + "amzn") xdg-open "https://www.amazon.com/s?k=${search_term// /+}" ;; + "amznjp") xdg-open "https://www.amazon.co.jp/s?k=${search_term// /+}" ;; + "ebay") xdg-open "https://www.ebay.com/sch/i.html?_nkw=${search_term// /+}" ;; + + # Utilities + "ggt") xdg-open "https://translate.google.com/?sl=auto&tl=en&text=$search_term&op=translate" ;; + "en2es") xdg-open "https://www.wordreference.com/es/translation.asp?tranword=$search_term" ;; + "es2en") xdg-open "https://www.wordreference.com/es/en/translation.asp?spen=$search_term" ;; + "en2de") xdg-open "https://www.wordreference.com/es/en/translation.asp?spen=$search_term" ;; + "de2en") xdg-open "https://www.wordreference.com/deen/$search_term" ;; + "jisho") xdg-open "https://jisho.org/search/$search_term" ;; + "rae") xdg-open "https://dle.rae.es/?w=$search_term" ;; + + # Mitsuo + "pw") xdg-open "http://wiki.pulse15/index.php?search=${search_term// /+}" ;; + "factorio") xdg-open "https://wiki.factorio.com/${search_term// /_}" ;; + "dst") xdg-open "https://dontstarve.wiki.gg/wiki/${search_term// /_}" ;; + "mc") xdg-open "https://minecraft.wiki/w/${search_term// /_}" ;; + "terraria") xdg-open "https://terraria.wiki.gg/wiki/${search_term// /_}" ;; + + *) exit 1 ;; +esac + diff --git a/public/.local/bin/input_control.sh b/public/.local/bin/input_control.sh new file mode 100755 index 0000000..f63de3b --- /dev/null +++ b/public/.local/bin/input_control.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Use either X keyboard extension layouts (setxkbmap), or fcitx (or both). +# +# At first I configured this to use setxkbmap, it works fine. +# +# fcitx already provides keybindings, but I wanted to display +# the current input method in dwmblocks immediatly. So I'm +# adding such support through fcitx5-remote. + +signal=20 + +# signal dwmblocks to update block +send_signal() { + pkill -RTMIN+$signal dwmblocks +} + +# Cycle X keyboard extension layouts +cycle_layouts() { + layouts=(us latam) # X keyboard extension + STATE_FILE="$XDG_STATE_HOME/keyboard_layout_state" + + if [ -f "$STATE_FILE" ]; then + index=$(cat "$STATE_FILE") + else + index=0 + fi + next_index=$(( (index + 1) % ${#layouts[@]} )) + echo $next_index > "$STATE_FILE" + + setxkbmap ${layouts[$index]} +} + +fcitx_control() { + # For this to correctly reflect the state of the system "Share Input State" + # should be set to "All" in fcitx5-configtool. + + case $1 in + en) + fcitx5-remote -c # Closed + fcitx5-remote -g Default + ;; + es) + fcitx5-remote -c # Closed + fcitx5-remote -g Spanish + ;; + ja) + fcitx5-remote -g Default + fcitx5-remote -o # Open + ;; + *) + fcitx5-remote -q # + fcitx5-remote -n + fcitx5-remote + ;; + esac +} + +#cycle_layouts +fcitx_control $1 + +send_signal diff --git a/public/.local/bin/laptop-backup.sh b/public/.local/bin/laptop-backup.sh new file mode 100755 index 0000000..a22c179 --- /dev/null +++ b/public/.local/bin/laptop-backup.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Fast backup using rsync + +if [ $# -ne 2 ]; then + echo "Usage: $(basename "$0") /dev/sdX backup" + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root." + exit 1 +fi + +rsync_options="-auvP --delete" +device=$1 +name=$2 + +# Note: `name` (nor `device`) should not contain spaces + +cryptsetup open --type luks $device $name +if [ $? -ne 0 ]; then + # bad device + exit 1 +fi +mount /dev/mapper/$name /mnt/$name +# TODO: stop backing up /var. Backup is just for Postgres and Mediawiki. +# `/var` is used by too many applications. Specialy pacman that clutters it +# with cached binaries. +rsync $rsync_options /var /mnt/$name # <10G +rsync $rsync_options /home /mnt/$name # <900G +rsync $rsync_options /etc /mnt/$name # <20M +echo "Backup complete." +df -h #| grep -E "${name}|var|home|etc" +umount /mnt/$name +cryptsetup close $name + +echo "All done. Check \`$ lsblk\` before unplugging the storage device." diff --git a/public/.local/bin/laptop-xinput_setup.sh b/public/.local/bin/laptop-xinput_setup.sh new file mode 100755 index 0000000..e471869 --- /dev/null +++ b/public/.local/bin/laptop-xinput_setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# See https://wiki.archlinux.org/title/Libinput + +#xinput list +#xinput list-props + +pulse15() { + xinput set-prop "UNIW0001:00 093A:0255 Touchpad" "libinput Tapping Enabled" 1 + #xinput set-prop "UNIW0001:00 093A:0255 Touchpad" "libinput Tapping Enabled Default" 1 +} + +pulse15 diff --git a/public/.local/bin/laptop-xrandr.sh b/public/.local/bin/laptop-xrandr.sh new file mode 100755 index 0000000..cbe9479 --- /dev/null +++ b/public/.local/bin/laptop-xrandr.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# See https://wiki.archlinux.org/title/Multihead + +# Didn't know how to get the screen name, this works for now +#screen=$(xrandr | grep "primary" | awk '{ print $1 }') +# But now how do I get the rest? And the correct order? Maybe it's better just +# to define "hardcoded" functions and just call them. + +simple_2_monitor() { + # enable + xrandr --output eDP --auto \ + --output HDMI-A-0 --auto --left-of eDP + # disable + xrandr --output eDP --auto \ + --output HDMI-A-0 --off +} + +# Thank you: https://www.maketecheasier.com/how-to-setup-dual-monitors-with-xrandr/ +# xrandr --auto --output HDMI-A-0 --mode 1920x1080 --right-of eDP + +#simple_2_monitor +xrandr --auto --output HDMI-A-0 --mode 1920x1080 --right-of eDP diff --git a/public/.local/bin/lp1-unzip_deletebinaries_zip.sh b/public/.local/bin/lp1-unzip_deletebinaries_zip.sh new file mode 100755 index 0000000..3fa4afb --- /dev/null +++ b/public/.local/bin/lp1-unzip_deletebinaries_zip.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Script for LP1 labs that are uploaded to Google Drive with binaries and +# that causes problems with Google Drive's automatic virus scan. + +# unzip +for f in *.zip; do unzip -q "$f"; done + +# delete build/ and dist/ directories (virus detection in Google Drive) +find . -type d -regex '^.*/\(dist\|build\)$' -print0 | xargs -0 rm -r + +# zip +rm *.zip # remove old zip files +for d in */; do + dirname="${d%/}" + zip -qr "$dirname.zip" "$d" +done + +# dos2unix (for me) +find . -type f -iregex ".*\.\(csv\|cpp\|h\|hpp\)" -print0 | xargs -0 dos2unix diff --git a/public/.local/bin/myfile-handler.sh b/public/.local/bin/myfile-handler.sh new file mode 100755 index 0000000..40360b8 --- /dev/null +++ b/public/.local/bin/myfile-handler.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# A script to handle custom protocol +url="$1" + +file_path="${url#myfile://}" +file_path="${file_path/\~/$HOME}" +xdg-open "$file_path" diff --git a/public/.local/bin/network_control.sh b/public/.local/bin/network_control.sh new file mode 100755 index 0000000..4dc4b38 --- /dev/null +++ b/public/.local/bin/network_control.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +signal=30 + +# signal dwmblocks to update network block +send_signal() { + pkill -RTMIN+$signal dwmblocks +} + +toggle_wifi() { + status=$(nmcli radio wifi) + + if [ "$status" = "enabled" ]; then + nmcli radio wifi off + else + nmcli radio wifi on + fi +} + +# This one is hard because it requires root, and the VPN interface name +# 2 ways to toggle, using systemctl, or wg-quick(1) +# This one might be better controled through a `dmenu` script. +toggle_vpn() { + : +} + +toggle_network_quarantine() { + # Check the status of all wireless devices + if rfkill list | grep -q "Soft blocked: no"; then + # not all blocked + rfkill block all + else + # all blocked + rfkill unblock all + fi +} + +# WIP +toggle_bluetooth() { + : +} + +case $1 in + wifitoggle) toggle_wifi ;; + vpntoggle) toggle_vpn ;; + bluetoothtoggle) toggle_bluetooth ;; + isolatetoggle) toggle_network_quarantine ;; + *) + echo "invalid option :)" + ;; +esac + +send_signal diff --git a/public/.local/bin/ocrthis.sh b/public/.local/bin/ocrthis.sh new file mode 100755 index 0000000..3010a6a --- /dev/null +++ b/public/.local/bin/ocrthis.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Creates and OCR PDF out of an image +# (OCR limited to printed characters (handwriting or photograph OCR is bad, if +# any) +# +# Alternatively use `tesseract FILE text` + +if [ $# -ne 1 ]; then + echo "Usage: $(basename "$0") input_file" + # (there is `basename` and `dirname`) + exit 1 +fi + +b="$(basename "$1")" +convert "$1" "${b}.pdf" +# TODO: some contrast enhancement step would help. If text has low contrast +# with background (e.g., blue on black, green on black), then OCR fails. +ocrmypdf "${b}.pdf" "${b}.ocr.pdf" +mv -f "${b}.ocr.pdf" "${b}.pdf" diff --git a/public/.local/bin/rename_pictures.sh b/public/.local/bin/rename_pictures.sh new file mode 100755 index 0000000..a3f2463 --- /dev/null +++ b/public/.local/bin/rename_pictures.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Very specific script to bulk rename pictures with some format +# (complex script for a simple task) + +exit # just in case + +shopt -s nullglob +for file in ss_*.png; do + date_part="${file:3:8}" + time_part="${file:12:6}" + new_name="ss-${date_part}T${time_part}0500.png" + + mv "$file" "$new_name" +done +shopt -u nullglob diff --git a/public/.local/bin/sb-audio b/public/.local/bin/sb-audio new file mode 100755 index 0000000..87ce7d7 --- /dev/null +++ b/public/.local/bin/sb-audio @@ -0,0 +1,35 @@ +#!/bin/sh + +# Prints the current volume and 🔇 if muted. + +case $BLOCK_BUTTON in + 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; + 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; + 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; + 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +#vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" + +vol="$(pactl get-sink-volume @DEFAULT_SINK@ | awk '/Volume/ { gsub(/%/,"",$5); print $5 }')" +micvol="$(pactl get-source-volume @DEFAULT_SOURCE@ | awk '/Volume/ { gsub(/%/,"",$5); print $5 }')" + +case 1 in + $((vol >= 70)) ) icon="🔊" ;; + $((vol >= 30)) ) icon="🔉" ;; + * ) icon="🔈" ;; +esac + +if pactl get-sink-mute @DEFAULT_SINK@ | grep -q yes; then + icon="🔇" +fi + +if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q no; then + icon="🎤$micvol%"$icon +fi + +echo "$icon$vol%" diff --git a/public/.local/bin/sb-battery b/public/.local/bin/sb-battery new file mode 100755 index 0000000..93cbe08 --- /dev/null +++ b/public/.local/bin/sb-battery @@ -0,0 +1,37 @@ +#!/bin/sh + +# Prints all batteries, their percentage remaining and an emoji corresponding +# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). + +case $BLOCK_BUTTON in + 3) notify-send "🔋 Battery module" "🔋: discharging +🛑: not charging +♻: stagnant charge +🔌: charging +⚡: charged +❗: battery very low! +- Scroll to change adjust xbacklight." ;; + 4) xbacklight -inc 10 ;; + 5) xbacklight -dec 10 ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# Loop through all attached batteries and format the info +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " + # Sets up the status and capacity + case "$(cat "$battery/status" 2>&1)" in + "Full") status="⚡" ;; + "Discharging") status="🔋" ;; + "Charging") status="🔌" ;; + "Not charging") status="🛑" ;; + "Unknown") status="♻️" ;; + *) exit 1 ;; + esac + capacity="$(cat "$battery/capacity" 2>&1)" + # Will make a warn variable if discharging and low + [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" + # Prints the info + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +done && printf "\\n" diff --git a/public/.local/bin/sb-input b/public/.local/bin/sb-input new file mode 100755 index 0000000..4fb1575 --- /dev/null +++ b/public/.local/bin/sb-input @@ -0,0 +1,9 @@ +#!/bin/bash + +icon="🌐" +layout="$(setxkbmap -query | grep layout | awk '{print $2}')" + +# fcitx state, 0 for close, 1 for inactive, 2 for active +test $(fcitx5-remote) = 2 && layout="日本語" + +echo $icon$layout diff --git a/public/.local/bin/sb-network b/public/.local/bin/sb-network new file mode 100755 index 0000000..0bdbe82 --- /dev/null +++ b/public/.local/bin/sb-network @@ -0,0 +1,52 @@ +#!/bin/sh + +# Prints some network connectivity status in emoji + +case $BLOCK_BUTTON in + 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; + 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; + 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; + 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + + +set_wlan() { + nmcli_status=$(nmcli -t -f TYPE,STATE connection show --active) + wifi=$(echo $nmcli_status | grep -q "802-11-wireless:activated" && echo "📶") + vpn=$(echo $nmcli_status | grep -q "wireguard:activated" && echo "🔒") + wlan="$wifi$vpn" +} + + +set_bt() { + # If bluetooth is on, show number of connected devices and their initials + if ! bluetoothctl show | grep -q "Powered: yes"; then return; fi + ds=$(bluetoothctl devices Connected | cut -d ' ' -f 3-) + if [ -z "$ds" ]; then + bt=$(echo "🦷") + return + fi + N=$(echo "$ds" | wc -l) + ds=$(echo "$ds" | cut -c 1-3 | paste -sd ",") + bt=$(echo "🦷$N:$ds") +} + + +check_network_quarantine() { + # If all wireless devices are (software) blocked, + # change status bar icon and exit + if ! rfkill list | grep -q "Soft blocked: no"; then + echo "🗿" + exit + fi +} + + +check_network_quarantine +set_wlan +set_bt +echo "$wlan$bt" diff --git a/public/.local/bin/scan_loop.sh b/public/.local/bin/scan_loop.sh new file mode 100755 index 0000000..722e63d --- /dev/null +++ b/public/.local/bin/scan_loop.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# The scan loop is useful when Automatic Document Feeder (ADF) can't be used + +scan_device_uri="hpaio:/net/OfficeJet_Pro_6970?ip=192.168.18.21" +# ^This HP printer is remarkable. It's been working fine since 2017. I refill +# the cardridge with UV ink very easily (I've never purchased ink cardridges +# other than the ones that came with the printer). As of 2023, only the Cyan +# and Black cardridges/inkjets work but Black&White print is all I need. +# And the Linux support and CLI interface is amazing. + + +# Automatic Document Feeder +adf() { + hp-scan --mode=color --resolution=300 --size=a4 --adf #--duplex +} + + +# Scans until terminated with ^C. Saves .png files on CWD. +flatbed_loop() { + echo "Warning: scan loop will run until terminated with Ctrl-C" + i=0 + while true; do + # device show with $ hp-info + hp-scan --mode=color --size=a4 --device=$scan_device_uri + echo "page " $((i + 1)) " done, you have 4 seconds to load next page" + sleep 4 + i=$((expr $i + 1)) + done + # convert *.png output.pdf +} + +flatbed_loop diff --git a/public/.local/bin/screenshot.sh b/public/.local/bin/screenshot.sh new file mode 100755 index 0000000..be4a8f9 --- /dev/null +++ b/public/.local/bin/screenshot.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Takes a screenshot and saves it + +# Inspired by Denshi's screenshot script (https://git.denshi.org/Scripts/tree/screenshot). +# See also https://www.youtube.com/watch?v=uYNTFg3_QaY&t=243s + +savepath="$HOME/media/Pictures/Screenshots" +filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" + +if [ "$1" == "screen" ]; then + # capture the screen determined by the cursor location + shotgun -s "$savepath/$filename" +elif [ "$1" == "screens" ]; then + # TODO: This is not currently possible with shotgun 2.5.1 + : +else + # capture a region of the screen + shotgun -g $(hacksaw) "$savepath/$filename" +fi + diff --git a/public/.local/bin/screenshot_ocr.sh b/public/.local/bin/screenshot_ocr.sh new file mode 100755 index 0000000..d88accf --- /dev/null +++ b/public/.local/bin/screenshot_ocr.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Select a region of the screen and perform OCR to it. Save text in clipboard. + +savepath="/tmp/screenshot_ocr.sh.d" +filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" +# German: deu, Spanish: spa, Japanese vertical: jpn_vert +tesseract_options="-l eng+jpn" + +_init() { + if [ ! -d "$savepath" ]; then + mkdir -p "$savepath" + fi + cd "$savepath" +} + +_init +# Screenshot region of screen +shotgun -g $(hacksaw) "$filename" +# Exit if previous command was unsuccessful +test $? -ne 0 && exit +# Try to scan codes from the image +zbarimg $filename | xclip -selection "clipboard" +# Perform OCR and save to clipboard +tesseract $tesseract_options $filename - | xclip -selection "clipboard" +rm $filename + +# TODO: clean japanese output. If text is 80% japanese characters, then it +# should not contain spaces around the characters. diff --git a/public/.local/bin/setbg.sh b/public/.local/bin/setbg.sh new file mode 100755 index 0000000..78cdb2d --- /dev/null +++ b/public/.local/bin/setbg.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Sets the background (Suckless setup) + +bgfile="$HOME/media/Pictures/Wallpapers/landscapes/japan/Lake_Kawaguchiko_Sakura_Mount_Fuji_3.jpg" +bgfile2="$HOME/media/Pictures/Wallpapers/mine/IMG_20200706_190712.jpg" + +xwallpaper --output eDP --zoom "$bgfile" +xwallpaper --output HDMI-A-0 --zoom "$bgfile2" diff --git a/public/.local/bin/setup_default_apps.sh b/public/.local/bin/setup_default_apps.sh new file mode 100755 index 0000000..9c58b95 --- /dev/null +++ b/public/.local/bin/setup_default_apps.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Set defaults for xdg-open +# +# For a list of MIME types see https://www.iana.org/assignments/media-types/media-types.xhtml + +# Useful commands: +# xdg-mime query filetype FILE +# xdg-mime query default MIMETYPE + +# File +#pcmanfm + +# Image +xdg-mime default nsxiv.desktop image/bmp image/gif image/jpeg image/jpg image/png image/tiff image/x-bmp image/x-portable-anymap image/x-portable-bitmap image/x-portable-graymap image/x-tga image/x-xpixmap image/webp image/heic image/svg+xml application/postscript image/jp2 image/jxl image/avif image/heif + +# Video +#xdg-mime default mpv.desktop A_LOT_OF_MIME_TYPES + +# Mail +#thunderbird + +# Office +xdg-mime default org.pwmt.zathura.desktop application/pdf application/postscript image/vnd.djvu application/epub+zip +#libreoffice + +# Text +xdg-mime default nvim.desktop text/plain + +# Net +xdg-mime default org.qbittorrent.qBittorrent.desktop application/x-bittorrent x-scheme-handler/magnet diff --git a/public/.local/bin/updatewebsite.sh b/public/.local/bin/updatewebsite.sh new file mode 100755 index 0000000..71c99b2 --- /dev/null +++ b/public/.local/bin/updatewebsite.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# This script syncs local files to my VPS + +# Thank you: https://unix.stackexchange.com/a/2503/347754 +options="-uvrPs --delete-after --copy-links" +targetdir="tokumori.xyz:/var/www" + +rsync $options /home/mitsuo/mahcode/www/tokumori.xyz $targetdir diff --git a/public/.profile b/public/.profile new file mode 100644 index 0000000..956694c --- /dev/null +++ b/public/.profile @@ -0,0 +1,12 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if bash +if [ "$SHELL" = "/bin/bash" ]; then + . ~/.bashrc +fi diff --git a/public/.vim/fun.vim b/public/.vim/fun.vim new file mode 100644 index 0000000..bd911f9 --- /dev/null +++ b/public/.vim/fun.vim @@ -0,0 +1,89 @@ +" Echoes longest line number and lenght. +function! LongestLineLength ( ) + let maxlength = 0 + let linenumber= 1 + while linenumber <= line("$") + exe ":".linenumber + let linelength = virtcol("$") + if maxlength < linelength + let maxlength = linelength + let maxlinenumber = linenumber + endif + let linenumber = linenumber+1 + endwhile + +"exe ':0' +"exe 'normal O' +"exe 'normal 0C'.maxlength + exe "normal" . maxlinenumber . "G" + exe ":echo \"" . maxlinenumber . ": " . maxlength . "\"" +endfunction + +command LongestLineLength call LongestLineLength() + + +" Save markdown document and export to pdf using pandoc. +" +" It would be nicer if a default document would be used but I coulnd't made it +" to work even after reading that manual section like 2 times. Also, there are +" variables that are lists of other variables that I don't know how to make them +" work (e.g. geometry=[top=1in, bottom=1in, heightrounded]) +function! Md2Pdf ( ) + exe ":w" + "-N for numbered headers + exe ":! pandoc -o \"" . expand("%:r") . ".pdf\" -t latex --variable classoption=twosides --variable papersize=a4 --variable margin-left=1in --variable margin-right=1in --variable margin-top=1in --variable margin-bottom=1in --variable links-as-notes --variable colorlinks --variable pagestyle=plain --variable documentclass=article -f markdown-implicit_figures \"" . expand("%") . "\"" + echo "pdf saved as \"" . expand("%:p:r") . ".pdf\"" +endfunction + +function! Md2Pdfms ( ) + exe ":w" + exe ":! pandoc -o " . expand("%:r") . ".pdf" . " -t ms -f markdown-implicit_figures \"" . expand("%") . "\"" + echo "pdf saved as " . expand("%:p:r") . ".pdf" +endfunction + +command Md2Pdf call Md2Pdf() +command Md2Pdfms call Md2Pdfms() + + +" Save markdown document and export to html using pandoc +function! Md2Html ( ) + exe ":w" + "exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\"" + exe ":! pandoc --highlight-style tango -o \"" . expand("%:r") . ".html\"" . " \"" . expand("%") . "\"" + echo "html saved as " . expand("%:p:r") . ".html" +endfunction + +command Md2Html call Md2Html() + +" Save markdown as ODT file (.docx is also possible) +function! Md2Odt ( ) + exe ":w" + exe ":! pandoc -s --toc -H ~/mahcode/markdown/pandoc/pandoc_style.html --highlight-style tango -o \"" . expand("%:r") . ".odt\"" . " \"" . expand("%") . "\"" + echo "ODT saved as " . expand("%:p:r") . ".odt" +endfunction + +command Md2Odt call Md2Odt() + + +" Compiles and Runs a C++ project +" TODO: how to add program's arguments or file redirectioning from command. +function! CompRunProj ( ) + exe ":w" + exe ":! g++ -o " . expand("%:r") . "-g *.cpp" + exe ":! ./" . expand("%:r") +endfunction + +command CompRunProj call CompRunProj() + + +" Function made to give feedback to students code in 1INF01 +" export C code to syntax highlighted pdf +function! C2Pdf ( ) + exe ":set ts=4" + exe ":w" + exe ":ha > %.ps" + exe ":!ps2pdf %.ps" + exe ":!rm %.ps" +endfunction + +command C2Pdf call C2Pdf() diff --git a/public/.vim/pack/mitsuo/README.md b/public/.vim/pack/mitsuo/README.md new file mode 100644 index 0000000..172c269 --- /dev/null +++ b/public/.vim/pack/mitsuo/README.md @@ -0,0 +1,12 @@ +Plugins I usually use and work fine together. + +- [NERDTree](https://github.com/preservim/nerdtree) + + <C-t> + +- [vim-fugitive](https://github.com/tpope/vim-fugitive) + + :G + :G blame + +Vim packages (version >= 8.2). See `:h packages` diff --git a/public/.vim/pack/mitsuo/nerdtree b/public/.vim/pack/mitsuo/nerdtree new file mode 160000 +Subproject eed488b1cd1867bd25f19f90e10440c5cc7d642 diff --git a/public/.vim/pack/mitsuo/vim-fugitive b/public/.vim/pack/mitsuo/vim-fugitive new file mode 160000 +Subproject b7287bd5421da62986d9abf9131509b2c9f918e diff --git a/public/.vim/viminfo b/public/.vim/viminfo new file mode 100644 index 0000000..7651f85 --- /dev/null +++ b/public/.vim/viminfo @@ -0,0 +1,31 @@ +# This viminfo file was generated by Vim 8.2. +# You may edit it if you're careful! + +# Viminfo version +|1,4 + +# Value of 'encoding' when this file was written +*encoding=utf-8 + + +# hlsearch on (H) or off (h): +~h +# Command Line History (newest to oldest): +:q +|2,0,1649356827,,"q" + +# Search String History (newest to oldest): + +# Expression History (newest to oldest): + +# Input Line History (newest to oldest): + +# Debug Line History (newest to oldest): + +# Registers: + +# File marks: + +# Jumplist (newest first): + +# History of marks within files (newest to oldest): diff --git a/public/.vim/vimrc b/public/.vim/vimrc new file mode 100644 index 0000000..f97a654 --- /dev/null +++ b/public/.vim/vimrc @@ -0,0 +1,332 @@ +" mitsuo's vimrc +" Created c. 2019-11-11 +" Last update (after destroying it accidentally): 2020-09-02 +" +" ┌─┬─┬─┬─┬─┬─┐ +" │m│i│t│s│u│o│✓x け が +" ├─┼─┼─┼─┼─┼─┤ ん +" │v│i│m│r│c│←│█▓▒░ り ば +" └─┴─┴─┴─┴─┴─┘ こ れ + +" XDG compliant REMOVED :D (what a pain) +" - For new installs just copy (or link) this file into ~/.vimrc and create +" the ~/.vim directory +" TODO: - sort sections + + +" Variables +" ---------------------------------------------------------------------- +" Get the first directory from the list in $VIMRUNTIMEPATH +let $VIMFILES=split(&rtp,",")[0] +set undodir=$VIMFILES/undo +set viewdir=$VIMFILES/view +set directory=$VIMFILES/swap +set viminfofile=$VIMFILES/viminfo + + +" Useful +" ---------------------------------------------------------------------- +set nocompatible +" Auto-recognize files and apply pluggins +filetype plugin indent on " See :h vimrc-filetype +syntax on + +" Search files +set wildmenu " command-line <Tab> completion <-- soo good +set wildignore+=*.o,*.obj,.git,*.rbc,*.class +set path+=./**30 " For gf and :find, add all subdirectories relative to + " current file (30 max) to the "search space" + +set scrolloff=5 " show a few lines of context + +set backspace=indent,eol,start " Allow <BS> and <Del> in insert mode + +" number gutter +set nonumber +set norelativenumber + +" Store session information +set viminfo+='1000 + +" Tag Jumping <-- so cool +" Instructions: create tag index (e.g. $ ctags -R .) +" place cursor on tag +" ^] to jump to definition +" g^] if more than 1 definition +" ^T to return (or ^O) +" TODO: create tags automatically (:!ctags -R . after :w if ft=c) + + +" Status line +" ---------------------------------------------------------------------- +set showcmd " show partial command on last line (below status bar) +" just add buffer number to the default +set statusline=%<%f\ %h%m%r%=b%02n\ \ %-14.(%l,%c%V%)\ %P + + +" Search +" ---------------------------------------------------------------------- +set hlsearch " highlight search (this can be annoying if no shortcut to then + " clear the highlight +set incsearch " Incrementally move cursor while typing search-string +" stop highlight only for current search. +" (Still preserve <C-L> updating directory in netrw) +nnoremap <C-L> :nohl<CR><C-L> +" Ignore case only when pattern is lowercase (both needed) +set ignorecase +set smartcase + + +" Indentation +" ---------------------------------------------------------------------- +" 4 column softtabs (uses ' ', not '\t'). +" TODO: move this 'guide' to somewhere apropiate +" tab->softtab :set tabstop=n :set expandtab :retab +" softtab->tab :set noexpandtab :set tabstop={softtabstop} :retab! +" Caution: +" - This will insert a tab wherever it can, even between words +" separated by as few as 2 spaces if ts=2! +" - Not recommended at all. Use some other program to only translate +" leading indenting from space to tabs. Also using tabs is not very +" good. My opinion is that they are good as a special character to +" separate data (like comma for CSV). +set tabstop=8 " '\t' or HT = 8 virtual columns +set shiftwidth=4 " Indentation with >> and C-T and C-D (insert mode) +set softtabstop=4 " For "inserted tabs" (inserts <Space> and <Tab> + " minimizing <Space>) +set expandtab " Expand with <Space> the inserted <Tab>s +"set smarttab " Use shiftwidth for inserted <Tabs> in the front of + " a line (Maybe useful for YAML) +" autoindent -> smartindent -> cindent -> indentexpr +" (from simple/less general to complex/more general) +set smartindent " This is a really nice and simple one +"set cindent +"set cinoptions=:0,g0 " See C-indenting + + +" Automatic formatting +" ---------------------------------------------------------------------- +" see fo-table +set formatoptions=l " Don't break long lines that are already typed +set formatoptions+=q " Allow formatting of comments with "gq" +set formatoptions+=r " Insert current leader after <Enter> in Insert mode +set formatoptions-=o " Automatically insert the current comment leader + " after hitting 'o'. +set formatoptions+=t " auto-wrap text (when inserting) +set formatoptions+=c " auto-wrap comments (when inserting) +set formatoptions+=p " Don't break honorifics like Prof. Smith +set formatoptions+=n " Allow lists +set formatoptions+=j " Removes comment leader when joining lines + + +" Word wrap +" ---------------------------------------------------------------------- +set wrap " Visual wrapping of lines wider than window +set linebreak " Works with previous option to not break words +" To 'justify' comments or block of text (paragraph) use "gq{motion}" or +" "gp{motion}", where {motion} can be "[/", "]/", "ip", "i{", "a{". +set textwidth=80 " auto break inserted text longer than 80 colums + + +" Other settings +" ---------------------------------------------------------------------- +set mouse=a " Enable for all modes +" set cmdheight=1 +" Always display the status line, even if only one window is displayed +set laststatus=2 +set ruler +set encoding=utf-8 +set more " Enable more-prompt for listings that don't fit in + " screen +"hint: g< command can be used to see the last page of previous command. + + +" Mappings +" ---------------------------------------------------------------------- +" F1 is help, F11 is full screen (terminal emulator) +map <F5> :source $VIMFILES/vimrc<CR> +map <S-F5> :e $VIMFILES/vimrc<CR> + +map <F7> :tabp<CR> +map <F8> :tabn<CR> + +" C/C++ Programming: + +map <F6> :w<CR>:!clear && make<CR> +"map <F10> :!./%:r<CR> +"map <F10> :!./a.out<CR> + +map <F11> :cnext<CR> +map <S-F11> :cprev<CR> + +" <Leader> = '\' when 'mapleader' is empty +" "Run cTags" +map <Leader>rt :!ctags -R .<CR> +map <C-\> :tnext<CR> + +" Motion to go to beggining of function while cursor is inside +nmap [f [m[{k0 + +" Other programs: + +" pandoc (& website) +nnoremap mm :w<CR>:Md2Html<CR><CR><CR> +nmap mM mm:!updatewebsite_zaz<CR><CR> +" asciidoc +nnoremap ma :w<CR>:!asciidoctor %<CR><CR> +nmap mA ma:!updatewebsite_zaz<CR><CR> + +" Funcionallity of the following depends on terminal. Needs 8bit input enabled +" for <Meta> = Alt key combos +" From: https://vim.fandom.com/wiki/Get_Alt_key_to_work_in_terminal + +nmap <M-H> <C-W>h +nmap <M-J> <C-W>j +nmap <M-K> <C-W>k +nmap <M-L> <C-W>l + +" Misc.: + +" Go Title Case (and clear highlighted matches) +" Ref.: vim.fandom.com +vmap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR><C-L> + +" Autoformat JSON jumbled data. (Selects the whole file as range to pass as +" standard input to `jq .` which pretty prints JSON. Then replace range with +" output.) +" Ref.: https://stackoverflow.com/questions/26214156/how-to-auto-format-json-on-save-in-vim +nnoremap gJ :%!python3 -m json.tool<CR> +" :%!jq . + +" NERDTree plugin +nnoremap <C-t> :NERDTreeToggle<CR> + +" Comment/UnComment lines +" Ref.: +" - https://vim.fandom.com/wiki/Comment/UnComment_visually_selected_text +" - https://stackoverflow.com/a/1676672/7498073 +" - https://stackoverflow.com/a/9051932/7498073 +au FileType haskell,vhdl,ada let b:comment_leader = '-- ' +au FileType vim let b:comment_leader = '" ' +au FileType c,cpp,java,asciidoc let b:comment_leader = '// ' +au FileType sh,make let b:comment_leader = '# ' +au FileType tex let b:comment_leader = '% ' +" That c_CTRL-R_= thingy enters the "expression register". And that \V +" tells :s to go into "Very NonMagic" mode. +noremap ,c :s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:noh<CR> +noremap ,u :s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:noh<CR> + + +" Yanking and pasting +" ---------------------------------------------------------------------- +" TODO: map something to "+y (cut buffer) and "*y (selection buffer) while in +" visual mode. +"vmap <++> "+y " The yank to the cut buffer (clipboard) +"vmap <++> "*y " The yank to the selection buffer + + +" Buffers +" ---------------------------------------------------------------------- +set hidden +map <S-F7> :bNext<LF> +map <S-F8> :bnext<LF> + + +" Printing +" ---------------------------------------------------------------------- +set printoptions=paper:A4,duplex:long +" set printoptions+=number:y +" TODO: Figure out how to print multibyte encodings. Enabling this settings +" produces errors. +set encoding=utf-8 +set fileencoding=utf-8 +" set printmbcharset=JIS_X_1990 " This allows Japanese characters to be printed +" set printmbfont=r:Noto-Sans-CJK-JP + + +" Functions +" ---------------------------------------------------------------------- +" TODO: maybe replace with $runtimepath +source $VIMFILES/fun.vim + + +" Views and Sessions (Window layout and Line folding) +" ---------------------------------------------------------------------- +" It is possible to create folds automatically but idk how to do it. +" :mkview so save them :loadview to load them (zo open one, zc close one, +" zR to open all, zM to close all, zx to restore)) + +" Views saves folds. Sessions saves all windows configuration and layout +" Load Sessions with $ vim -S Session.vim + +" To automatically save and restore views for *.c *.cpp files: +au BufWinLeave *.c mkview +au BufWinEnter *.c silent loadview +au BufWinLeave *.cpp mkview +au BufWinEnter *.cpp silent loadview + + +" Snippets +" ---------------------------------------------------------------------- +" I deleted the file accidently +"nnoremap ,ch :-1r $VIMFILES/snippets/cheader.c<CR> + + +" File Browsing +" ---------------------------------------------------------------------- +" Use netrw out of the box file browser plugin. +" :e . open file browser on current directory +" V or t open file on vsplit or new tab. +" :bd or :Rex to return +" More mappings on |netrw-browse-maps| +"let g:netrw_banner=0 " disable banner +"let g:netrw_browse_split=4 " open in prior window +let g:netrw_altv=1 " open splits to the right +"let g:netrw_list_hide=netrw_gitignore#Hide() +"let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' " wtf? (?) +" Learned from Max Cantor talk https://youtu.be/XA2WjJbmmoM + + +" Additions +" ---------------------------------------------------------------------- +" Replaces previous WORD arithmetic expression with result (from Vim +" fandom-wiki) +inoremap <C-A> <Esc>diWi<C-R>=<C-R>"<CR> + + +" Plugins +" ---------------------------------------------------------------------- +" I disabled it bc I think it interferes with formatoptions +"" Automatic vim-plug install +"if empty(glob('~/.vim/autoload/plug.vim')) +" silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs +" \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +"endif +" +"call plug#begin() +"Plug 'ARM9/arm-syntax-vim' +"autocmd BufNewFile,BufRead *.s,*.S set filetype=arm " arm = armv6/7 +" +"call plug#end() + +" Other plugins +" I used to use IndexedSearch plugin. Functionality was incorporated into Vim +" since Vim 8.1.1270. +set shortmess-=S + + +" Colors +" ---------------------------------------------------------------------- +" I like desert, murphy, pablo, industry +" (default is OK for most cases but when using vimdiff, highlighted numbers are +" unreadable) +:colorscheme industry + + +" Ducktape (place this in ~/.vim/after (after directory)) +" ---------------------------------------------------------------------- +" Not even the ducktape worked for this one on C files TODO +set formatoptions-=o " Automatically insert the current comment leader +" TODO: fix this shit getting reset in a markdown text +set formatoptions+=r " auto insert comment leader after <Enter> diff --git a/public/.vim/vimrc_windows b/public/.vim/vimrc_windows new file mode 100644 index 0000000..8ce69cd --- /dev/null +++ b/public/.vim/vimrc_windows @@ -0,0 +1,10 @@ +" Git for Windows Vim user initialization file +" GFW uses ~/.vimrc and ~/.vim/vimrc instead of ~/_vimrc and ~/vimfiles/vimrc +" See https://github.com/git-for-windows/git/issues/658#issuecomment-184269470 +" This file configures GFW Vim to behave like Windows Vim +" From: https://kevinlocke.name/bits/2020/07/30/sharing-vimrc-in-git-for-windows/ +let &runtimepath = '~/vimfiles,' +\ . join(filter(split(&runtimepath, ','), 'v:val !~? "/\\.vim"'), ',') +\ . ',~/vimfiles/after' +let &packpath = &runtimepath +source ~/vimfiles/vimrc diff --git a/public/.xbindkeysrc b/public/.xbindkeysrc new file mode 100644 index 0000000..7acb6fe --- /dev/null +++ b/public/.xbindkeysrc @@ -0,0 +1,205 @@ +# For the benefit of emacs users: -*- shell-script -*- +########################### +# xbindkeys configuration # +########################### +# +# Version: 1.8.7 +# +# If you edit this file, do not forget to uncomment any lines +# that you change. +# The pound(#) symbol may be used anywhere for comments. +# +# To specify a key, you can use 'xbindkeys --key' or +# 'xbindkeys --multikey' and put one of the two lines in this file. +# +# The format of a command line is: +# "command to start" +# associated key +# +# +# A list of keys is in /usr/include/X11/keysym.h and in +# /usr/include/X11/keysymdef.h +# The XK_ is not needed. +# +# List of modifier: +# Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock), +# Mod3 (CapsLock), Mod4, Mod5 (Scroll). +# + +# The release modifier is not a standard X modifier, but you can +# use it if you want to catch release events instead of press events + +# By defaults, xbindkeys does not pay attention with the modifiers +# NumLock, CapsLock and ScrollLock. +# Uncomment the lines above if you want to pay attention to them. + +#keystate_numlock = enable +#keystate_capslock = enable +#keystate_scrolllock= enable + +# Examples of commands: + +#"xbindkeys_show" +# control+shift + q + +## set directly keycode (here control + f with my keyboard) +#"xterm" +# c:41 + m:0x4 + +## specify a mouse button +#"xterm" +# control + b:2 + +#"xterm -geom 50x20+20+20" +# Shift+Mod2+alt + s +# +## set directly keycode (here control+alt+mod2 + f with my keyboard) +#"xterm" +# alt + c:0x29 + m:4 + mod2 +# +## Control+Shift+a release event starts rxvt +#"rxvt" +# release+control+shift + a +# +## Control + mouse button 2 release event starts rxvt +#"rxvt" +# Control + b:2 + Release + + +# My shortcuts +# ============ + +# See all mappings in a neat table here: $HOME/docs/notes/keybindings.ods + +# Modifier scheme (order: Control,Shift,Alt(Mod1),Super(Mod4)): +# * app-specific: +# * Control, Control+Shift, Contrl+Alt (*) +# * Linux & WM (dwm): +# * Alt, Control+Alt (*), Shift+Alt +# * user-defined: +# * Mod4 (application launch & audio control) +# * Shift+Mod4 (brightness control & audio control) +# * Control+Mod4 (unused) +# * Alt+Mod4 (unused) +# * unused (4 finger shortcuts): +# * Control+Shift+Alt, Control+Shift+Mod4, Control+Alt+Mod4, Shift+Alt+Mod4 +# * unused (5 finger shortcut): +# * Control+Shift+Alt+Mod4 + +# System +# ------ + +# WIP: shutdown and reboot require root privileges, so they won't work like this +"shutdown 0" + Control+Shift+Alt+Mod4 + s + +"reboot" + Control+Shift+Alt+Mod4 + r + +"slock" + Control+Alt + l + +"audio_control.sh inc" + Mod4 + 0 + +"audio_control.sh dec" + Mod4 + 9 + +"audio_control.sh mutetoggle" + Mod4 + m + +"audio_control.sh micinc" + Mod4 + 8 + +"audio_control.sh micdec" + Mod4 + 7 + +"audio_control.sh deafentoggle" + Mod4 + n + +"brightness_control.sh inc" + Shift+Mod4 + 0 + +"brightness_control.sh dec" + Shift+Mod4 + 9 + +"network_control.sh wifitoggle" + Shift+Mod4 + c + +"network_control.sh bluetoothtoggle" + Shift+Mod4 + v + +"network_control.sh isolatetoggle" + Shift+Mod4 + b + +# Suckless desktop +# -------------------- + +"dmenu-webshortcuts.sh" + Alt + w + +"dmenu-emojicopy.sh" + Alt + e + +"screenshot.sh" + Print + +"screenshot.sh screen" + Shift + Print + +"screenshot_ocr.sh" + Mod4 + s + +# This key combination (Mod4 + Space) seems to break xbindkeys +# See Also: +# https://bbs.archlinux.org/viewtopic.php?id=226182 +#"audio_control.sh dec" +# Mod4 + Space + +"input_control.sh en" + Mod4 + k + +"input_control.sh es" + Mod4 + l + +"input_control.sh ja" + Mod4 + j + +# Launch applications (super + key) +# --------------------------------- + +"st -e tmux" + Mod4 + Return + +"st" + Shift+Mod4 + Return + +"pcmanfm" + Mod4 + e + +"firefox" + Mod4 + w + +"thunderbird" + Mod4 + t + +"goldendict" + Mod4 + g + +"zeal" + Mod4 + h + +# Media control +# ------------- + +"playerctl play-pause" + Mod4 + Down + +"playerctl stop" + Mod4 + Up + +"playerctl next" + Mod4 + Right + +"playerctl previous" + Mod4 + Left diff --git a/public/.xinitrc b/public/.xinitrc new file mode 100644 index 0000000..cee8050 --- /dev/null +++ b/public/.xinitrc @@ -0,0 +1,92 @@ +#!/bin/sh + +# This first part is copied from /etc/X11/xinit/xinitrc +# +# Start X with `$ xstart` +# See startx(1) and xinit(1) + + +userresources=$HOME/.Xresources +usermodmap=$HOME/.Xmodmap +sysresources=/etc/X11/xinit/.Xresources +sysmodmap=/etc/X11/xinit/.Xmodmap + +# merge in defaults and keymaps + +if [ -f $sysresources ]; then + xrdb -merge $sysresources +fi + +if [ -f $sysmodmap ]; then + xmodmap $sysmodmap +fi + +if [ -f "$userresources" ]; then + xrdb -merge "$userresources" +fi + +if [ -f "$usermodmap" ]; then + xmodmap "$usermodmap" +fi + +# Load necessary X11 configuration + +if [ -d /etc/X11/xinit/xinitrc.d ] ; then + for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do + [ -x "$f" ] && . "$f" + done + unset f +fi + +# Setup and start Desktop Environment +# ====================================================================== + +# Thanks: https://bbs.archlinux.org/viewtopic.php?pid=1565341#p1565341 +run_after_dwm() { + # Bind the right Alt key to Mod4 (for DWM) + # https://wiki.archlinux.org/title/Dwm#Bind_the_right_Alt_key_to_Mod4 + # xmodmap -pke | grep Alt_R + xmodmap -e "keycode 108 = Super_L" + xmodmap -e "remove mod1 = Super_L" +} + +# fcitx (CJK and emoji input method) +export GTK_IM_MODULE=fcitx +export QT_IM_MODULE=fcitx +export XMODIFIERS=@im=fcitx + +xrandr --dpi 144 # Original mac: 72, stupid windows: 96 pulse15: 188 +setxkbmap -option caps:escape +laptop-xinput_setup.sh +laptop-xrandr.sh +xbindkeys + +#autostart="mpd xcompmgr dunst unclutter pipewire remapd" +#autostart="dunst unclutter" +# +#for program in $autostart; do +# pidof -sx "$program" || "$program" & +#done >/dev/null 2>&1 + +# Start twm +#twm & +#xclock -geometry 50x50-1+1 & +#xterm -geometry 80x50+494+51 & +#xterm -geometry 80x20+494-0 & +#exec xterm -geometry 80x66+0+0 -name login + +# Start Plasma +# Start KDE Plasma (DE) +#export DESKTOP_SESSION=plasma +#exec startplasma-x11 + +# Start xfce4 +#startxfce4 + +# Start dwm +unclutter & +xautolock -time 10 -locker slock & +dwmblocks & +setbg.sh & +(sleep 5 && run_after_dwm) & +exec dwm diff --git a/public/code/README.txt b/public/code/README.txt new file mode 100644 index 0000000..b8c12ad --- /dev/null +++ b/public/code/README.txt @@ -0,0 +1,2 @@ +Files here are configuration files for software that applies such configuration +in compile time. Mainly suckless (https://suckless.org/) software. diff --git a/public/code/dwm/config.h b/public/code/dwm/config.h new file mode 100644 index 0000000..895fced --- /dev/null +++ b/public/code/dwm/config.h @@ -0,0 +1,124 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char *fonts[] = { + "monospace:size=10", + "Noto Sans CJK JP:size=10", //:antialias=true:autohint=true", + "Noto Color Emoji:size=8", //:antialias=true:autohint=true", +}; +static const char dmenufont[] = "monospace:size=10"; +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#005577"; +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +}; + +/* tagging */ +static const char *tags[] = { "一", "二", "三", "四", "五", "六", "七", "八", "九" }; + +static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "GoldenDict", NULL, NULL, 0, 1, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod1Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *termcmd[] = { "st", NULL }; + +static const Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, +// { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, + + // mitsuo + { MODKEY, XK_F4, killclient, {0} }, +}; + +/* button definitions */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static const Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; + diff --git a/public/code/dwmblocks/config.h b/public/code/dwmblocks/config.h new file mode 100644 index 0000000..6587a09 --- /dev/null +++ b/public/code/dwmblocks/config.h @@ -0,0 +1,26 @@ +// Modify this file to change what commands output to your statusbar, and +// recompile using the make command. Kill the previous dwmblocks if any, run +// `dwmblocks &` again. + +// DWM's status bar can also be changed with (xprop -root -set WM_NAME "hi") +// https://dwm.suckless.org/status_monitor/ + +// Other people's configs: +// https://github.com/LukeSmithxyz/dwmblocks/blob/master/config.h +// https://git.denshi.org/dwmblocks/tree/blocks.h + +static const Block blocks[] = { + /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ + + {"", "sb-input", 0, 20}, + {"", "sb-audio", 0, 10}, + {"", "sb-battery", 5, 0}, + {"🧠", "sensors | grep 'Tctl' | awk '{print $2}'", 5, 0}, + {"🐏", "free | awk '/^Mem/ { printf \"%.0f%\", $3/$2*100 }'", 5, 0}, + {"", "sb-network", 30, 30}, + {"", "date '+Q%qW%V%a %m月%d日 %H:%M'", 12, 0}, +}; + +//sets delimeter between status commands. NULL character ('\0') means no delimeter. +static char delim[] = " "; +static unsigned int delimLen = 5; diff --git a/public/code/st/config.h b/public/code/st/config.h new file mode 100644 index 0000000..267246f --- /dev/null +++ b/public/code/st/config.h @@ -0,0 +1,502 @@ +/* See LICENSE file for copyright and license details. */ + +/* + * appearance + * + * 1366x768: pixelsize=12 + * 2560x1440: pixelsize=15 + * 2560x1440 (15.6"): pixelsize=16 + * + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + * + * NOTE: Use either pixelsize=10 (absolute) or size=10 (relative to xrandr DPI + * setting). In my config I'm currently using `size` for dwm, but + * `pixelsize` for st. Idk, maybe one day I'll make it tidy. Also the + * font for st is Hack because I'm used to it, but in dwm is monospace, + * which currently defaults to "Noto Sans Mono". + */ +//static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static char *font = "Hack:pixelsize=16:antialias=true:autohint=true"; +static char *font2[] = { + /* libxft does not support color emoji. Thus st crashes if it encounters + * one and tries to render it with Noto Color Emoji Font. It existst a + * patch named "libxft-gra" that solves this issue. It's documented on + * the st article on the ArchLinux Wiki */ + //"PowerlineSymbols:pixelsize=16:antialias=true:autohint=true", + //"Source Han Sans JP:pixelsize=16:antialias=true:autohint=true", + //"Source Han Serif JP:pixelsize=16:antialias=true:autohint=true", + "Noto Sans CJK JP:pixelsize=16:antialias=true:autohint=true", + "Noto Color Emoji:pixelsize=14:antialias=true:autohint=true", + /* Fallback font */ + "Symbola:pixelsize=14:antialias=true:autohint=true", +}; +static int borderpx = 2; + +/* + * What program is execed by st depends of these precedence rules: + * 1: program passed with -e + * 2: scroll and/or utmp + * 3: SHELL environment variable + * 4: value of shell in /etc/passwd + * 5: value of shell in config.h + */ +static char *shell = "/bin/sh"; +char *utmp = NULL; +/* scroll program: to enable use a string like "scroll" */ +char *scroll = NULL; +char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; + +/* identification sequence returned in DA and DECID */ +char *vtiden = "\033[?6c"; + +/* Kerning / character bounding-box multipliers */ +static float cwscale = 1.0; +static float chscale = 1.0; + +/* + * word delimiter string + * + * More advanced example: L" `'\"()[]{}" + */ +wchar_t *worddelimiters = L" "; + +/* selection timeouts (in milliseconds) */ +static unsigned int doubleclicktimeout = 300; +static unsigned int tripleclicktimeout = 600; + +/* alt screens */ +int allowaltscreen = 1; + +/* allow certain non-interactive (insecure) window operations such as: + setting the clipboard text */ +int allowwindowops = 0; + +/* + * draw latency range in ms - from new content/keypress/etc until drawing. + * within this range, st draws when content stops arriving (idle). mostly it's + * near minlatency, but it waits longer for slow updates to avoid partial draw. + * low minlatency will tear/flicker more, as it can "detect" idle too early. + */ +static double minlatency = 8; +static double maxlatency = 33; + +/* + * blinking timeout (set to 0 to disable blinking) for the terminal blinking + * attribute. + */ +static unsigned int blinktimeout = 800; + +/* + * thickness of underline and bar cursors + */ +static unsigned int cursorthickness = 2; + +/* + * bell volume. It must be a value between -100 and 100. Use 0 for disabling + * it + */ +static int bellvolume = 0; + +/* default TERM value */ +char *termname = "st-256color"; + +/* + * spaces per tab + * + * When you are changing this value, don't forget to adapt the »it« value in + * the st.info and appropriately install the st.info in the environment where + * you use this st version. + * + * it#$tabspaces, + * + * Secondly make sure your kernel is not expanding tabs. When running `stty + * -a` »tab0« should appear. You can tell the terminal to not expand tabs by + * running following command: + * + * stty tabs + */ +unsigned int tabspaces = 8; + +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + /* 8 normal colors */ + [0] = "#000000", /* black */ + [1] = "#B21818", /* red */ + [2] = "#18B218", /* green */ + [3] = "#B26818", /* yellow */ + [4] = "#1818B2", /* blue */ + [5] = "#B218B2", /* magenta */ + [6] = "#18B2B2", /* cyan */ + [7] = "#B2B2B2", /* white */ + + /* 8 bright colors */ + [8] = "#686868", /* black */ + [9] = "#FF5454", /* red */ + [10] = "#54FF54", /* green */ + [11] = "#FFFF54", /* yellow */ + [12] = "#5454FF", /* blue */ + [13] = "#FF54FF", /* magenta */ + [14] = "#54FFFF", /* cyan */ + [15] = "#FFFFFF", /* white */ + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", /* defaultcs */ + "#555555", /* defaultrcs */ + "gray90", /* default foreground colour */ + "black", /* default background colour */ +}; + + +/* + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +unsigned int defaultfg = 7; +unsigned int defaultbg = 0; +unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; + +/* + * Default shape of cursor + * 2: Block ("█") + * 4: Underline ("_") + * 6: Bar ("|") + * 7: Snowman ("☃") + */ +static unsigned int cursorshape = 2; + +/* + * Default columns and rows numbers + */ + +static unsigned int cols = 80; +static unsigned int rows = 24; + +/* + * Default colour and shape of the mouse cursor + */ +static unsigned int mouseshape = XC_left_ptr; +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; + +/* + * Color used to display font attributes when fontconfig selected a font which + * doesn't match the ones requested. + */ +static unsigned int defaultattr = 11; + +/* + * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). + * Note that if you want to use ShiftMask with selmasks, set this to an other + * modifier, set to 0 to not use it. + */ +static uint forcemousemod = ShiftMask; + +/* + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. + */ +static MouseShortcut mshortcuts[] = { + /* mask button function argument release */ + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, + { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, + { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, + { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, +}; + +/* Internal keyboard shortcuts. */ +#define MODKEY Mod1Mask +#define TERMMOD (ControlMask|ShiftMask) + +static Shortcut shortcuts[] = { + /* mask keysym function argument */ + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, + { TERMMOD, XK_Prior, zoom, {.f = +1} }, + { TERMMOD, XK_Next, zoom, {.f = -1} }, + { TERMMOD, XK_Home, zoomreset, {.f = 0} }, + { TERMMOD, XK_C, clipcopy, {.i = 0} }, + { TERMMOD, XK_V, clippaste, {.i = 0} }, + { TERMMOD, XK_Y, selpaste, {.i = 0} }, + { ShiftMask, XK_Insert, selpaste, {.i = 0} }, + { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + /* my stuff */ + { ControlMask, XK_equal, zoom, {.f = +1} }, + { ControlMask, XK_minus, zoom, {.f = -1} }, + { ControlMask, XK_0, zoomreset, {.f = 0} }, +}; + +/* + * Special keys (change & recompile st.info accordingly) + * + * Mask value: + * * Use XK_ANY_MOD to match the key no matter modifiers state + * * Use XK_NO_MOD to match the key alone (no modifiers) + * appkey value: + * * 0: no value + * * > 0: keypad application mode enabled + * * = 2: term.numlock = 1 + * * < 0: keypad application mode disabled + * appcursor value: + * * 0: no value + * * > 0: cursor application mode enabled + * * < 0: cursor application mode disabled + * + * Be careful with the order of the definitions because st searches in + * this table sequentially, so any XK_ANY_MOD must be in the last + * position for a key. + */ + +/* + * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) + * to be mapped below, add them to this array. + */ +static KeySym mappedkeys[] = { -1 }; + +/* + * State bits to ignore when matching key or button events. By default, + * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. + */ +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; + +/* + * This is the huge key array which defines all compatibility to the Linux + * world. Please decide about changes wisely. + */ +static Key key[] = { + /* keysym mask string appkey appcursor */ + { XK_KP_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0}, + { XK_KP_End, ControlMask, "\033[J", -1, 0}, + { XK_KP_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_KP_End, ShiftMask, "\033[K", -1, 0}, + { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[L", -1, 0}, + { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_KP_Delete, ControlMask, "\033[M", -1, 0}, + { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0}, + { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0}, + { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0}, + { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0}, + { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0}, + { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0}, + { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0}, + { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0}, + { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0}, + { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0}, + { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0}, + { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0}, + { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0}, + { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0}, + { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0}, + { XK_Up, ShiftMask, "\033[1;2A", 0, 0}, + { XK_Up, Mod1Mask, "\033[1;3A", 0, 0}, + { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0}, + { XK_Up, ControlMask, "\033[1;5A", 0, 0}, + { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0}, + { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0}, + { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0}, + { XK_Up, XK_ANY_MOD, "\033[A", 0, -1}, + { XK_Up, XK_ANY_MOD, "\033OA", 0, +1}, + { XK_Down, ShiftMask, "\033[1;2B", 0, 0}, + { XK_Down, Mod1Mask, "\033[1;3B", 0, 0}, + { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0}, + { XK_Down, ControlMask, "\033[1;5B", 0, 0}, + { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0}, + { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0}, + { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0}, + { XK_Down, XK_ANY_MOD, "\033[B", 0, -1}, + { XK_Down, XK_ANY_MOD, "\033OB", 0, +1}, + { XK_Left, ShiftMask, "\033[1;2D", 0, 0}, + { XK_Left, Mod1Mask, "\033[1;3D", 0, 0}, + { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0}, + { XK_Left, ControlMask, "\033[1;5D", 0, 0}, + { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0}, + { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0}, + { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0}, + { XK_Left, XK_ANY_MOD, "\033[D", 0, -1}, + { XK_Left, XK_ANY_MOD, "\033OD", 0, +1}, + { XK_Right, ShiftMask, "\033[1;2C", 0, 0}, + { XK_Right, Mod1Mask, "\033[1;3C", 0, 0}, + { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0}, + { XK_Right, ControlMask, "\033[1;5C", 0, 0}, + { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0}, + { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0}, + { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0}, + { XK_Right, XK_ANY_MOD, "\033[C", 0, -1}, + { XK_Right, XK_ANY_MOD, "\033OC", 0, +1}, + { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0}, + { XK_Return, Mod1Mask, "\033\r", 0, 0}, + { XK_Return, XK_ANY_MOD, "\r", 0, 0}, + { XK_Insert, ShiftMask, "\033[4l", -1, 0}, + { XK_Insert, ShiftMask, "\033[2;2~", +1, 0}, + { XK_Insert, ControlMask, "\033[L", -1, 0}, + { XK_Insert, ControlMask, "\033[2;5~", +1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0}, + { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0}, + { XK_Delete, ControlMask, "\033[M", -1, 0}, + { XK_Delete, ControlMask, "\033[3;5~", +1, 0}, + { XK_Delete, ShiftMask, "\033[2K", -1, 0}, + { XK_Delete, ShiftMask, "\033[3;2~", +1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0}, + { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0}, + { XK_BackSpace, XK_NO_MOD, "\177", 0, 0}, + { XK_BackSpace, Mod1Mask, "\033\177", 0, 0}, + { XK_Home, ShiftMask, "\033[2J", 0, -1}, + { XK_Home, ShiftMask, "\033[1;2H", 0, +1}, + { XK_Home, XK_ANY_MOD, "\033[H", 0, -1}, + { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1}, + { XK_End, ControlMask, "\033[J", -1, 0}, + { XK_End, ControlMask, "\033[1;5F", +1, 0}, + { XK_End, ShiftMask, "\033[K", -1, 0}, + { XK_End, ShiftMask, "\033[1;2F", +1, 0}, + { XK_End, XK_ANY_MOD, "\033[4~", 0, 0}, + { XK_Prior, ControlMask, "\033[5;5~", 0, 0}, + { XK_Prior, ShiftMask, "\033[5;2~", 0, 0}, + { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0}, + { XK_Next, ControlMask, "\033[6;5~", 0, 0}, + { XK_Next, ShiftMask, "\033[6;2~", 0, 0}, + { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0}, + { XK_F1, XK_NO_MOD, "\033OP" , 0, 0}, + { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0}, + { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0}, + { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0}, + { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0}, + { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0}, + { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0}, + { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0}, + { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0}, + { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0}, + { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0}, + { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0}, + { XK_F3, XK_NO_MOD, "\033OR" , 0, 0}, + { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0}, + { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0}, + { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0}, + { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0}, + { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0}, + { XK_F4, XK_NO_MOD, "\033OS" , 0, 0}, + { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0}, + { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0}, + { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0}, + { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0}, + { XK_F5, XK_NO_MOD, "\033[15~", 0, 0}, + { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0}, + { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0}, + { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0}, + { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0}, + { XK_F6, XK_NO_MOD, "\033[17~", 0, 0}, + { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0}, + { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0}, + { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0}, + { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0}, + { XK_F7, XK_NO_MOD, "\033[18~", 0, 0}, + { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0}, + { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0}, + { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0}, + { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0}, + { XK_F8, XK_NO_MOD, "\033[19~", 0, 0}, + { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0}, + { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0}, + { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0}, + { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0}, + { XK_F9, XK_NO_MOD, "\033[20~", 0, 0}, + { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0}, + { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0}, + { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0}, + { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0}, + { XK_F10, XK_NO_MOD, "\033[21~", 0, 0}, + { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0}, + { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0}, + { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0}, + { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0}, + { XK_F11, XK_NO_MOD, "\033[23~", 0, 0}, + { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0}, + { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0}, + { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0}, + { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0}, + { XK_F12, XK_NO_MOD, "\033[24~", 0, 0}, + { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0}, + { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0}, + { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0}, + { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0}, + { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0}, + { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0}, + { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0}, + { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0}, + { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0}, + { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0}, + { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0}, + { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0}, + { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0}, + { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0}, + { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0}, + { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0}, + { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0}, + { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0}, + { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0}, + { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0}, + { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0}, + { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0}, + { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0}, + { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0}, + { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0}, + { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0}, + { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0}, +}; + +/* + * Selection types' masks. + * Use the same masks as usual. + * Button1Mask is always unset, to make masks match between ButtonPress. + * ButtonRelease and MotionNotify. + * If no match is found, regular selection is used. + */ +static uint selmasks[] = { + [SEL_RECTANGULAR] = Mod1Mask, +}; + +/* + * Printable characters in ASCII, used to estimate the advance width + * of single wide characters. + */ +static char ascii_printable[] = + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~"; diff --git a/public/windows_shit/README.txt b/public/windows_shit/README.txt new file mode 100644 index 0000000..da0c1b4 --- /dev/null +++ b/public/windows_shit/README.txt @@ -0,0 +1 @@ +ugly stuff diff --git a/public/windows_shit/powershell/Microsoft.PowerShell_profile.ps1 b/public/windows_shit/powershell/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..fc55bac --- /dev/null +++ b/public/windows_shit/powershell/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,19 @@ +# Access this file using $PROFILE +# +# By default, powershell does not allow execution of non-signed scripts +# > Get-ExecutionPolicy +# > Set-ExecutionPolicy -Scope CurrentUser RemoteSigned +# +# Home directory: +# cmd.exe: %USERPROFILE% +# Powershell: $ENV:USERPROFILE +# +# To break long commands in Powershell use a trailing backtick (`) + +# Custom colored prompt +# Ref.: https://stackoverflow.com/questions/6297072 +function prompt +{ + Write-Host "PS $(get-location)`n>" -nonewline -foregroundcolor DarkCyan + return ' ' +} |
