Back (Current repo: dotfiles)

my dotfiles to make it easy to transfer my settings
To clone this repository:
git clone https://git.viktor1993.net/dotfiles.git
Log | Download | Files | Refs

commit 41d2789af42634a11bd542716f4d9caaa1b22adf
Author: root <root>
Date:   Sun,  4 May 2025 14:14:31 +0200

add new dotfiles

Diffstat:
Aetc/i3/config | 243+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/i3blocks.conf | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/mail.rc | 4++++
Aetc/maxscale.cnf | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/mpd.conf | 34++++++++++++++++++++++++++++++++++
Ahome/user/.bash_aliases | 12++++++++++++
Ahome/user/.bashrc | 11+++++++++++
Ahome/user/.config/custom/db/.mariadb_root.cnf | 6++++++
Ahome/user/.config/custom/exhibit-stamp | 15+++++++++++++++
Ahome/user/.config/custom/exhibit-template.tex | 32++++++++++++++++++++++++++++++++
Ahome/user/.config/custom/locations | 6++++++
Ahome/user/.config/custom/searches | 5+++++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/handlebars.vim | 3+++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/mustache.vim | 3+++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/handlebars.vim | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/mustache.vim | 1+
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/indent/handlebars.vim | 125+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/indent/mustache.vim | 1+
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/handlebars.vim | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/mustache.vim | 1+
Ahome/user/.config/sxiv/exec/key-handler | 28++++++++++++++++++++++++++++
Ahome/user/.config/vim/colours.vim | 41+++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/vim/prog_funcs.vim | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/vim/spanishkeys.vim | 46++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.config/vim/sql_query.vim | 9+++++++++
Ahome/user/.config/vim/statusline.vim | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.local/bin/addbookmark | 10++++++++++
Ahome/user/.local/bin/connectphone | 33+++++++++++++++++++++++++++++++++
Ahome/user/.local/bin/dmenumusic | 3+++
Ahome/user/.local/bin/dmenupass | 2++
Ahome/user/.local/bin/dmenupoweroff | 23+++++++++++++++++++++++
Ahome/user/.local/bin/dmenusearch | 17+++++++++++++++++
Ahome/user/.local/bin/maim-config | 22++++++++++++++++++++++
Ahome/user/.local/bin/pausempv | 5+++++
Ahome/user/.local/bin/pdflabel | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.local/bin/resumempv | 5+++++
Ahome/user/.local/bin/showclip | 14++++++++++++++
Ahome/user/.local/bin/twindow | 20++++++++++++++++++++
Ahome/user/.local/bin/wordpractice | 2++
Ahome/user/.profile | 25+++++++++++++++++++++++++
Ahome/user/.vim/after/syntax/handlebars.vim | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.vim/after/syntax/i3.vim | 270+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/.vim/after/syntax/mustache.vim | 1+
Ahome/user/.vimrc | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/scripts/commentbox.sh | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/scripts/dmenu_music | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahome/user/scripts/wordpractice | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amisc/disable_recents_nemo | 7+++++++
Ausr/share/i3blocks/bandwidth | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ausr/share/i3blocks/cpu_usage | 9+++++++++
Ausr/share/i3blocks/datetime | 8++++++++
Ausr/share/i3blocks/disk | 3+++
Ausr/share/i3blocks/iface | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ausr/share/i3blocks/memory | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Ausr/share/i3blocks/music | 9+++++++++
Ausr/share/i3blocks/volume | 14++++++++++++++
56 files changed, 2439 insertions(+), 0 deletions(-)

diff --git a/etc/i3/config b/etc/i3/config @@ -0,0 +1,243 @@ +# vim: set ft=i3config +## Some shortcuts and definitions +set $ig 1 +set $og 1 +set $term --no-startup-id $TERMINAL +set $mod Mod4 +set $shutdown sudo -A shutdown -h now +set $reboot sudo -A reboot +set $netrefresh --no-startup-id sudo -A systemctl restart NetworkManager +set $hibernate sudo -A systemctl suspend + +## Gaps +for_window [class="^.*"] border pixel 2 +gaps inner $ig +gaps outer $og + +# General dropdown window traits. The order can matter. +for_window [instance="dropdown_*"] floating enable +for_window [instance="dropdown_*"] move scratchpad +for_window [instance="dropdown_*"] sticky enable +for_window [instance="dropdown_*"] scratchpad show +for_window [instance="dropdown_tmuxdd"] resize set 625 450 +for_window [instance="dropdown_dropdowncalc"] resize set 800 300 +for_window [instance="dropdown_tmuxdd"] border pixel 3 +for_window [instance="dropdown_dropdowncalc"] border pixel 2 +for_window [instance="dropdown_*"] move position center + +bar { + font pango:mono 10 #, EmojiOne Color 10 + status_command i3blocks + position top + mode dock + modifier None + bindsym button4 nop + bindsym button5 nop +} + +## Non-Letter Key Bindings +bindsym $mod+Return exec $term +bindsym $mod+Shift+Return exec $term + +bindsym $mod+Shift+space floating toggle +bindsym $mod+space focus mode_toggle + +bindsym $mod+Escape workspace prev +bindsym $mod+Shift+Escape exec --no-startup-id prompt "Exit i3?" "i3 exit" + +bindsym $mod+grave exec --no-startup-id dmenuemoji + +#STOP/HIDE EVERYTHING: +bindsym $mod+Shift+Delete exec --no-startup-id pulsemixer --mute ; exec --no-startup-id ${MPC} pause && pkill -RTMIN+10 i3blocks ; exec --no-startup-id pausempv; workspace 0; exec $term -e htop ; exec $term -e lf + +## Letter Key Bindings +# unassorted little shortcuts to quickly get to commonly used progs and some workspace management + +#quit and force quit +bindsym $mod+q [con_id="__focused__" instance="^(?!dropdown_).*$"] kill +bindsym $mod+Shift+q [con_id="__focused__" instance="^(?!dropdown_).*$"] exec --no-startup-id kill -9 $(xdotool getwindowfocus getwindowpid) + +#browser, network settings +bindsym $mod+w exec --no-startup-id $BROWSER +bindsym $mod+Shift+w exec $term -e nmtui + +#bookmarks +bindsym $mod+e exec xdotool type $(cat $HOME/.local/share/bookmarks/bookmarks | dmenu -i -l 50) +bindsym $mod+Shift+e exec --no-startup-id $HOME/.local/bin/addbookmark + +# work and test vms +bindsym $mod+r exec --no-startup-id VBoxManage startvm debian-work; workspace $ws9 +bindsym $mod+Shift+r exec --no-startup-id VBoxManage startvm debian-test; workspace $ws10 + +bindsym $mod+t split toggle +bindsym $mod+Shift+t gaps inner current set $ig; gaps outer current set $og + +bindsym $mod+y gaps inner minus 1 +bindsym $mod+Shift+y exec --no-startup-id i3resize left + +bindsym $mod+u exec --no-startup-id sudo -A unetbootin +bindsym $mod+Shift+u exec --no-startup-id i3resize down + +bindsym $mod+i exec $term -e htop +bindsym $mod+Shift+i exec --no-startup-id i3resize up + +bindsym $mod+o sticky toggle +bindsym $mod+Shift+o exec --no-startup-id i3resize right + +bindsym $mod+p exec --no-startup-id ${MPC} toggle +bindsym $mod+Shift+p exec --no-startup-id ${MPC} pause + +#pulsemixer and alsamixer +bindsym $mod+a exec $term -a alsamixer +bindsym $mod+Shift+a exec $term -e pulsemixer + +bindsym $mod+s gaps inner current plus 1 +bindsym $mod+Shift+s exec --no-startup-id /usr/bin/steam; workspace $ws8 + +bindsym $mod+d exec --no-startup-id dmenu_run +bindsym $mod+Shift+d gaps inner current set 0; gaps outer current set 0 + +bindsym $mod+f fullscreen toggle +bindsym $mod+Shift+f exec --no-startup-id nemo; workspace $ws4 + +bindsym $mod+g workspace prev +bindsym $mod+Shift+g exec --no-startup-id gimp; workspace $ws5 + +bindsym $mod+h focus left +bindsym $mod+Shift+h move left 30 +bindsym $mod+Ctrl+h move workspace to output left + +bindsym $mod+j focus down +bindsym $mod+Shift+j move down 30 +bindsym $mod+Ctrl+j move workspace to output down + +bindsym $mod+k focus up +bindsym $mod+Shift+k move up 30 +bindsym $mod+Ctrl+k move workspace to output up + +bindsym $mod+l focus right +bindsym $mod+Shift+l move right 30 +bindsym $mod+Ctrl+l move workspace to output right + +bindsym $mod+z gaps outer current plus 1 +bindsym $mod+Shift+z gaps outer current minus 1 + +#lock and lock menu + music pauce +bindsym --release $mod+x exec --no-startup-id ${MPC} pause; exec --no-startup-id slock +bindsym $mod+Shift+x exec --no-startup-id ${MPC} pause; exec --no-startup-id dmenupoweroff + +bindsym $mod+c exec $term -e calcurse +#bindsym $mod+Shift+c exec --no-startup-id <command> + +#vim and virtualbox +bindsym $mod+v exec --no-startup-id $term -e $EDITOR +bindsym $mod+Shift+v exec --no-startup-id /usr/bin/virtualbox; workspace $ws9 + +bindsym $mod+b bar mode toggle +bindsym $mod+Shift+b floating toggle; sticky toggle; exec --no-startup-id hover left + +bindsym $mod+n exec $term -e newsboat && pkill -RTMIN+6 i3blocks +bindsym $mod+Shift+n floating toggle; sticky toggle; exec --no-startup-id hover right + +#mpv pause/unpause +bindsym $mod+m exec --no-startup-id pausempv +bindsym $mod+Shift+m exec --no-startup-id resumempv + +#This is like alt tabbing, but with workspces +bindsym $mod+Tab workspace back_and_forth + +set $ws1 "1" +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" +set $ws10 "10" + +# switch to workspace +bindsym $mod+1 workspace $ws1 +bindsym $mod+2 workspace $ws2 +bindsym $mod+3 workspace $ws3 +bindsym $mod+4 workspace $ws4 +bindsym $mod+5 workspace $ws5 +bindsym $mod+6 workspace $ws6 +bindsym $mod+7 workspace $ws7 +bindsym $mod+8 workspace $ws8 +bindsym $mod+9 workspace $ws9 +bindsym $mod+0 workspace $ws10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10 + +for_window [class="Pinentry"] sticky enable +for_window [class="sent"] border pixel 0px +for_window [title="GIMP Startup"] move workspace $ws5 +for_window [class="Gimp"] move workspace $ws5 +for_window [window_role="GtkFileChooserDialog"] resize set 800 600 +for_window [window_role="GtkFileChooserDialog"] move position center +for_window [title="Default - Wine desktop"] floating enable + +# Function buttons for quick access to important stuff +bindsym $mod+F1 exec --no-startup-id dmenupoweroff +bindsym $mod+F2 exec --no-startup-id dmenumusic +bindsym $mod+F3 exec --no-startup-id dmenusearch +bindsym $mod+F4 exec --no-startup-id twindow +bindsym $mod+F5 exec --no-startup-id showclip +bindsym $mod+F6 exec --no-startup-id connectphone -c +bindsym $mod+F7 exec --no-startup-id connectphone -d +#bindsym $mod+F8 exec --no-startup-id <command> +#bindsym $mod+F9 exec --no-startup-id <command> +#bindsym $mod+F10 exec --no-startup-id <command> +bindsym $mod+F11 exec --no-startup-id $netrefresh +bindsym $mod+F12 exec $term -e nmtui +#bindsym $mod+Shift+F1 exec --no-startup-id <command> + +# Extra keys for workspace management +bindsym $mod+Left focus left +bindsym $mod+Shift+Left move left +bindsym $mod+Ctrl+Left move workspace to output left +bindsym $mod+Down focus down +bindsym $mod+Shift+Down move down +bindsym $mod+Ctrl+Down move workspace to output down +bindsym $mod+Up focus up +bindsym $mod+Shift+Up move up +bindsym $mod+Ctrl+Up move workspace to output up +bindsym $mod+Right focus right +bindsym $mod+Shift+Right move right +bindsym $mod+Ctrl+Right move workspace to output right + +# Volume keys +bindsym $mod+plus exec --no-startup-id amixer -q -D pulse sset Master 1%+ +bindsym $mod+Shift+plus exec --no-startup-id amixer -q -D pulse sset Master 10%+ +bindsym $mod+minus exec --no-startup-id amixer -q -D pulse sset Master 1%- +bindsym $mod+Shift+minus exec --no-startup-id amixer -q -D pulse sset Master 10%- +bindsym $mod+BackSpace exec --no-startup-id amixer -D pulse set Master toggle + +# Skiping an mpd song +bindsym $mod+Ctrl+minus exec --no-startup-id ${MPC} prev +bindsym $mod+Ctrl+plus exec --no-startup-id ${MPC} next + +# For advancing forward/backward in an mpd song +bindsym $mod+bracketleft exec --no-startup-id ${MPC} seek -10 +bindsym $mod+Shift+bracketleft exec --no-startup-id ${MPC} seek -120 +bindsym $mod+bracketright exec --no-startup-id ${MPC} seek +10 +bindsym $mod+Shift+bracketright exec --no-startup-id ${MPC} seek +120 + +# For screenshots (with maim) +bindsym $mod+Print exec --no-startup-id maim $HOME/Pictures/pic-full-"$(date '+%y%m%d-%H%M-%S').png" +bindsym $mod+Shift+Print exec --no-startup-id $HOME/.local/bin/maim-config + +#lock screen when not in use +exec "xautolock -detectsleep -time 20 -locker \"slock\"" diff --git a/etc/i3blocks.conf b/etc/i3blocks.conf @@ -0,0 +1,70 @@ +# i3blocks config file +# +# Please see man i3blocks for a complete reference! +# The man page is also hosted at http://vivien.github.io/i3blocks +# +# List of valid properties: +# +# align +# color +# command +# full_text +# instance +# interval +# label +# min_width +# name +# separator +# separator_block_width +# short_text +# signal +# urgent + +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +command=/usr/share/i3blocks/$BLOCK_NAME +separator_block_width=15 +markup=none + +[music] +label=♪ +interval=1 + +[volume] +label=🔉 +instance=Master +interval=1 + +[memory] +label=🧠 +separator=false +interval=30 + +[disk] +label=💾 +interval=30 + +[iface] +label=🌎 +color=#00FF00 +interval=10 +separator=false + +[bandwidth] +interval=5 + +[datetime] +command=/usr/share/i3blocks/datetime +label=⏳ +interval=1 +signal=1 + +[cpu_usage] +label=CPU +label=💻 +interval=10 +min_width=CPU 100.00% +separator=false + diff --git a/etc/mail.rc b/etc/mail.rc @@ -0,0 +1,4 @@ +set ask askcc append dot save crt +ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To + +set sendmail="/usr/bin/msmtp" diff --git a/etc/maxscale.cnf b/etc/maxscale.cnf @@ -0,0 +1,141 @@ +##################################################### +# MaxScale documentation: # +# https://mariadb.com/kb/en/mariadb-maxscale-23-08/ # +##################################################### + +######################################################################################### +# Global parameters # +# # +# Complete list of configuration options: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-maxscale-configuration-guide/ # +######################################################################################### +[maxscale] +threads=auto +log_augmentation = 1 +ms_timestamp = 1 +syslog = 1 + +############################################################################ +# Server definitions # +# # +# Set the address of the server to the network address of a MariaDB server.# +############################################################################ + +[server1] +type=server +address=192.168.2.24 +port=3309 +protocol=MariaDBBackend + +[server2] +type=server +address=192.168.2.99 +port=3306 +protocol=MariaDBBackend +################################################################################## +# Uncomment this and add MaxScale's IP to proxy_protocol_networks in MariaDB for # +# easier user management: https://mariadb.com/kb/en/proxy-protocol-support/ # +################################################################################## +# proxy_protocol=true + +#################################################################################### +# Monitor for the servers # +# # +# This will keep MaxScale aware of the state of the servers. # +# MariaDB Monitor documentation: # +# https://mariadb.com/kb/en/mariadb-maxscale-23-08-monitors/ # +# # +# The GRANTs needed by the monitor user depend on the actual monitor. # +# The GRANTs required by the MariaDB Monitor can be found here: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-monitor/#required-grants # +#################################################################################### + +[MariaDB-Monitor] +type=monitor +module=mariadbmon +servers=server1,server2 +user=maxscaleuser +password=[REDACTED] +replication_user=repl +replication_password=[REDACTED] +auto_failover=true +auto_rejoin=true +enforce_simple_topology=true +#enforce_read_only_slaves=1 +monitor_interval=2000ms +#################################################################################################### +# Uncomment these to enable automatic node failover: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-monitor/#cluster-manipulation-operations # +# # +# The GRANTs required for automatic node failover can be found here: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-monitor/#cluster-manipulation-grants # +#################################################################################################### +# auto_failover=true +# auto_rejoin=true +# enforce_simple_topology=true +# replication_user=<username used for replication> +# replication_password=<password used for replication> +################################################################################################# +# Uncomment this if you use more than one MaxScale with automatic node failover: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-monitor/#cooperative-monitoring # +################################################################################################# +# cooperative_monitoring_locks=majority_of_all + +########################################################################################### +# Service definitions # +# # +# Service Definition for a read-only service and a read/write splitting service. # +# # +# The GRANTs needed by the service user can be found here: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-authentication-modules/#required-grants # +########################################################################################### + +################################################################## +# ReadConnRoute documentation: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-readconnroute/ # +################################################################## + +[Read-Only-Service] +type=service +router=readconnroute +servers=server2 +user=maxscaleuser +password=[REDACTED] +router_options=slave,running + +################################################################### +# ReadWriteSplit documentation: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-readwritesplit/ # +################################################################### + +[Read-Write-Service] +type=service +router=readwritesplit +servers=server1 +user=maxscaleuser +password=[REDACTED] + +###################################################################################### +# Uncomment these to enable transparent transaction replay on node failure: # +# https://mariadb.com/kb/en/mariadb-maxscale-2308-readwritesplit/#transaction_replay # +###################################################################################### +# transaction_replay=true +# transaction_replay_timeout=30s + +#################################################################### +# Listener definitions for the services # +# # +# These listeners represent the ports the services will listen on. # +#################################################################### + +[Read-Only-Listener] +type=listener +service=Read-Only-Service +protocol=MariaDBClient +port=4008 + +[Read-Write-Listener] +type=listener +service=Read-Write-Service +protocol=MariaDBClient +port=4006 diff --git a/etc/mpd.conf b/etc/mpd.conf @@ -0,0 +1,34 @@ +music_directory "~/Music" +playlist_directory "~/Music/playlists" +db_file "/var/lib/mpd/tag_cache" +log_file "/var/log/mpd/mpd.log" +pid_file "/run/mpd/pid" +state_file "/var/lib/mpd/state" +sticker_file "/var/lib/mpd/sticker.sql" +user "mpd" +bind_to_address "any" +input { + plugin "curl" +} +input { + enabled "no" + plugin "qobuz" +} +input { + enabled "no" + plugin "tidal" +} +decoder { + enabled "no" + plugin "wildmidi" + config_file "/etc/timidity/timidity.cfg" +} +decoder { + plugin "hybrid_dsd" + enabled "no" +} +audio_output { + type "pulse" + name "pulse audio" +} +filesystem_charset "UTF-8" diff --git a/home/user/.bash_aliases b/home/user/.bash_aliases @@ -0,0 +1,12 @@ +alias fixaudio="pulseaudio -k && rm -r ~/.config/pulse" +alias bashrc="vim $HOME/.bashrc" +alias vimrc="vim $HOME/.vimrc" +alias reload="source $HOME/.bashrc" +alias aliasrc="vim $HOME/.bash_aliases" +alias less="less -r " +alias i3blocks="cd /usr/share/i3blocks; sudo su" +alias pics="sxiv -r -q * " +alias mpv="mpv --input-ipc-server=/tmp/mpvsocket " +alias weather="curl -s wttr.in | less" +alias graphics="lspci | grep ' VGA ' | cut -d\" \" -f 1 | xargs -i lspci -v -s {}" + diff --git a/home/user/.bashrc b/home/user/.bashrc @@ -0,0 +1,11 @@ +parse_git_branch() { + if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = true ]; then + ADD_TO_PROMPT=$(git branch 2> /dev/null | awk '!/^[^*]/' | awk '{match($0, /[a-zA-Z0-9\-_]+/); print "("substr($0, RSTART, RLENGTH)") ";}') + echo "$ADD_TO_PROMPT" + fi +} + +export PS1="$PS1\$(parse_git_branch)" +export MYSQL_PS1="(\u@\h) [\d]>" +export SUDO_ASKPASS=$HOME/.local/bin/dmenupass + diff --git a/home/user/.config/custom/db/.mariadb_root.cnf b/home/user/.config/custom/db/.mariadb_root.cnf @@ -0,0 +1,6 @@ +[client] +host=127.0.0.1 +port=3309 +user=root +database=information_schema +password=[REDACTED] diff --git a/home/user/.config/custom/exhibit-stamp b/home/user/.config/custom/exhibit-stamp @@ -0,0 +1,15 @@ +total=%REPLACE_NUM% +gs -o pagenumbers.pdf \ + -sDEVICE=pdfwrite \ + -g5950x8420 \ + -c "/Helvetica findfont \ + 13 scalefont setfont \ + 1 1 ${total} { \ + /PageNo exch def \ + 260 10 moveto \ + (PS' EXHIBIT %REPLACE_EXHIBIT% \() show \ + PageNo 3 string cvs \ + show \ + (\)) show \ + showpage \ + } for" diff --git a/home/user/.config/custom/exhibit-template.tex b/home/user/.config/custom/exhibit-template.tex @@ -0,0 +1,32 @@ +\documentclass{article} + +\usepackage{titling} +\usepackage{geometry} +\usepackage[2]{pagesel} +\usepackage{fix-cm} + +\makeatletter +\newcommand\HUGE{\@setfontsize\Huge{70}{80}} +\makeatother + + +\geometry{a4paper, margin=1in} + +\title{} +\date{} +\author{} + +\pagenumbering{gobble} + +\begin{document} +\maketitle +\newpage + +% \vspace doesn't like being at the very beginning, so the workaround +% is to generate an empty page and discard it +\null\vspace{\fill} +\centering +\textbf{\HUGE EXHIBIT @REPLACE@} +\vspace{\fill} +\newpage +\end{document} diff --git a/home/user/.config/custom/locations b/home/user/.config/custom/locations @@ -0,0 +1,6 @@ +$HOME/Documents +$HOME/Downloads +$HOME/Pictures +$HOME/Music +$HOME/.local/bin +$HOME/spanish_study diff --git a/home/user/.config/custom/searches b/home/user/.config/custom/searches @@ -0,0 +1,5 @@ +https://www.google.com/search?q= +https://duckduckgo.com/?q= +https://www.youtube.com/results?search_query= +https://github.com/search?q= +https://www.reddit.com/search/?q= diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/handlebars.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/handlebars.vim @@ -0,0 +1,3 @@ +if has("autocmd") + au BufNewFile,BufRead *.handlebars,*.hdbs,*.hbs,*.hb set filetype=html.handlebars +endif diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/mustache.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftdetect/mustache.vim @@ -0,0 +1,3 @@ +if has("autocmd") + au BufNewFile,BufRead *.mustache,*.hogan,*.hulk,*.hjs set filetype=html.mustache +endif diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/handlebars.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/handlebars.vim @@ -0,0 +1,123 @@ +if exists('b:loaded_mustache_handlebars') + finish +endif +let b:loaded_mustache_handlebars = 1 + +let s:cpo_save = &cpo +set cpo&vim + +" Matchit support for Mustache & Handlebars +" extending HTML matchit groups +if exists("loaded_matchit") && exists("b:match_words") + let b:match_words = b:match_words + \ . ',{:},[:],(:),' + \ . '\%({{\)\@<=#\s*\%(if\|unless\)\s*.\{-}}}' + \ . ':' + \ . '\%({{\)\@<=\s*else\s*}}' + \ . ':' + \ . '\%({{\)\@<=/\s*\%(if\|unless\)\s*}},' + \ . '\%({{\)\@<=[#^]\s*\([-0-9a-zA-Z_?!/.]\+\).\{-}}}' + \ . ':' + \ . '\%({{\)\@<=/\s*\1\s*}}' +endif + +" Set template for comment +setlocal commentstring={{!--\ %s\ --}} + +if exists("g:mustache_abbreviations") + inoremap <buffer> {{{ {{{}}}<left><left><left> + inoremap <buffer> {{ {{}}<left><left> + inoremap <buffer> {{! {{!}}<left><left> + inoremap <buffer> {{< {{<}}<left><left> + inoremap <buffer> {{> {{>}}<left><left> + inoremap <buffer> {{# {{#}}<cr>{{/}}<up><left><left> + inoremap <buffer> {{if {{#if }}<cr>{{/if}}<up><left> + inoremap <buffer> {{ife {{#if }}<cr>{{else}}<cr>{{/if}}<up><up><left> +endif + + +" Section movement +" Adapted from vim-ruby - many thanks to the maintainers of that plugin + +function! s:sectionmovement(pattern,flags,mode,count) + norm! m' + if a:mode ==# 'v' + norm! gv + endif + let i = 0 + while i < a:count + let i = i + 1 + " saving current position + let line = line('.') + let col = col('.') + let pos = search(a:pattern,'W'.a:flags) + " if there's no more matches, return to last position + if pos == 0 + call cursor(line,col) + return + endif + endwhile +endfunction + +nnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','n',v:count1)<CR> +nnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'n',v:count1)<CR> +xnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','v',v:count1)<CR> +xnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'v',v:count1)<CR> + + +" Operator pending mappings + +" Operators are available by default. Set `let g:mustache_operators = 0` in +" your .vimrc to disable them. +if ! exists("g:mustache_operators") + let g:mustache_operators = 1 +endif + +if exists("g:mustache_operators") && g:mustache_operators + onoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR> + onoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR> + xnoremap <silent> <buffer> ie :<C-U>call <SID>wrap_inside()<CR> + xnoremap <silent> <buffer> ae :<C-U>call <SID>wrap_around()<CR> +endif + +function! s:wrap_around() + " If the cursor is at the end of the tag element, move back + " so that the end tag can be detected. + while getline('.')[col('.')-1] ==# '}' + execute 'norm h' + endwhile + + " Moves to the end of the closing tag + let pos = search('}}','We') + if pos != 0 + if getline('.')[col('.')] ==# '}' + " Ending tag contains 3 closing brackets '}}}', + " move to the last bracket. + execute 'norm l' + endif + + " select the whole tag + execute 'norm v%' + endif +endfunction + +function! s:wrap_inside() + " If the cursor is at the end of the tag element, move back + " so that the end tag can be detected. + while getline('.')[col('.')-1] ==# '}' + execute 'norm h' + endwhile + + " Moves to the end of the closing tag + let pos = search('}}','W') + if pos != 0 + " select only inside the tag + execute 'norm v%loho' + endif +endfunction + + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nofoldenable diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/mustache.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/ftplugin/mustache.vim @@ -0,0 +1 @@ +runtime! ftplugin/handlebars*.vim ftplugin/handlebars/*.vim diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/indent/handlebars.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/indent/handlebars.vim @@ -0,0 +1,125 @@ +" Mustache & Handlebars syntax +" Language: Mustache, Handlebars +" Maintainer: Juvenn Woo <machese@gmail.com> +" Screenshot: http://imgur.com/6F408 +" Version: 3 +" Last Change: 26 Nov 2018 +" Remarks: based on eruby indent plugin by tpope +" References: +" [Mustache](http://github.com/defunkt/mustache) +" [Handlebars](https://github.com/wycats/handlebars.js) +" [ctemplate](http://code.google.com/p/google-ctemplate/) +" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html) +" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html) + +if exists("b:did_indent_hbs") + finish +endif + +unlet! b:did_indent +setlocal indentexpr= + +runtime! indent/html.vim +unlet! b:did_indent + +" Force HTML indent to not keep state. +let b:html_indent_usestate = 0 + +if &l:indentexpr == '' + if &l:cindent + let &l:indentexpr = 'cindent(v:lnum)' + else + let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))' + endif +endif +let b:handlebars_subtype_indentexpr = &l:indentexpr + +let b:did_indent = 1 +let b:did_indent_hbs = 1 + +setlocal indentexpr=GetHandlebarsIndent() +setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetHandlebarsIndent") + finish +endif + +function! GetHandlebarsIndent(...) + " The value of a single shift-width + if exists('*shiftwidth') + let sw = shiftwidth() + else + let sw = &sw + endif + + if a:0 && a:1 == '.' + let v:lnum = line('.') + elseif a:0 && a:1 =~ '^\d' + let v:lnum = a:1 + endif + let vcol = col('.') + call cursor(v:lnum,1) + call cursor(v:lnum,vcol) + exe "let ind = ".b:handlebars_subtype_indentexpr + + " Workaround for Andy Wokula's HTML indent. This should be removed after + " some time, since the newest version is fixed in a different way. + if b:handlebars_subtype_indentexpr =~# '^HtmlIndent(' + \ && exists('b:indent') + \ && type(b:indent) == type({}) + \ && has_key(b:indent, 'lnum') + " Force HTML indent to not keep state + let b:indent.lnum = -1 + endif + let lnum = prevnonblank(v:lnum-1) + let prevLine = getline(lnum) + let currentLine = getline(v:lnum) + + " all indent rules only apply if the block opening/closing + " tag is on a separate line + + " indent after block {{#block + if prevLine =~# '\v\s*\{\{[#^].*\s*' + let ind = ind + sw + endif + " but not if the block ends on the same line + if prevLine =~# '\v\s*\{\{\#(.+)(\s+|\}\}).*\{\{\/\1' + let ind = ind - sw + endif + " unindent after block close {{/block}} + if currentLine =~# '\v^\s*\{\{\/\S*\}\}\s*' + let ind = ind - sw + endif + " indent after component block {{a-component + if prevLine =~# '\v\s*\{\{\w' + let ind = ind + sw + endif + " but not if the component block ends on the same line + if prevLine =~# '\v\s*\{\{\w(.+)\}\}' + let ind = ind - sw + endif + " unindent }} lines, and following lines if not inside a block expression + let savedPos = getpos('.') + if currentLine =~# '\v^\s*\}\}\s*$' || (currentLine !~# '\v^\s*\{\{\/' && prevLine =~# '\v^\s*[^\{\} \t]+\}\}\s*$') + let closingLnum = search('}}\s*$', 'Wbc', lnum) + let [openingLnum, col] = searchpairpos('{{', '', '}}', 'Wb') + if openingLnum > 0 && closingLnum > 0 + if strpart(getline(openingLnum), col - 1, 3) !~ '{{[#^]' + let ind = ind - sw + endif + else + call setpos('.', savedPos) + endif + endif + " unindent {{else}} + if currentLine =~# '\v^\s*\{\{else.*\}\}\s*$' + let ind = ind - sw + endif + " indent again after {{else}} + if prevLine =~# '\v^\s*\{\{else.*\}\}\s*$' + let ind = ind + sw + endif + + return ind +endfunction diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/indent/mustache.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/indent/mustache.vim @@ -0,0 +1 @@ +runtime! indent/handlebars.vim diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/handlebars.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/handlebars.vim @@ -0,0 +1,106 @@ +" Mustache & Handlebars syntax +" Language: Mustache, Handlebars +" Maintainer: Juvenn Woo <machese@gmail.com> +" Screenshot: http://imgur.com/6F408 +" Version: 6 +" Last Change: Jul 16 2019 +" Remark: +" It lexically hilights embedded mustaches (exclusively) in html file. +" While it was written for Ruby-based Mustache template system, it should +" work for Google's C-based *ctemplate* as well as Erlang-based *et*. All +" of them are, AFAIK, based on the idea of ctemplate. +" References: +" [Mustache](http://github.com/defunkt/mustache) +" [Handlebars](https://github.com/wycats/handlebars.js) +" [ctemplate](http://code.google.com/p/google-ctemplate/) +" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html) +" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html) +" TODO: Feedback is welcomed. + + +" Read the HTML syntax to start with +if version < 600 + so <sfile>:p:h/html.vim +else + runtime! syntax/html.vim + unlet b:current_syntax +endif + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Standard HiLink will not work with included syntax files +if version < 508 + command! -nargs=+ HtmlHiLink hi link <args> +else + command! -nargs=+ HtmlHiLink hi def link <args> +endif + +syntax match mustacheError '}}}\?' +syntax match mustacheInsideError '{{[{$#<>=!\/]\?' + +" Ember angle bracket syntax syntax starts with a capital letter: +" https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md +syntax case match +syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer +syntax case ignore +syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent +syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets +syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets + +syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer + +syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent + +syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam +syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside +syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer +syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer +syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside +syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside +syntax match mustacheConditionals '\([/#]\?\<\(if\|unless\)\|\<else\)\>' contained containedin=@mustacheInside +syntax match mustacheHelpers '[/#]\?\<\(with\|link\-to\|each\(\-in\)\?\|let\)\>' contained containedin=@mustacheInside +syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside +syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside +syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer +syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer +syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside +syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside + +" Clustering +syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue + + +" Hilighting +" mustacheInside hilighted as Number, which is rarely used in html +" you might like change it to Function or Identifier +HtmlHiLink mustacheVariable Number +HtmlHiLink mustacheVariableUnescape Number +HtmlHiLink mustachePartial Number +HtmlHiLink mustacheMarkerSet Number +HtmlHiLink mustacheParam htmlArg +HtmlHiLink mustacheAngleComponentName htmlTag + +HtmlHiLink mustacheComment Comment +HtmlHiLink mustacheBlockComment Comment +HtmlHiLink mustacheError Error +HtmlHiLink mustacheInsideError Error + +HtmlHiLink mustacheHandlebars Special +HtmlHiLink mustacheAngleBrackets htmlTagName +HtmlHiLink mustacheUnescape Identifier +HtmlHiLink mustacheOperators Operator +HtmlHiLink mustacheConditionals Conditional +HtmlHiLink mustacheHelpers Repeat +HtmlHiLink mustacheQString String +HtmlHiLink mustacheDQString String + +syn region mustacheScriptTemplate start=+<script [^>]*type *=[^>]*text/\(mustache\|x-handlebars-template\)[^>]*>+ +\ end=+</script>+me=s-1 keepend +\ contains=mustacheInside,@htmlMustacheContainer,htmlTag,htmlEndTag,htmlTagName,htmlSpecialChar + +let b:current_syntax = "handlebars" +delcommand HtmlHiLink diff --git a/home/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/mustache.vim b/home/user/.config/custom/vim/vim-mustache-handlebars-master/syntax/mustache.vim @@ -0,0 +1 @@ +runtime! syntax/handlebars.vim diff --git a/home/user/.config/sxiv/exec/key-handler b/home/user/.config/sxiv/exec/key-handler @@ -0,0 +1,28 @@ +#!/bin/bash +while read image +do + REALPATH="$(echo $PWD)/${image}" + BG_DIR="$HOME/.config/background" + if [[ "$1" == "b" ]]; then + mkdir -p "$BG_DIR" #just to make sure this dir always exists + cp "$image" "$BG_DIR/image.png" && feh --bg-scale "$BG_DIR/image.png" && notify-send -i "$BG_DIR/image.png" "Wallpaper changed..." + elif [[ "$1" == "c" ]]; then + if [[ -z "$DEST" ]]; then + DEST="$(cat $HOME/.config/custom/locations | dmenu -l 20 -i -p "Copy file(s) to where?" )" + fi + if [[ -z "$DEST" ]]; then + exit 0; + fi + cp "$image" "$DEST" && notify-send -i "$REALPATH" "$image has been copied to $DEST" & + elif [[ "$1" == "m" ]]; then + if [[ -z "$DEST" ]]; then + DEST="$(cat $HOME/.config/custom/locations | dmenu -l 20 -i -p "Move file(s) to where?" )" + fi + if [[ -z "$DEST" ]]; then + exit 0; + fi + mv "$image" "$DEST" && notify-send -i "$REALPATH" "$image has been moved to $DEST" & + elif [[ "$1" == "y" ]]; then + echo -n "$image" | xclip -selection clipboard && notify-send "$REALPATH copied to clipboard" & + fi +done diff --git a/home/user/.config/vim/colours.vim b/home/user/.config/vim/colours.vim @@ -0,0 +1,41 @@ +set background=dark +hi clear + +if exists("syntax_on") + syntax reset +endif + +let g:colors_name = "custom_dark" + + +hi Normal guifg=#87ff5f guibg=#000000 ctermfg=111 ctermbg=Black +hi CursorLine guibg=#3a3a3a ctermbg=DarkGray +hi Visual guibg=#585858 guifg=NONE +hi LineNr guifg=#585858 guibg=#000000 ctermfg=DarkGray +hi CursorLineNr guifg=#87ff5f gui=bold ctermfg=LightGreen cterm=bold + +hi Comment guifg=#8a8a8a gui=italic ctermfg=DarkGray cterm=italic +hi Constant guifg=#af5fff gui=none ctermfg=141 +hi String guifg=#af5fff gui=none ctermfg=141 +hi Number guifg=#af5fff gui=none ctermfg=141 +hi Identifier guifg=#5fff00 gui=none ctermfg=Green +hi Function guifg=#5fff00 gui=none ctermfg=Green +hi Type guifg=#5f875f gui=bold ctermfg=DarkGreen cterm=bold +hi Keyword guifg=#ffffff gui=bold ctermfg=White cterm=bold +hi Statement guifg=#ffffff gui=bold ctermfg=White cterm=bold +hi PreProc guifg=#8a8a8a gui=none ctermfg=DarkGray +hi Special guifg=#0087af gui=none ctermfg=Blue +hi Delimiter guifg=#0087af gui=none ctermfg=Blue +hi Operator guifg=#ffffff gui=bold ctermfg=White cterm=bold + +hi Title guifg=#a8ff60 gui=bold ctermfg=LightGreen cterm=bold +hi Pmenu guibg=#1c1c1c guifg=#ffffff +hi PmenuSel guibg=#585858 guifg=#a8ff60 gui=bold + +hi MatchParen guibg=#3a3a3a guifg=#0087af gui=bold +hi Error guifg=#ffffff guibg=#ff0000 gui=bold +hi Todo guifg=#ff0000 guibg=#000000 gui=bold + +hi SpecialChar guifg=#ffffff gui=none ctermfg=White +hi Boolean guifg=#d78700 gui=bold ctermfg=DarkYellow cterm=bold +hi Include guifg=#8a8a8a gui=none ctermfg=DarkGray diff --git a/home/user/.config/vim/prog_funcs.vim b/home/user/.config/vim/prog_funcs.vim @@ -0,0 +1,123 @@ +" turns the selected line number to a comment box, can also add a title into the box +" mostly intended for use at the beginning of files that might require an intro to understand + +function WrapLineInCommentBox(linenumber, ...) + " make title an optional variable + if a:0 > 0 + let title = a:1 + else + let title = '' + end + execute 'r!echo' getbufline(bufnr('%'), a:linenumber, a:linenumber)[0] '| bash $HOME/scripts/commentbox.sh' title + execute a:linenumber ."d" +endfunction + +" switch between js/html file of the same name +function SwitchJS() + let file_name = expand("%<") + let ext = split(expand("%"), '\.')[-1] + + if ext == "js" + let swap_to_file = join([file_name, ".html"], "") + if filereadable(swap_to_file) + :e %<.html + else " in some projects this is common, so add a special case for this + let swap_to_file = "index.html" + if filereadable(swap_to_file) + :e index.html + endif + endif + elseif ext == "html" + let swap_to_file = join([file_name, ".js"], "") + if filereadable(swap_to_file) + :e %<.js + else " if file of same name is not found, try to look for file matching name of parent directory + let swap_to_file = join([expand('%:p:h:t'), ".js"], "") + if filereadable(swap_to_file) + :e %:p:h:t.js + endif + endif + endif +endfunction + +" turns a comment composed of multiple lines of // to a single multi-line /* */ type of comment +function! ToMultiLineComment() + let start_line = line(".") + let double_slash = '^\s*\/\/' + + " if no '//' at the beginning of line, bail and tell the user + if (match(getline(start_line), double_slash) == -1) + echohl WarningMsg | echo 'Cursor not in line with a multi-line "//" comment.' | echohl None + return + endif + + let end_line = start_line + + " pick up how many lines our change is going to affect + while (match(getline(start_line - 1), double_slash) >= 0) + let start_line = start_line - 1 + endwhile + while (match(getline(end_line + 1), double_slash) >= 0) + let end_line = end_line + 1 + endwhile + + " if we would only change one single line, bail and tell the user + if (start_line == end_line) + echohl WarningMsg | echo 'This comment is only a single line in length.' | echohl None + return + endif + + if (match(getline(end_line), '^\s*\/\/\s*$') >= 0) + " The last line is just a '//' so we want to replace it with ' */' + " instead of replacing it with ' *', and adding a new terminating '*/' line. + execute end_line + execute 's~//~ */~' + let end_line = end_line - 1 + endif + + execute start_line + execute 's~//~/*~' + + " this if block prevents an error from getting thrown when two comments are close to each other + if (end_line >= (start_line+1)) + execute (start_line + 1) . ',' . end_line . 's~^\(\s*\)//~\1 *~' + execute end_line + 1 + endif +endfunction + +" turn a single line of /* */ comment to // type of comment +" also fixes weird comments like +" /* ... +" */ to a single line // type of comment +function! OneLineMultiComment() + let start_line = line(".") " gets current line number at cursor position + let start_pat = '^\s*\/\*' + let end_pat = '^\s*\*\/\s*$' + let single_pat = '^\s*\/\*\([^*\\]\|\\.\)*\*\/\s*$' + + if match(getline(start_line), single_pat) >= 0 + " A complete /* ... */ comment on one line. + execute 's~^\(\s*\)/\*\(.\{-}\)\s*\*/~\1//\2~' + return + endif + + if match(getline(start_line), start_pat) >= 0 + " If a line starts with '/*'; assume the next line will start with '*/' + let end_line = start_line + 1 + elseif match(getline(start_line), end_pat) >= 0 " getline(5) gets text of line 5 + "match() returns -1 if not found, otherwise returns position where match is found + " If a line starts with '*/'; assume the previous line will start with '/*' + let end_line = start_line + let start_line = end_line - 1 + endif + + " Make sure start_line starts with '/*', and end_line starts with '*/' + if match(getline(start_line), start_pat) == -1 || match(getline(end_line), end_pat) == -1 + echohl WarningMsg | echo 'Invalid operation, should be in a /* ... */ comment' | echohl None + return + endif + + execute end_line + normal! ddk + execute 's~^\(\s*\)/\*\(.\{-}\)\s*$~\1//\2~' +endfunction diff --git a/home/user/.config/vim/spanishkeys.vim b/home/user/.config/vim/spanishkeys.vim @@ -0,0 +1,46 @@ +let g:SpanishKeysEnabled=0 + +" I sometimes find this easier than changing keyboard layout, +" because I don't remember easily what's supposed to be where. + +function! ToggleSpanishKeys() + if !g:SpanishKeysEnabled + call EnableSpanishKeys() + else + call DisableSpanishKeys() + endif +endfunction + +function! EnableSpanishKeys() + echo "Enabling Spanish accents" + let g:SpanishKeysEnabled=1 + + inoremap <leader>a á<C-o>1l + inoremap <leader>A Á<C-o>1l + inoremap <leader>e é<C-o>1l + inoremap <leader>E É<C-o>1l + inoremap <leader>i í<C-o>1l + inoremap <leader>I Í<C-o>1l + inoremap <leader>o ó<C-o>1l + inoremap <leader>O Ó<C-o>1l + inoremap <leader>u ú<C-o>1l + inoremap <leader>U Ú<C-o>1l + inoremap <leader>n ñ<C-o>1l +endfunction + +function! DisableSpanishKeys() + echo "Disabling Spanish accents" + let g:SpanishKeysEnabled=0 + + iunmap <leader>a + iunmap <leader>A + iunmap <leader>e + iunmap <leader>E + iunmap <leader>i + iunmap <leader>I + iunmap <leader>o + iunmap <leader>O + iunmap <leader>u + iunmap <leader>U + iunmap <leader>n +endfunction diff --git a/home/user/.config/vim/sql_query.vim b/home/user/.config/vim/sql_query.vim @@ -0,0 +1,9 @@ +function RunSQLFile() + cd %:p:h + let result = system("cat ".bufname("%")." | mariadb --defaults-extra-file=$HOME/.config/custom/db/.mariadb_root.cnf -A") + split __SQL_Result__ + normal! ggdG + setlocal buftype=nofile + call append(0, split(result, '\v\n')) + cd - +endfunction diff --git a/home/user/.config/vim/statusline.vim b/home/user/.config/vim/statusline.vim @@ -0,0 +1,62 @@ +"statusline, remove git related functions if we are exploring directories +if isdirectory(expand('%')) + set laststatus=2 + set statusline= " left align + set statusline+=%2*\ " blank char + set statusline+=%2*\ 0 + set statusline+=%2*\ + set statusline+=%1*\ << + set statusline+=%1*\ %f " short filename + set statusline+=%1*\ >> + set statusline+=%= " right align + set statusline+=%* + set statusline+=%3*\%h%m%r " file flags (help, read-only, modified) + set statusline+=%4*\ 0 + set statusline+=%3*\%.25F " long filename (trimmed to 25 chars) + set statusline+=%3*\:: + set statusline+=%3*\%l/%L\\| " line count + set statusline+=%3*\%y " file type +else + set laststatus=2 + set statusline= " left align + set statusline+=%2*\ " blank char + set statusline+=%2*\%{b:gitdiffs} " include info about committed changes between current branch and master + set statusline+=%2*\ + set statusline+=%1*\ << + set statusline+=%1*\ %f " short filename + set statusline+=%1*\ >> + set statusline+=%= " right align + set statusline+=%* + set statusline+=%3*\%h%m%r " file flags (help, read-only, modified) + set statusline+=%4*\%{b:gitbranch} " include git branch + set statusline+=%3*\%.25F " long filename (trimmed to 25 chars) + set statusline+=%3*\:: + set statusline+=%3*\%l/%L\\| " line count + set statusline+=%3*\%y " file type + hi User1 ctermbg=black ctermfg=grey guibg=black guifg=grey + hi User2 ctermbg=green ctermfg=black guibg=green guifg=black + hi User3 ctermbg=black ctermfg=lightgreen guibg=black guifg=lightgreen +endif + +"statusline helper functions + +function! StatuslineGitBranch() + let b:gitbranch="" + let b:gitdiffs="" + if &modifiable + try + lcd %:p:h + catch + return + endtry + let l:gitrevparse=system("git rev-parse --abbrev-ref HEAD") + lcd - + if l:gitrevparse!~"fatal: not a git repository" + "name of our git branch, if we are in one + let b:gitbranch="(".substitute(l:gitrevparse, '\n', '', 'g').") " + "short info about committed changes of this branch vs master + let b:gitdiffs=system('git diff --shortstat $(git branch --show-current 2>/dev/null) master 2>/dev/null | sed -E "s/([a-z ]+) +//g"') + endif + endif +endfunction diff --git a/home/user/.local/bin/addbookmark b/home/user/.local/bin/addbookmark @@ -0,0 +1,10 @@ +#!/bin/bash + +FILE=$HOME/.local/share/bookmarks/bookmarks +BOOKMARK=$(xclip -o) + +if [[ $(grep -c "$BOOKMARK" $FILE) -eq 0 ]]; then + echo $BOOKMARK >> $FILE && notify-send "Bookmark added!" +else + notify-send "Already bookmarked!" +fi diff --git a/home/user/.local/bin/connectphone b/home/user/.local/bin/connectphone @@ -0,0 +1,33 @@ +#!/bin/bash + +#a simple script for connecting my android phone with jmtpfs for file transfers via dmenu + +function connect_android() { + CONNECTION_EXISTS=$(grep -c "jmtpfs" /etc/mtab) + if [[ $CONNECTION_EXISTS -eq 0 ]]; then + mkdir -p /tmp/jmtpfs/android && jmtpfs /tmp/jmtpfs/android && notify-send "Device connected." + else + notify-send "Device already connected, or previous disconnect not cleaned up." + fi +} + +function disconnect_android() { + + FOLDER_EXISTS=$(ls /tmp | grep -c "jmtpfs") + + if [[ $FOLDER_EXISTS -eq 1 ]]; then + lsof /tmp/jmtpfs/android | awk '(NR>1){print $2}' | xargs -I {} kill -9 {} #kill any processes before attempting to unmount + fusermount -u /tmp/jmtpfs/android && rm -rf /tmp/jmtpfs && notify-send "Device disconnected." + fi + +} + +OPTSTRING=":cd" + +while getopts ${OPTSTRING} opt; do + case ${opt} in + c) connect_android ;; + d) disconnect_android ;; + *) exit 1 ;; + esac +done diff --git a/home/user/.local/bin/dmenumusic b/home/user/.local/bin/dmenumusic @@ -0,0 +1,3 @@ +#!/bin/bash +#work in progress, but does what I need it to, a small script to make music playlists and play them with dmenu +bash $HOME/scripts/dmenu_music diff --git a/home/user/.local/bin/dmenupass b/home/user/.local/bin/dmenupass @@ -0,0 +1,2 @@ +#!/bin/bash +dmenu -P -p "$1" <&- diff --git a/home/user/.local/bin/dmenupoweroff b/home/user/.local/bin/dmenupoweroff @@ -0,0 +1,23 @@ +#!/bin/bash + +MENU="dmenu_bind" + +OPT=$(echo -e "0: Cancel\n1: Lock\n2: Suspend\n3: Poweroff\n4: Reboot\n5: Logout\n6: Refresh i3" | dmenu -p "Select an option..." | awk +'BEGIN{FS=":"}{print $1}') + +if [[ "$OPT" = "0" ]]; then + exit +elif [[ "$OPT" = "1" ]]; then + slock +elif [[ "$OPT" = "2" ]]; then + systemctl suspend +elif [[ "$OPT" = "3" ]]; then + poweroff +elif [[ "$OPT" = "4" ]]; then + reboot +elif [[ "$OPT" = "5" ]]; then + i3-msg exit +elif [[ "$OPT" = "6" ]]; then + i3-msg reload && i3-msg restart +fi + diff --git a/home/user/.local/bin/dmenusearch b/home/user/.local/bin/dmenusearch @@ -0,0 +1,17 @@ +#!/bin/bash + +SEARCH_FOR="$(dmenu -p "Search for...:")" + +if [ -z "$SEARCH_FOR" ]; then + exit 0 +fi + +SEARCHER="$(dmenu -i -l 8 -p 'Search in:' < "$HOME/.config/custom/searches")" + +if [ -z "$SEARCHER" ]; then + exit 0 +fi + +SEARCH_URL="$(echo "$SEARCHER" | awk -v search="$SEARCH_FOR" '{print $1 search $2}')" + +$BROWSER "$SEARCH_URL" & diff --git a/home/user/.local/bin/maim-config b/home/user/.local/bin/maim-config @@ -0,0 +1,22 @@ +#!/bin/bash + +#A small script file for main to pick settings for screenshot taking. Requires maim. + +OUT="$(date '+%y%m%d-%H%M-%S').png" +XCLIP_CMD="xclip -sel clip -t image/png" + +OPT=$(echo -e "0: A selected area\n1: Current Window\n2: Full screen\n3: A selected area (copy)\n4: Current window (copy)\n5: Full screen (copy)" | dmenu -l 6 -i -p "Select which area to screenshot..." | awk 'BEGIN{FS=":"}{print $1}') + +if [[ "$OPT" = "0" ]]; then + maim -u -s pic-selected-"${OUT}" +elif [[ "$OPT" = "1" ]]; then + maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${OUT}" +elif [[ "$OPT" = "2" ]]; then + maim -q -d 0.2 pic-full-"${OUT}" +elif [[ "$OPT" = "3" ]]; then + maim -u -s | ${XCLIP_CMD} +elif [[ "$OPT" = "4" ]]; then + maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${XCLIP_CMD} +elif [[ "$OPT" = "5" ]]; then + maim -q -d 0.2 | ${XCLIP_CMD} +fi diff --git a/home/user/.local/bin/pausempv b/home/user/.local/bin/pausempv @@ -0,0 +1,5 @@ +#!/bin/bash + +# used as one of the i3 keybindings, this is used to pause the movie player + +echo '{ "command": ["set_property", "pause", true] }' | socat - /tmp/mpvsocket diff --git a/home/user/.local/bin/pdflabel b/home/user/.local/bin/pdflabel @@ -0,0 +1,90 @@ +#!/bin/bash + +# When presenting documents or images as evidence at some US Courts, the individual pages must form +# a collection called "EXHIBIT <single letter>. Each page must be labeled with this, as well as +# a page number. + +OUTPUT_DIR=/tmp/out-$(date '+%Y%m%d%H%M%S') +TEMPLATE_DIR=/tmp/exhibit-template +TITLE_TEMPLATE=$HOME/.config/custom/exhibit-template.tex +STAMP_TEMPLATE=$HOME/.config/custom/exhibit-stamp +CWD=$(pwd) + +function add_exhibit_label() { + + echo "${FUNCNAME[0]}: Adding file $1" + INPUT=$1 + LETTER=$2 + PAGE_NUMBER=$3 + + if [ ! -f $INPUT ]; then + echo "${FUNCNAME[0]}: Invalid input, file is missing." + return 1 + fi + + OUTPUT_NAME=$(echo $INPUT | sed -E 's/\.[a-z]+$/-output.pdf/' | sed -E 's/(.*)\/([^/]+$)/\2/') + + pdftk ${OUTPUT_DIR}/${PAGE_NUMBER}-pagenumber.pdf background $INPUT output ${OUTPUT_DIR}/00${PAGE_NUMBER}-page.pdf + rm ${OUTPUT_DIR}/${PAGE_NUMBER}-pagenumber.pdf +} + +function create_exhibit_title_page() { + + LETTER=$1 + mkdir -p $TEMPLATE_DIR + cat $TITLE_TEMPLATE > ${TEMPLATE_DIR}/000-exhibit.tex + sed -i -E "s/@REPLACE@/$LETTER/" ${TEMPLATE_DIR}/000-exhibit.tex + echo "${FUNCNAME[0]}: creating title page" + pdflatex -output-directory=${CWD} ${TEMPLATE_DIR}/000-exhibit.tex >/dev/null + + if [ -f ${CWD}/000-exhibit.pdf ]; then + mv ${CWD}/000-exhibit.pdf ${OUTPUT_DIR}/000-exhibit.pdf + fi +} + +function merge_exhibit_files() { + + cd $OUTPUT_DIR + echo "${FUNCNAME[0]}: merging files" + gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf $(ls | grep -E "[0-9-]+[a-z]+.pdf$" | sort -V) + cd $CWD + +} + + +function main() { + + if [[ ! $1 =~ ^[a-zA-Z] ]]; then + echo "${FUNCNAME[0]}: Please add a letter of exhibit" + exit 1 + fi + + mkdir -p $OUTPUT_DIR + + EXHIBIT_LETTER=$(echo $1 | awk '{print toupper($0)}') + + NUMBER_OF_PAGES_NEEDED=$(ls $CWD | grep -Ec "\.pdf$") + cat $STAMP_TEMPLATE > ${TEMPLATE_DIR}/000-template + sed -i -E "s/%REPLACE_NUM%/$NUMBER_OF_PAGES_NEEDED/" ${TEMPLATE_DIR}/000-template + sed -i -E "s/%REPLACE_EXHIBIT%/$EXHIBIT_LETTER/" ${TEMPLATE_DIR}/000-template + + cd $TEMPLATE_DIR + bash ${TEMPLATE_DIR}/000-template + mv ${TEMPLATE_DIR}/pagenumbers.pdf ${OUTPUT_DIR}/pagenumbers.pdf + cd $OUTPUT_DIR + pdfseparate pagenumbers.pdf %d-pagenumber.pdf + + cd $CWD + c=1 + for FILE in $(find . -regextype posix-extended -regex '.*pdf$' -print0 | xargs -0 realpath | sort -V); do + add_exhibit_label $FILE $EXHIBIT_LETTER $c + let c++ + done + + create_exhibit_title_page $EXHIBIT_LETTER + merge_exhibit_files $EXHIBIT_LETTER + + echo "Results in $OUTPUT_DIR" +} + +main "$@" diff --git a/home/user/.local/bin/resumempv b/home/user/.local/bin/resumempv @@ -0,0 +1,5 @@ +#!/bin/bash + +# this is an i3 keybinding for mpv, to resume a video after pausing + +echo '{ "command": ["set_property", "pause", false] }' | socat - /tmp/mpvsocket diff --git a/home/user/.local/bin/showclip b/home/user/.local/bin/showclip @@ -0,0 +1,14 @@ +#!/bin/bash + +# small script to inspect clipboard contents + +CL=$(xclip -o -selection clipboard) +PR=$(xclip -o -selection primary) + +if [ -n "$CL" ]; then + notify-send "Clipboard:" "$CL" +fi + +if [ -n "$PR" ]; then + notify-send "Primary:" "$PR" +fi diff --git a/home/user/.local/bin/twindow b/home/user/.local/bin/twindow @@ -0,0 +1,20 @@ +#!/bin/bash + +#A small script to try and open a new terminal window at the working directory of the active window + +WINDOW_PID=$(xprop -id $(xdotool getwindowfocus) | grep '_NET_WM_PID' | grep -Eo '[0-9]*$') +PIDS=$(pstree -lpATna "$WINDOW_PID" | grep -oP ',\K\d+' | tac) + +for PID in $PIDS; do + PS_CMD=$(ps -o pgid= -p "$PID") + PROCESS_GROUP_LEAD=$(ps -o comm= -p "$("${PS_CMD}" | tr -d ' ')") + CWD=$(readlink /proc/${PID}/cwd) + + #git will point to the repo's root instead of the working directory + [ "$PROCESS_GROUP_LEAD" = 'git' ] || [ ! -d "$CWD" ] && continue + #handle processes that show ~ or / instead of the working directory + [ "$cwd" != "$HOME" ] && [ "$CWD" != '/' ] && break +done + +[ "$PWD" != "$CWD" ] && [ -d "$CWD" ] && { cd "$CWD" || exit 1; } +"$TERMINAL" diff --git a/home/user/.local/bin/wordpractice b/home/user/.local/bin/wordpractice @@ -0,0 +1,2 @@ +#!/bin/bash +st -e bash "$HOME/scripts/wordpractice" diff --git a/home/user/.profile b/home/user/.profile @@ -0,0 +1,25 @@ +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + source "$HOME/.bashrc" + fi +fi + +export BROWSER="$HOME/firefox/firefox/firefox" +export BROWSER2="/usr/bin/firefox" +export TERMINAL="/usr/local/bin/st" +export EDITOR="/usr/bin/vim" +export STUDY_FILES="$HOME/spanish_study/vocabulary" +export MPC="mpc -h 127.0.0.1 -p 6664 " +export MPV="mpv --input-ipc-server=/tmp/mpvsocket " +export SUDO_ASKPASS=$HOME/.local/bin/dmenupass + +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + diff --git a/home/user/.vim/after/syntax/handlebars.vim b/home/user/.vim/after/syntax/handlebars.vim @@ -0,0 +1,106 @@ +" Mustache & Handlebars syntax +" Language: Mustache, Handlebars +" Maintainer: Juvenn Woo <machese@gmail.com> +" Screenshot: http://imgur.com/6F408 +" Version: 6 +" Last Change: Jul 16 2019 +" Remark: +" It lexically hilights embedded mustaches (exclusively) in html file. +" While it was written for Ruby-based Mustache template system, it should +" work for Google's C-based *ctemplate* as well as Erlang-based *et*. All +" of them are, AFAIK, based on the idea of ctemplate. +" References: +" [Mustache](http://github.com/defunkt/mustache) +" [Handlebars](https://github.com/wycats/handlebars.js) +" [ctemplate](http://code.google.com/p/google-ctemplate/) +" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html) +" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html) +" TODO: Feedback is welcomed. + + +" Read the HTML syntax to start with +if version < 600 + so <sfile>:p:h/html.vim +else + runtime! syntax/html.vim + unlet b:current_syntax +endif + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Standard HiLink will not work with included syntax files +if version < 508 + command! -nargs=+ HtmlHiLink hi link <args> +else + command! -nargs=+ HtmlHiLink hi def link <args> +endif + +syntax match mustacheError '}}}\?' +syntax match mustacheInsideError '{{[{$#<>=!\/]\?' + +" Ember angle bracket syntax syntax starts with a capital letter: +" https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md +syntax case match +syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer +syntax case ignore +syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent +syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets +syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets + +syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer + +syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent + +syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam +syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside +syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer +syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer +syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside +syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside +syntax match mustacheConditionals '\([/#]\?\<\(if\|unless\)\|\<else\)\>' contained containedin=@mustacheInside +syntax match mustacheHelpers '[/#]\?\<\(with\|link\-to\|each\(\-in\)\?\|let\)\>' contained containedin=@mustacheInside +syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside +syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside +syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer +syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer +syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside +syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside + +" Clustering +syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue + + +" Hilighting +" mustacheInside hilighted as Number, which is rarely used in html +" you might like change it to Function or Identifier +HtmlHiLink mustacheVariable Number +HtmlHiLink mustacheVariableUnescape Number +HtmlHiLink mustachePartial Number +HtmlHiLink mustacheMarkerSet Number +HtmlHiLink mustacheParam htmlArg +HtmlHiLink mustacheAngleComponentName htmlTag + +HtmlHiLink mustacheComment Comment +HtmlHiLink mustacheBlockComment Comment +HtmlHiLink mustacheError Error +HtmlHiLink mustacheInsideError Error + +HtmlHiLink mustacheHandlebars Special +HtmlHiLink mustacheAngleBrackets htmlTagName +HtmlHiLink mustacheUnescape Identifier +HtmlHiLink mustacheOperators Operator +HtmlHiLink mustacheConditionals Conditional +HtmlHiLink mustacheHelpers Repeat +HtmlHiLink mustacheQString String +HtmlHiLink mustacheDQString String + +syn region mustacheScriptTemplate start=+<script [^>]*type *=[^>]*text/\(mustache\|x-handlebars-template\)[^>]*>+ +\ end=+</script>+me=s-1 keepend +\ contains=mustacheInside,@htmlMustacheContainer,htmlTag,htmlEndTag,htmlTagName,htmlSpecialChar + +let b:current_syntax = "handlebars" +delcommand HtmlHiLink diff --git a/home/user/.vim/after/syntax/i3.vim b/home/user/.vim/after/syntax/i3.vim @@ -0,0 +1,270 @@ +" This file provides the syntax highlighting needed for i3 config files. +" Need to add a small config to .vimrc to make this auto-work with the config file + +if version < 600 + syn clear +elsei exists("b:current_syntax") + fini +en + +scriptencoding utf-8 + +" Error +syn match i3ConfigError /.*/ + +" Todo +syn keyword i3ConfigTodo TODO FIXME XXX contained + +" Comment +" Comments are started with a # and can only be used at the beginning of a line +syn match i3ConfigComment /^\s*#.*$/ contains=i3ConfigTodo + +" Font +" A FreeType font description is composed by: +" a font family, a style, a weight, a variant, a stretch and a size. +syn match i3ConfigFontSeparator /,/ contained +syn match i3ConfigFontSeparator /:/ contained +syn keyword i3ConfigFontKeyword font contained +syn match i3ConfigFontNamespace /\w\+:/ contained contains=i3ConfigFontSeparator +syn match i3ConfigFontContent /-\?\w\+\(-\+\|\s\+\|,\)/ contained contains=i3ConfigFontNamespace,i3ConfigFontSeparator,i3ConfigFontKeyword +syn match i3ConfigFontSize /\s\=\d\+\(px\)\?\s\?$/ contained +syn match i3ConfigFont /^\s*font\s\+.*$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace +syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace +syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?[^\\]\+$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace +syn match i3ConfigFont /^\s*font\s\+\(\(.*\\\_.*\)\|\(.*[^\\]\+$\)\)/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace + +" variables +syn match i3ConfigString /\(['"]\)\(.\{-}\)\1/ contained +syn match i3ConfigColor /#\w\{6}/ contained +syn match i3ConfigVariableModifier /+/ contained +syn match i3ConfigVariableAndModifier /+\w\+/ contained contains=i3ConfigVariableModifier +syn match i3ConfigVariable /\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?/ contains=i3ConfigVariableModifier,i3ConfigVariableAndModifier +syn keyword i3ConfigInitializeKeyword set contained +syn match i3ConfigInitialize /^\s*set\s\+.*$/ contains=i3ConfigVariable,i3ConfigInitializeKeyword,i3ConfigColor,i3ConfigString + +" Gaps +syn keyword i3ConfigGapStyleKeyword inner outer horizontal vertical top right bottom left current all set plus minus toggle up down contained +syn match i3ConfigGapStyle /^\s*\(gaps\)\s\+\(inner\|outer\|horizontal\|vertical\|left\|top\|right\|bottom\)\(\s\+\(current\|all\)\)\?\(\s\+\(set\|plus\|minus\|toggle\)\)\?\(\s\+\(-\?\d\+\|\$.*\)\)$/ contains=i3ConfigGapStyleKeyword,i3ConfigNumber,i3ConfigVariable +syn keyword i3ConfigSmartGapKeyword on inverse_outer contained +syn match i3ConfigSmartGap /^\s*smart_gaps\s\+\(on\|inverse_outer\)\s\?$/ contains=i3ConfigSmartGapKeyword +syn keyword i3ConfigSmartBorderKeyword on no_gaps contained +syn match i3ConfigSmartBorder /^\s*smart_borders\s\+\(on\|no_gaps\)\s\?$/ contains=i3ConfigSmartBorderKeyword + +" Keyboard bindings +syn keyword i3ConfigAction toggle fullscreen restart key import kill shrink grow contained +syn keyword i3ConfigAction focus move grow height width split layout resize restore reload mute unmute exit mode workspace container to contained +syn match i3ConfigModifier /\w\++\w\+\(\(+\w\+\)\+\)\?/ contained contains=i3ConfigVariableModifier +syn match i3ConfigNumber /\s\d\+/ contained +syn match i3ConfigUnit /\sp\(pt\|x\)/ contained +syn match i3ConfigUnitOr /\sor/ contained +syn keyword i3ConfigBindKeyword bindsym bindcode exec gaps border contained +syn match i3ConfigBindArgument /--\w\+\(\(-\w\+\)\+\)\?\s/ contained +syn match i3ConfigBind /^\s*\(bindsym\|bindcode\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword,i3ConfigBorderStyleKeyword + +" Floating +syn keyword swayConfigFloatingModifier floating_modifier contained +syn match swayConfigFloatingMouseAction /^\s\?.*floating_modifier\s.*\(normal\|inverted\)$/ contains=swayConfigFloatingModifier,i3ConfigVariable,i3ConfigSize + +syn keyword i3ConfigSizeSpecial x contained +syn match i3ConfigNegativeSize /-/ contained +syn match i3ConfigSize /-\?\d\+\s\?x\s\?-\?\d\+/ contained contains=i3ConfigSizeSpecial,i3ConfigNumber,i3ConfigNegativeSize +syn match i3ConfigFloating /^\s*floating_modifier\s\+\$\w\+\d\?/ contains=i3ConfigVariable,i3ConfigSize,swayConfigFloatingMouseAction +syn match i3ConfigFloating /^\s*floating_\(maximum\|minimum\)_size\s\+-\?\d\+\s\?x\s\?-\?\d\+/ contains=i3ConfigSize + +" Orientation +syn keyword i3ConfigOrientationKeyword vertical horizontal auto contained +syn match i3ConfigOrientation /^\s*default_orientation\s\+\(vertical\|horizontal\|auto\)\s\?$/ contains=i3ConfigOrientationKeyword + +" Layout +syn keyword i3ConfigLayoutKeyword default stacking tabbed contained +syn match i3ConfigLayout /^\s*workspace_layout\s\+\(default\|stacking\|tabbed\)\s\?$/ contains=i3ConfigLayoutKeyword + +" Border style +syn keyword i3ConfigBorderStyleKeyword none normal pixel contained +syn match i3ConfigBorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\(\s\+\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?\)\?\)\s\?$/ contains=i3ConfigBorderStyleKeyword,i3ConfigNumber,i3ConfigVariable + +" Hide borders and edges +syn keyword i3ConfigEdgeKeyword none vertical horizontal both smart smart_no_gaps contained +syn match i3ConfigEdge /^\s*hide_edge_borders\s\+\(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=i3ConfigEdgeKeyword + +" Arbitrary commands for specific windows (for_window) +syn keyword i3ConfigCommandKeyword for_window contained +syn region i3ConfigWindowStringSpecial start=+"+ skip=+\\"+ end=+"+ contained contains=i3ConfigString +syn region i3ConfigWindowCommandSpecial start="\[" end="\]" contained contains=i3ConfigWindowStringSpacial,i3ConfigString +syn match i3ConfigArbitraryCommand /^\s*for_window\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigCommandKeyword,i3ConfigBorderStyleKeyword,i3ConfigLayoutKeyword,i3ConfigOrientationKeyword,Size,i3ConfigNumber + +" Disable focus open opening +syn keyword i3ConfigNoFocusKeyword no_focus contained +syn match i3ConfigDisableFocus /^\s*no_focus\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigNoFocusKeyword + +" Move client to specific workspace automatically +syn keyword i3ConfigAssignKeyword assign contained +syn match i3ConfigAssignSpecial /→/ contained +syn match i3ConfigAssign /^\s*assign\s\+.*$/ contains=i3ConfigAssignKeyword,i3ConfigWindowCommandSpecial,i3ConfigAssignSpecial + +" X resources +syn keyword i3ConfigResourceKeyword set_from_resource contained +syn match i3ConfigResource /^\s*set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigWindowCommandSpecial,i3ConfigColor,i3ConfigVariable + +" Auto start applications +syn keyword i3ConfigExecKeyword exec exec_always contained +syn match i3ConfigNoStartupId /--no-startup-id/ contained " We are not using i3ConfigBindArgument as only no-startup-id is supported here +syn match i3ConfigExec /^\s*exec\(_always\)\?\s\+.*$/ contains=i3ConfigExecKeyword,i3ConfigNoStartupId,i3ConfigString + +" Automatically putting workspaces on specific screens +syn keyword i3ConfigWorkspaceKeyword workspace contained +syn keyword i3ConfigOutput output contained +syn match i3ConfigWorkspace /^\s*workspace\s\+.*$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigOutput + +" set display outputs +syn match swayConfigOutput /^\s*output\s\+.*$/ contains=i3ConfigOutput + +" set display focus +syn keyword swayConfigFocusKeyword focus contained +syn keyword swayConfigFocusType output contained +syn match swayConfigFocus /^\s*focus\soutput\s.*$/ contains=swayConfigFocusKeyword,swayConfigFocusType + +" Changing colors +syn keyword i3ConfigClientColorKeyword client focused focused_inactive unfocused urgent placeholder background contained +syn match i3ConfigClientColor /^\s*client.\w\+\s\+.*$/ contains=i3ConfigClientColorKeyword,i3ConfigColor,i3ConfigVariable + +syn keyword i3ConfigTitleAlignKeyword left center right contained +syn match i3ConfigTitleAlign /^\s*title_align\s\+.*$/ contains=i3ConfigTitleAlignKeyword + +" Interprocess communication +syn match i3ConfigInterprocessKeyword /ipc-socket/ contained +syn match i3ConfigInterprocess /^\s*ipc-socket\s\+.*$/ contains=i3ConfigInterprocessKeyword + +" Mouse warping +syn keyword i3ConfigMouseWarpingKeyword mouse_warping contained +syn keyword i3ConfigMouseWarpingType output none contained +syn match i3ConfigMouseWarping /^\s*mouse_warping\s\+\(output\|none\)\s\?$/ contains=i3ConfigMouseWarpingKeyword,i3ConfigMouseWarpingType + +" Focus follows mouse +syn keyword i3ConfigFocusFollowsMouseKeyword focus_follows_mouse contained +syn keyword i3ConfigFocusFollowsMouseType yes no contained +syn match i3ConfigFocusFollowsMouse /^\s*focus_follows_mouse\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusFollowsMouseKeyword,i3ConfigFocusFollowsMouseType + +" Popups during fullscreen mode +syn keyword i3ConfigPopupOnFullscreenKeyword popup_during_fullscreen contained +syn keyword i3ConfigPopuponFullscreenType smart ignore leave_fullscreen contained +syn match i3ConfigPopupOnFullscreen /^\s*popup_during_fullscreen\s\+\w\+\s\?$/ contains=i3ConfigPopupOnFullscreenKeyword,i3ConfigPopupOnFullscreenType + +" Focus wrapping +syn keyword i3ConfigFocusWrappingKeyword force_focus_wrapping focus_wrapping contained +syn keyword i3ConfigFocusWrappingType yes no contained +syn match i3ConfigFocusWrapping /^\s*\(force_\)\?focus_wrapping\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigFocusWrappingKeyword + +" Forcing Xinerama +syn keyword i3ConfigForceXineramaKeyword force_xinerama contained +syn match i3ConfigForceXinerama /^\s*force_xinerama\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigForceXineramaKeyword + +" Automatic back-and-forth when switching to the current workspace +syn keyword i3ConfigAutomaticSwitchKeyword workspace_auto_back_and_forth contained +syn match i3ConfigAutomaticSwitch /^\s*workspace_auto_back_and_forth\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigAutomaticSwitchKeyword + +" Delay urgency hint +syn keyword i3ConfigTimeUnit ms contained +syn keyword i3ConfigDelayUrgencyKeyword force_display_urgency_hint contained +syn match i3ConfigDelayUrgency /^\s*force_display_urgency_hint\s\+\d\+\s\+ms\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDelayUrgencyKeyword,i3ConfigNumber,i3ConfigTimeUnit + +" Focus on window activation +syn keyword i3ConfigFocusOnActivationKeyword focus_on_window_activation contained +syn keyword i3ConfigFocusOnActivationType smart urgent focus none contained +syn match i3ConfigFocusOnActivation /^\s*focus_on_window_activation\s\+\(smart\|urgent\|focus\|none\)\s\?$/ contains=i3ConfigFocusOnActivationKeyword,i3ConfigFocusOnActivationType + +" Automatic back-and-forth when switching to the current workspace +syn keyword i3ConfigDrawingMarksKeyword show_marks contained +syn match i3ConfigDrawingMarks /^\s*show_marks\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDrawingMarksKeyword + +" Group mode/bar +syn keyword i3ConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained +syn region i3ConfigBlock start=+.*s\?{$+ end=+^}$+ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend + +" Line continuation +syn region i3ConfigLineCont start=/^.*\\$/ end=/^.*$/ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend + +" Includes with relative paths to config files +syn keyword swayConfigInclude include contained +syn match swayConfigFile /^include\s\(\~\?\/.*$\|\.\{0,2}\/.*$\)/ contains=swayConfigInclude + +" Define the highlighting. +hi! def link i3ConfigError Error +hi! def link i3ConfigTodo Todo +hi! def link i3ConfigComment Comment +hi! def link i3ConfigFontContent Type +hi! def link i3ConfigFocusOnActivationType Type +hi! def link i3ConfigPopupOnFullscreenType Type +hi! def link i3ConfigOrientationKeyword Type +hi! def link i3ConfigMouseWarpingType Type +hi! def link i3ConfigFocusFollowsMouseType Type +hi! def link i3ConfigGapStyleKeyword Type +hi! def link i3ConfigTitleAlignKeyword Type +hi! def link i3ConfigSmartGapKeyword Type +hi! def link i3ConfigSmartBorderKeyword Type +hi! def link i3ConfigLayoutKeyword Type +hi! def link i3ConfigBorderStyleKeyword Type +hi! def link i3ConfigEdgeKeyword Type +hi! def link i3ConfigAction Type +hi! def link i3ConfigCommand Type +hi! def link i3ConfigOutput Type +hi! def link i3ConfigWindowCommandSpecial Type +hi! def link i3ConfigFocusWrappingType Type +hi! def link i3ConfigUnitOr Type +hi! def link i3ConfigFontSize Constant +hi! def link i3ConfigColor Constant +hi! def link i3ConfigNumber Constant +hi! def link i3ConfigUnit Constant +hi! def link i3ConfigVariableAndModifier Constant +hi! def link i3ConfigTimeUnit Constant +hi! def link i3ConfigModifier Constant +hi! def link i3ConfigString Constant +hi! def link i3ConfigNegativeSize Constant +hi! def link i3ConfigFontSeparator Special +hi! def link i3ConfigVariableModifier Special +hi! def link i3ConfigSizeSpecial Special +hi! def link i3ConfigWindowSpecial Special +hi! def link i3ConfigAssignSpecial Special +hi! def link i3ConfigFontNamespace PreProc +hi! def link i3ConfigBindArgument PreProc +hi! def link i3ConfigNoStartupId PreProc +hi! def link i3ConfigFontKeyword Identifier +hi! def link i3ConfigBindKeyword Identifier +hi! def link i3ConfigOrientation Identifier +hi! def link i3ConfigGapStyle Identifier +hi! def link i3ConfigTitleAlign Identifier +hi! def link i3ConfigSmartGap Identifier +hi! def link i3ConfigSmartBorder Identifier +hi! def link i3ConfigLayout Identifier +hi! def link i3ConfigBorderStyle Identifier +hi! def link i3ConfigEdge Identifier +hi! def link i3ConfigFloating Identifier +hi! def link i3ConfigCommandKeyword Identifier +hi! def link i3ConfigNoFocusKeyword Identifier +hi! def link i3ConfigInitializeKeyword Identifier +hi! def link i3ConfigAssignKeyword Identifier +hi! def link i3ConfigResourceKeyword Identifier +hi! def link i3ConfigExecKeyword Identifier +hi! def link i3ConfigWorkspaceKeyword Identifier +hi! def link i3ConfigClientColorKeyword Identifier +hi! def link i3ConfigInterprocessKeyword Identifier +hi! def link i3ConfigMouseWarpingKeyword Identifier +hi! def link i3ConfigFocusFollowsMouseKeyword Identifier +hi! def link i3ConfigPopupOnFullscreenKeyword Identifier +hi! def link i3ConfigFocusWrappingKeyword Identifier +hi! def link i3ConfigForceXineramaKeyword Identifier +hi! def link i3ConfigAutomaticSwitchKeyword Identifier +hi! def link i3ConfigDelayUrgencyKeyword Identifier +hi! def link i3ConfigFocusOnActivationKeyword Identifier +hi! def link i3ConfigDrawingMarksKeyword Identifier +hi! def link i3ConfigBlockKeyword Identifier +hi! def link i3ConfigVariable Statement +hi! def link i3ConfigArbitraryCommand Type +hi! def link swayConfigInclude Identifier +hi! def link swayConfigFile Constant +hi! def link swayConfigFloatingModifier Identifier +hi! def link swayConfigFloatingMouseAction Type +hi! def link swayConfigFocusKeyword Type +hi! def link swayConfigFocusType Identifier + +let b:current_syntax = "i3" diff --git a/home/user/.vim/after/syntax/mustache.vim b/home/user/.vim/after/syntax/mustache.vim @@ -0,0 +1 @@ +runtime! syntax/handlebars.vim diff --git a/home/user/.vimrc b/home/user/.vimrc @@ -0,0 +1,69 @@ +let mapleader="," + +" define a folder for extra .vim files, keeps the .vimrc itself from growing too big +let g:vim_extras_home = get(g:, 'vim_extras_home', expand('$HOME/.config/vim')) + +execute 'source' g:vim_extras_home.'/spanishkeys.vim' +execute 'source' g:vim_extras_home.'/prog_funcs.vim' +execute 'source' g:vim_extras_home.'/statusline.vim' +execute 'source' g:vim_extras_home.'/sql_query.vim' +execute 'source' g:vim_extras_home.'/colours.vim' + +" get vim to recognize filetype, for getting the FileType event, load plugin for filetype (if any), load indent for filetype (if any) +filetype plugin indent on +" show existing tab with 4 spaces width +set tabstop=4 +" when indenting with '>', use 4 spaces width +set shiftwidth=4 +" press tab, get 4 spaces +set expandtab + +" disables automatic commenting on newline +autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + +" remebers position of cursor on closed file +autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | execute "normal! g`\"" | endif + +" auto-highlight trailing spaces at the end of line +autocmd BufWinEnter,InsertLeave <buffer> match Error /\s\+$/ +autocmd InsertEnter <buffer> match Error /\s\+\%#\@<!$/ +autocmd BufWinLeave <buffer> call clearmatches() + +" syntax highlight for certain files +augroup ft_detection_all + autocmd! + autocmd BufNewFile,BufRead /etc/i3/config set filetype=i3config + autocmd BufNewFile,BufRead *.handlebars,*.hdbs,*.hbs,*.hb set filetype=html.handlebars + autocmd BufNewFile,BufRead *.mustache,*.hogan,*.hulk,*.hjs set filetype=html.mustache +augroup end + +" calls some git related functions for the statusbar +augroup GetGitBranch + autocmd! + autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch() +augroup end + +" a few filetype based maps, for saving a keystroke here and there +" <C-o> <- run next command in Normal Mode, <C-m> to insert enter +autocmd FileType html,html.handlebars inoremap <leader>! <!--<Space><Space>--><C-o>3h +autocmd FileType html,html.handlebars inoremap <leader>t <table><C-m><C-m></table><C-o>^<C-o>k +autocmd FileType html.handlebars inoremap <leader>c {{!--<Space><Space>--}}<C-o>4h +autocmd FileType javascript inoremap <leader>c console.log('');<C-o>2h +autocmd FileType html,javascript nnoremap <leader>s :call SwitchJS()<CR> +autocmd FileType sql nnoremap <leader>q :call RunSQLFile()<CR> + +" when pasting something from another file, we don't want auto-indent +nnoremap <leader>p :set invpaste<CR> + +" source ~/.vimrc (useful to test something simple out) +nnoremap <leader><F2> :w<CR>:source %<CR> + +" save as root +cnoremap w!! w !sudo -A tee > /dev/null % + +" sometimes I need Spanish accents but just in vim for taking notes +nnoremap <leader>e :call ToggleSpanishKeys()<CR> + +" functions to help create or format certain code comments +nnoremap <leader>x :call ToMultiLineComment()<CR> +nnoremap <leader>y :call OneLineMultiComment()<CR> diff --git a/home/user/scripts/commentbox.sh b/home/user/scripts/commentbox.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +### commentbox ################################################################# +# A simple script that makes it easy to generate a nicely formatted comment # +# box around text (that looks something like this the one here) # +################################################################################ + +if [ -t 0 ]; then + echo "USAGE: This function reads from standard input for the contents of the comment box." + exit 1 +fi + +# Grab stdin +STDIN=$(cat -) + +# Check for the correct number of args +#if [ $# -eq 0 ]; then +# echo "USAGE: ${0##*/} <title>" 1>&2 +# exit 1 +#fi + +# The number of columns to use for wrapping, +# minus 4 so the comment box doesn't exceed +# this value is variable, but caps at this value +# for small text, the box will be less wide + +COLUMNS=76 + +if [ ${#STDIN} -lt $COLUMNS ]; then + COLUMNS=${#STDIN} +fi + +if [ ${#1} -ge $COLUMNS ]; then + echo "Title is too long! Can not draw box." + exit 1 +fi + +if [ $COLUMNS -eq 0 ]; then + echo "Missing input!" + exit 1 +fi + +# The border to print +BORDER='' + +# Generate the border to be used along the +#+ top and bottom of the text. +for f in $(seq $((COLUMNS + 4))); do + BORDER=${BORDER}'#' +done + +# Print the top border +BORDER_TOP=$(awk -v title="$1" -v border_len=$COLUMNS 'BEGIN{printf "## "title" ";} END{while(length($0)<(border_len)){$0=$0"#"; } print substr($0, 1, border_len-length(title));}') + +if [ -z "$1" ]; then + BORDER_TOP=${BORDER} +fi + +echo $BORDER_TOP + + +# Print the user's message +while read line; do + printf "# %-${COLUMNS}s #\n" "$line" +done < <(fold -w ${COLUMNS} -s << EOF +$STDIN +EOF +) + +# Print the bottom border +echo ${BORDER} diff --git a/home/user/scripts/dmenu_music b/home/user/scripts/dmenu_music @@ -0,0 +1,59 @@ +#!/bin/bash + +MPC="mpc -h 127.0.0.1 -p 6664 " +PLAYLIST_DIR="$HOME/Music/playlists/" +MUSIC_DIR="$HOME/Music/" + +OPT=$(echo -e "0: Load Playlist\n1: Play Playlist\n2: Create New Playlist\n3: Add song to Playlist\n4: Remove song from Playlist\n5: Clear Playlist\n6: Update DB\n7: Toggle Random\n8: Stop Music" | dmenu -p "Select an option..." | awk 'BEGIN{FS=":"}{print $1}') + +if [[ "$OPT" = "0" ]]; then + PLAYLIST=$(find "$PLAYLIST_DIR" -maxdepth 1 -type f -regextype posix-extended -regex ".*\.m3u$" | sed -E 's/(.*)+\/([^/]+)(\.m3u$)/\2/' | dmenu -l 20 -i -p 'Open which playlist? (type "any" for random)') + notify-send $(${MPC}load $PLAYLIST) +elif [[ "$OPT" = "1" ]]; then + EXISTS_CURRENT_PLAYLIST=$($MPC playlist | wc -l) + if [[ $EXISTS_CURRENT_PLAYLIST -gt 0 ]]; then + ${MPC}play + else + notify-send "No playlist has been selected" + fi +elif [[ "$OPT" = "2" ]]; then + NEW_PL_NAME=$(dmenu -i -p 'Enter filename') + if [ -f ${PLAYLIST_DIR}/${NEW_PL_NAME}.m3u ]; then + notify-send "File already exists!" + else + cat "" > ${PLAYLIST_DIR}/${NEW_PL_NAME}.m3u + if [ -f ${PLAYLIST_DIR}/${NEW_PL_NAME}.m3u ]; then + notify-send "Playlist ${NEW_PL_NAME} created!" + fi + fi +elif [[ "$OPT" = "3" ]]; then + MUSIC_FILE=$(find "$MUSIC_DIR" -type f -regextype posix-extended -regex ".*\.mp3$" | dmenu -l 20 -p "Select a file...") + if [ ! -f "$MUSIC_FILE" ]; then + notify-send "No file was found!" + else + OPT_PLAYLIST=$(find "$PLAYLIST_DIR" -maxdepth 1 -type f -regextype posix-extended -regex ".*\.m3u$" | sed -E 's/(.*)+\/([^/]+\.m3u$)/\2/' | dmenu -l 20 -i -p 'Append to which playlist?') + REAL_OPT_PLAYLIST=${PLAYLIST_DIR}${OPT_PLAYLIST} + if [[ $(grep -c "$MUSIC_FILE" "$REAL_OPT_PLAYLIST") -gt 0 ]]; then + notify-send "File already in playlist $OPT_PLAYLIST" + else + echo "$MUSIC_FILE" >> "$REAL_OPT_PLAYLIST" + notify-send "File added to playlist $OPT_PLAYLIST" + fi + fi +elif [[ "$OPT" = "4" ]]; then + OPT_PLAYLIST=$(find "$PLAYLIST_DIR" -maxdepth 1 -type f -regextype posix-extended -regex ".*\.m3u$" | sed -E 's/(.*)+\/([^/]+\.m3u$)/\2/' | dmenu -l 20 -i -p 'Append to which playlist?') + REAL_OPT_PLAYLIST=${PLAYLIST_DIR}${OPT_PLAYLIST} + TARGET_SONG=$(cat "$REAL_OPT_PLAYLIST" | dmenu -l 20 -p "Remove which song?") + TARGET_LINE_NUMBER=$(grep -En "$TARGET_SONG" "$REAL_OPT_PLAYLIST" | awk 'BEGIN{FS=":"}{print $1}') + sed -i "${TARGET_LINE_NUMBER}d" file + notify-send "Song removed from playlist $OPT_PLAYLIST" +elif [[ "$OPT" = "5" ]]; then + ${MPC}clear + notify-send "Playlist cleared!" +elif [[ "$OPT" = "6" ]]; then + notify-send $(${MPC}update) +elif [[ "$OPT" = "7" ]]; then + ${MPC}random && notify-send $(${MPC}status | awk '(NR==3){match($0, /random: [a-zA-Z]+/, m); print m[0];}') +elif [[ "$OPT" = "8" ]]; then + ${MPC}stop +fi diff --git a/home/user/scripts/wordpractice b/home/user/scripts/wordpractice @@ -0,0 +1,91 @@ +#!/bin/bash + +# A crappy little script for myself to help practice memorizing spanish words. Each text file acts as a kind of pack of flashcards. + +function summon_dmenu() { + DIRECTORY="$HOME/spanish_study/vocabulary/" + FILE=${DIRECTORY}$(find "$DIRECTORY" -maxdepth 1 -type f -regextype posix-extended -regex ".*\.txt$" | sed -E 's/(.*)+\/([^/]+\.txt$)/\2/' | dmenu -l 20 -i -p 'Open which file? (type "any" for random)') + + if [ $FILE = ${DIRECTORY}"any" ]; then + FILE=$(pick_random_file) + fi + + if [ ! -f $FILE ]; then + echo "Missing file!" + exit 1 + fi + + echo "To exit, answer with :q to quit when prompted for an answer" +} + +function pick_random_file() { + + CHOSEN_FILE=$(ls -d ${DIRECTORY}/* | grep -v ${FILE} | awk -v x=$RANDOM 'BEGIN{srand(x);}{line[NR]=$0;}END{print line[(int(rand()*NR+1))];}') + echo $CHOSEN_FILE +} + +function prepare_file() { + TEMPFILE=$(mktemp --suffix=.txt) + cat $FILE > $TEMPFILE #we don't want to modify the original file, even accidentally +} + +function cleanup_file() { + rm $TEMPFILE +} + +function prompt_user() { + FLENGTH=$(awk 'END{print NR}' $TEMPFILE) + + if [[ $FLENGTH -eq 0 ]]; then + echo "Congratulations, you've answered every question!" + cleanup_file + read -p "Another? (y/n) " RETRY + if [[ "$RETRY" == "y" ]]; then + main + fi + exit 1 + fi + + # we want to be able to pick a random word to test from the file + function random_num() { + awk -v y=$1 -v x=$RANDOM 'BEGIN{srand(x); print int(rand()*y+1)}' + } + + LINE=$(random_num $FLENGTH) + + CHOSEN_LINE=$(awk -v LINE=$LINE '{if(NR==LINE){print $0}}' $TEMPFILE) + + ANSWER=$(echo $CHOSEN_LINE | awk 'BEGIN{FS=":"}{gsub(/^[ ]+|[ ]+$/, "", $2); print $2}') + + QUESTION=$(echo $CHOSEN_LINE | awk 'BEGIN{FS=":"}{gsub(/^[ ]+|[ ]+$/, "", $1); print "What does \x22"$1"\x22 mean?";}') + + read -p "$QUESTION " INPUT + + if [[ "$INPUT" == ":q" ]]; then + echo "Bye" + cleanup_file + exit 1 + fi + + INPUT_LC=$(echo "$INPUT" | awk '{print tolower($0)}') + ANSWER_LC=$(echo "$ANSWER" | awk '{print tolower($0)}') + + if [[ "$INPUT_LC" == "$ANSWER_LC" ]]; then + echo "Correct." + sed -i "${LINE}d" $TEMPFILE + else + echo "Incorrect." + echo "The answer should have been \"${ANSWER}\"" + fi +} + +function main() { + summon_dmenu + prepare_file + + while true; do + prompt_user + done +} + +main diff --git a/misc/disable_recents_nemo b/misc/disable_recents_nemo @@ -0,0 +1,7 @@ +#!/bin/bash + +#disable recents tab in nemo file browser + +rm $HOME/.local/share/recently-used.xbel +touch $HOME/.local/share/recently-used.xbel +sudo chattr +i $HOME/.local/share/recently-used.xbel diff --git a/usr/share/i3blocks/bandwidth b/usr/share/i3blocks/bandwidth @@ -0,0 +1,90 @@ +#!/bin/bash +# Copyright (C) 2012 Stefan Breunig <stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de> +# Copyright (C) 2014 kaueraal +# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + INTERFACE=$BLOCK_INSTANCE +else + INTERFACE=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +# Issue #36 compliant. +if ! [ -e "/sys/class/net/${INTERFACE}/operstate" ] || ! [ "`cat /sys/class/net/${INTERFACE}/operstate`" = "up" ] +then + echo "$INTERFACE down" + echo "$INTERFACE down" + echo "#FF0000" + exit 0 +fi + +# path to store the old results in +path="/dev/shm/$(basename $0)-${INTERFACE}" + +# grabbing data for each adapter. +read rx < "/sys/class/net/${INTERFACE}/statistics/rx_bytes" +read tx < "/sys/class/net/${INTERFACE}/statistics/tx_bytes" + +# get time +time=$(date +%s) + +# write current data if file does not exist. Do not exit, this will cause +# problems if this file is sourced instead of executed as another process. +if ! [[ -f "${path}" ]]; then + echo "${time} ${rx} ${tx}" > "${path}" + chmod 0666 "${path}" +fi + +# read previous state and update data storage +read old < "${path}" +echo "${time} ${rx} ${tx}" > "${path}" + +# parse old data and calc time passed +old=(${old//;/ }) +time_diff=$(( $time - ${old[0]} )) + +# sanity check: has a positive amount of time passed +[[ "${time_diff}" -gt 0 ]] || exit + +# calc bytes transferred, and their rate in byte/s +rx_diff=$(( $rx - ${old[1]} )) +tx_diff=$(( $tx - ${old[2]} )) +rx_rate=$(( $rx_diff / $time_diff )) +tx_rate=$(( $tx_diff / $time_diff )) + +# shift by 10 bytes to get KiB/s. If the value is larger than +# 1024^2 = 1048576, then display MiB/s instead + +# incoming +echo -n "🔻 " +rx_kib=$(( $rx_rate >> 10 )) +if [[ "$rx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $rx_kib / 1024" | bc`" +else + echo -n "${rx_kib}K" +fi + +echo -n " " + +# outgoing +echo -n "🔺 " +tx_kib=$(( $tx_rate >> 10 )) +if [[ "$tx_rate" -gt 1048576 ]]; then + printf '%sM' "`echo "scale=1; $tx_kib / 1024" | bc`" +else + echo -n "${tx_kib}K" +fi diff --git a/usr/share/i3blocks/cpu_usage b/usr/share/i3blocks/cpu_usage @@ -0,0 +1,9 @@ +#!/bin/bash + +IDLE=$(mpstat 1 1 | grep Average | awk '{print $NF}') +CPU=$(echo "100 - $IDLE" | bc -l) + +echo "${CPU}%" + + + diff --git a/usr/share/i3blocks/datetime b/usr/share/i3blocks/datetime @@ -0,0 +1,8 @@ +#!/bin/bash + +case "$BLOCK_BUTTON" in + 1) $TERMINAL -e calcurse ;; +esac + + +echo $(date '+%Y-%m-%d %H:%M:%S'); diff --git a/usr/share/i3blocks/disk b/usr/share/i3blocks/disk @@ -0,0 +1,3 @@ +#!/bin/sh + +df -Phl $HOME | awk '(NR>1){print $4" ("$5")"}' diff --git a/usr/share/i3blocks/iface b/usr/share/i3blocks/iface @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> +# Copyright (C) 2014 Alexander Keller <github@nycroth.com> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +#------------------------------------------------------------------------ + +# Use the provided interface, otherwise the device used for the default route. +if [[ -n $BLOCK_INSTANCE ]]; then + IF=$BLOCK_INSTANCE +else + IF=$(ip route | awk '/^default/ { print $5 ; exit }') +fi + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${IF} ]] && exit + +#------------------------------------------------------------------------ + +if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then + echo down # full text + echo down # short text + echo \#FF0000 # color + exit +fi + +case $1 in + -4) + AF=inet ;; + -6) + AF=inet6 ;; + *) + AF=inet6? ;; +esac + +# if no interface is found, use the first device with a global scope +IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit") + +case $BLOCK_BUTTON in + 3) echo -n "$IPADDR" | xclip -q -se c ;; +esac + +#------------------------------------------------------------------------ + +echo "$IPADDR" # full text +echo "$IPADDR" # short text diff --git a/usr/share/i3blocks/memory b/usr/share/i3blocks/memory @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright (C) 2014 Julien Bonjean <julien@bonjean.info> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + # full text + if (type == "swap") + printf("%.1fG\n", (swap_total-swap_free)/1024/1024) + else + printf("%.1fG\n", mem_free/1024/1024) + + # TODO: short text + + # TODO: color (if less than X%) +} +' /proc/meminfo diff --git a/usr/share/i3blocks/music b/usr/share/i3blocks/music @@ -0,0 +1,9 @@ +#!/bin/bash +MPC="mpc -h 127.0.0.1 -p 6664 " +IS_PLAYING=$($MPC status | awk '{if($0 ~ /playing|paused/){printf "Y"}else{printf "N"}}') + +if [[ "$IS_PLAYING" =~ Y ]]; then + echo $($MPC status | awk '{if(NR==1){x=$0}if(NR==2){y=$0}}END{printf x" "y;}' | sed -E 's/\.mp3//g' ) +else + echo "no music playing" +fi diff --git a/usr/share/i3blocks/volume b/usr/share/i3blocks/volume @@ -0,0 +1,14 @@ +#!/bin/bash + +#technically, this is the volume for the left speaker, but if the left and right speaker are toggled together +#then this is OK. + +IS_TOGGLED_OFF=$(amixer -D pulse get Master | grep -Ec '\[off\]') + +if [[ "$IS_TOGGLED_OFF" -eq 0 ]]; then + MASTER_VOLUME=$(amixer -D pulse get Master | grep -Eo -m1 '[0-9]{1,3}%') +else + MASTER_VOLUME="muted" +fi + +echo $MASTER_VOLUME