From 381aaffe4ed3caa0f1356b720f6d4fc0de5b1f8f Mon Sep 17 00:00:00 2001 From: davidovski Date: Mon, 16 May 2022 00:48:34 +0100 Subject: removed bash and added mkshrc --- config/vim/plugin/hare.vim | 78 ++++++++++++++++++++++++++++++++++++++++++ mkshrc | 56 ++++++++++++++++++++++++++++++ scripts/bg.sh | 3 +- scripts/cinema.sh | 2 +- scripts/fzf-bash-completion.sh | 4 +-- scripts/gamma.sh | 2 +- scripts/links-launcher | 10 ++++++ scripts/lock | 3 +- scripts/powermenu | 1 + scripts/record_window.sh | 19 ++++++++++ scripts/screenshot | 2 +- scripts/tablet | 4 +-- scripts/websearch | 17 +++++---- sh_aliases | 74 +++++++++++++++++++++++++++++++++++++++ 14 files changed, 259 insertions(+), 16 deletions(-) create mode 100644 config/vim/plugin/hare.vim create mode 100644 mkshrc create mode 100755 scripts/links-launcher create mode 100755 scripts/record_window.sh create mode 100644 sh_aliases diff --git a/config/vim/plugin/hare.vim b/config/vim/plugin/hare.vim new file mode 100644 index 0000000..ad8cd3a --- /dev/null +++ b/config/vim/plugin/hare.vim @@ -0,0 +1,78 @@ +" Vim syntax file +" Language: Hare + +if exists("b:current_syntax") + finish +endif + +syn case match +syn keyword hareKeyword let const fn def type static export defer _ +syn keyword hareBranch for return break continue yield +syn keyword hareConditional if else match switch +syn keyword hareLabel case +syn keyword hareBuiltin len offset free alloc assert append abort delete insert +syn keyword hareBuiltin vastart vaarg vaend +syn keyword hareOperator is as +syn match hareType "\vsize((\_\s|//.*)*\()@!" +syn match hareBuiltin "\vsize((\_\s|//.*)*\()@=" +syn match harePreProc "^use .*;" +syn match harePreProc "@[a-z]*" +syn match hareOperator "\.\.\." "\.\." + +syn region hareString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+ +syn region hareString start=+`+ end=+`+ + +"adapted from c.vim +"integer number, or floating point number without a dot and with "f". +syn match hareNumbers display transparent "\v<\d" contains=hareNumber,hareOctal,hareBinary,hareFloat +syn match hareNumber display contained "\v\d+(e[-+]?\d+)?(z|[iu](8|16|32|64)?)?" +"hex number +syn match hareNumber display contained "\v0x\x+(z|[iu](8|16|32|64)?)?" +"octal number +syn match hareOctal display contained "\v0o\o+(z|[iu](8|16|32|64)?)?" +"binary number +syn match hareBinary display contained '\v0b[01]+(z|[iu](8|16|32|64)?)?' +syn match hareFloat display contained "\v\d+(e[-+]?\d+)?(f32|f64)" +"floating point number, with dot, optional exponent +syn match hareFloat display contained "\v\d+\.\d+(e[-+]?\d+)?(f32|f64)?" + +syn match hareSpaceError display excludenl "\v\s+$" +syn match hareSpaceError display "\v +\t"me=e-1 + +syn keyword hareTodo contained TODO FIXME XXX +syn region hareComment start="//" end="$" contains=hareTodo,@Spell + +syn keyword hareType u8 u16 u32 u64 i8 i16 i32 i64 +syn keyword hareType uint int +syn keyword hareType uintptr +syn keyword hareType f32 f64 +syn keyword hareType bool +syn keyword hareType char str +syn keyword hareType void +syn keyword hareType struct union +syn keyword hareType enum +syn keyword hareType nullable +syn keyword hareType rune +syn keyword hareType valist +syn keyword hareNull null +syn keyword hareBoolean true false + +hi def link hareBinary Number +hi def link hareBoolean Boolean +hi def link hareBranch Repeat +hi def link hareBuiltin Function +hi def link hareComment Comment +hi def link hareConditional Conditional +hi def link hareFloat Number +hi def link hareKeyword Keyword +hi def link hareLabel Label +hi def link hareNull Constant +hi def link hareNumber Number +hi def link hareOctal Number +hi def link hareOperator Operator +hi def link harePreProc PreProc +hi def link hareString String +hi def link hareTodo Todo +hi def link hareType Type +hi def link hareSpaceError Error +" vim: tabstop=8 shiftwidth=2 expandtab diff --git a/mkshrc b/mkshrc new file mode 100644 index 0000000..8a9023f --- /dev/null +++ b/mkshrc @@ -0,0 +1,56 @@ +#!/bin/mksh +case $- in + *i*) ;; + *) return;; +esac + +export VIMINIT="source ~/.config/vim/vimrc" +export NVIMINIT="source ~/.config/vim/vimrc" + +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias dir='dir --color=auto' + alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +[ -f ~/.sh_aliases ] && . ~/.sh_aliases +[ -f ~/.profile ] && . ~/.profile + +# parse the current branch and status of git to be added to the prompt +function parse_git_branch() { + BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` + if [ ! "${BRANCH}" == "" ] + then + STAT=`parse_git_dirty` + echo " [${BRANCH}${STAT}]" + else + echo "" + fi +} + +function parse_git_dirty { + status=`git status 2>&1 | tee` + dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` + untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` + ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"` + newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"` + renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"` + deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"` + bits='' + [ "${renamed}" == "0" ] && bits=">${bits}" + [ "${ahead}" == "0" ] && bits="*${bits}" + [ "${newfile}" == "0" ] && bits="+${bits}" + [ "${untracked}" == "0" ] && bits="?${bits}" + [ "${deleted}" == "0" ] && bits="x${bits}" + [ "${dirty}" == "0" ] && bits="!${bits}" + [ ! "${bits}" == "" ] && echo " ${bits}" || echo "" +} + +bind '^L=clear-screen' + +export PS1=$(echo -e "\e[0;97m\${PWD/#\$HOME/\~}\e[0;37m\`parse_git_branch\` > \e[0;0m") diff --git a/scripts/bg.sh b/scripts/bg.sh index 747aa20..decf4f1 100755 --- a/scripts/bg.sh +++ b/scripts/bg.sh @@ -1,2 +1,3 @@ #!/bin/sh -feh --force-aliasing --bg-fill ~/.config/bg +feh --force-aliasing --bg-tile ~/.config/dither.png +#feh --force-aliasing --bg-fill ~/.config/bg diff --git a/scripts/cinema.sh b/scripts/cinema.sh index c453260..46c7082 100755 --- a/scripts/cinema.sh +++ b/scripts/cinema.sh @@ -1,3 +1,3 @@ #!/bin/sh -MAIN_DP=DP-2; +MAIN_DP=DP-0; v=$(xrandr --current --verbose | grep "Brightness" | cut -f2 -d " " | tr '\n' '*' | rev | cut -c 2- | rev | sed -e "s/$/==1/" | bc -l | grep -q 0 && echo 1 || echo 0); xrandr | grep " connected" | cut -f1 -d " " | while read -r line; do echo $line | grep -q $MAIN_DP && : || xrandr --output $line --brightness $v; done diff --git a/scripts/fzf-bash-completion.sh b/scripts/fzf-bash-completion.sh index 9a63e15..337e908 100644 --- a/scripts/fzf-bash-completion.sh +++ b/scripts/fzf-bash-completion.sh @@ -42,9 +42,9 @@ _fzf_bash_completion_flatten_subshells() { printf '%s\n' "$line$buffer" buffer= fi - done < <(tac) + done < <(cat) printf '%s\n' "$buffer" - ) | tac + ) | cat } _fzf_bash_completion_find_matching_bracket() { diff --git a/scripts/gamma.sh b/scripts/gamma.sh index 0117dd5..cd9433f 100755 --- a/scripts/gamma.sh +++ b/scripts/gamma.sh @@ -1,5 +1,5 @@ #!/bin/bash -MAIN_DP=DP-2; +MAIN_DP=DP-0; v=$1 diff --git a/scripts/links-launcher b/scripts/links-launcher new file mode 100755 index 0000000..eef2a2f --- /dev/null +++ b/scripts/links-launcher @@ -0,0 +1,10 @@ +#!/bin/sh + +startpage=${1:-https://search.davidovski.xyz/} + +bin="$(which links || which xlinks)" + +[ "${#DISPLAY}" = "0" ] || opts="-g -html-g-text-color 0xf58f44 -html-g-background-color 0x191919 -font /home/david/.fonts/ttf-mononoki/mononoki-Regular.ttf" + +$bin $opts $startpage + diff --git a/scripts/lock b/scripts/lock index 01820fb..d0b8d36 100755 --- a/scripts/lock +++ b/scripts/lock @@ -1,2 +1,3 @@ #!/bin/sh -i3lock-fancy -p -t '' +#i3lock-fancy -p -t '' +slock diff --git a/scripts/powermenu b/scripts/powermenu index 49b8f3e..a1ac5f4 100755 --- a/scripts/powermenu +++ b/scripts/powermenu @@ -1,2 +1,3 @@ #!/bin/sh + printf "suspend\nreboot\npoweroff\nhibernate" | rofi -dmenu -p "systemctl" | xargs -r systemctl diff --git a/scripts/record_window.sh b/scripts/record_window.sh new file mode 100755 index 0000000..841b756 --- /dev/null +++ b/scripts/record_window.sh @@ -0,0 +1,19 @@ +#!/bin/sh +info=/tmp/wminfo + +xwininfo > /tmp/wminfo + +geom=$(cat $info | grep "geometry" | cut -d' ' -f4) + +width=$(cat $info | grep Width | cut -d' ' -f4) +height=$(cat $info | grep Height | cut -d' ' -f4) + +size="${width}x${height}" +position=+$(echo $geom | cut -d'+' -f2- | sed "s/+/,/g") + +filename=$(date +"$HOME/pics/screenshot/%F_%T.mp4") + +echo $size and $position +ffmpeg -y -f x11grab -video_size $size -i $position $filename + +rm $info diff --git a/scripts/screenshot b/scripts/screenshot index 626671c..d0df6a8 100755 --- a/scripts/screenshot +++ b/scripts/screenshot @@ -1,2 +1,2 @@ #!/bin/bash -maim -su /dev/stdout | tee >(xclip -selection clipboard -t image/png) > $(date +"$HOME/pics/screenshot/%F_%T.png") +maim -su /dev/stdout | tee $(date +"$HOME/pics/screenshot/%F_%T.png") | xclip -selection clipboard -t image/png diff --git a/scripts/tablet b/scripts/tablet index 3b49064..ec3eefa 100755 --- a/scripts/tablet +++ b/scripts/tablet @@ -9,10 +9,10 @@ tablet_ratio = (lambda s: float(s[0]) / float(s[1]))(sys.argv[4].split(":")) if #Layout of screens: (x, y, w, h) screens = [ - (3840, 0, 1080, 1920), + (0, 0, 1280, 1024), (1280, 0, 2560, 1440), + (3840, 0, 1080, 1920), (4920, 0, 1080, 1920), - (0, 0, 1280, 1024), ] #TODO find this with xrandr diff --git a/scripts/websearch b/scripts/websearch index 996ddc3..32d8773 100755 --- a/scripts/websearch +++ b/scripts/websearch @@ -1,14 +1,17 @@ #!/bin/sh - -SEARCH_ENGINE="https://search.brave.com/search?q=" -SEARCH_HISTORY=/tmp/.search_history +browser="links-launcher" +SEARCH_ENGINE="https://librex.beparanoid.de/search.php?q=" +SEARCH_HISTORY=$HOME/.local/share/search_history SEARCH=$(cat $SEARCH_HISTORY | dmenu -p "search") -touch $SEARCH_HISTORY +echo "$SEARCH" >> $SEARCH_HISTORY -cat <<< "$SEARCH -$(cat $SEARCH_HISTORY)" > $SEARCH_HISTORY +query=$(echo $SEARCH | sed 's/ /+/g') -brave "$SEARCH_ENGINE$SEARCH" +echo $query | grep -q '(?=^.{5,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)' && { + links-launcher "$query" +} || { + links-launcher "$SEARCH_ENGINE$query" +} diff --git a/sh_aliases b/sh_aliases new file mode 100644 index 0000000..24e7106 --- /dev/null +++ b/sh_aliases @@ -0,0 +1,74 @@ +alias l="ls -lah" + +alias cls="clear" +alias cp="cp -v" +alias gif-for-cli="gif-for-cli -l 0 -c █ --display-mode=truecolor" +alias cdu="cdu -s -dh" +alias dclock="tput civis; watch -t -n1 \"date +%T|toilet --font mono12\"" +alias blank="tput civis ; clear ; read" +alias open="xdg-open 2>/dev/null" +alias sl="ls" +alias resettabletscale='tablet 8 156 1 4:3' +#alias settabletscale="tablet 8 156 2.5063 4:3" +alias settabletscale="tablet 18 155 2 4:3" + +alias gosumemory-default="sudo /home/david/.local/share/gosumemory/gosumemory -path /home/david/.local/share/osu-wine/OSU/Songs" + +alias yta="yt-dlp --no-mtime --add-metadata --no-check-certificate -x -f bestaudio/best" + +alias suspend="i3lock-fancy -p -t ''; systemctl suspend" + +alias vim="nvim" +#alias tablet2='tablet 18 156 2.4' + +rfc() { (for f in */; do du -a "$f" | tail -n+2 | wc -l | xargs printf "%s\t$f\n" ; done) | sort -Vr ;} + +pandoc-md () { + pandoc --pdf-engine=xelatex --variable mainfont="Arial" --variable sansfont=Arial --from markdown -o `basename $1`.pdf $1 +} + +mp4-gif () { + ffmpeg -i $1 -r 15 -vf "scale=360:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" $2 +} + +alias zth="zathura" +alias nb="nb --blog-dir $BLOG_DIR" +alias looking-glass-client="looking-glass-client -G input:rawMouse=yes input:escapekey=119 input:autocapture=yes -k -j" +alias show-keymap="vim qmk_firmware/keyboards/ergo42/keymaps/iksvo/keymap.c" + + +configure () { + vim ~/.config/$1 +} + +bitrate () { + mediainfo Aphrodite_-_Superman_\(dnb\).mp3 | grep 'Bit rate ' + +} + +alias syncdir="sudo rsync -rv --no-perms --no-owner --no-group --delete" +alias chromium-tor="chromium --incognito --proxy-server=socks5://localhost:9050 --user-data-dir=/tmp/tor" +alias chromium-i2p="chromium --incognito --proxy-server=socks5://localhost:4447 --user-data-dir=/tmp/i2p" + +alarmclock () { + sudo rtcwake -m no -t "$(date -d 'tomorrow 07:00:00' '+%s')" && echo 'set alarm for tomorrow at 7am' +} + +# does tail -f on a dir... bit of a hack +# i spelled this wrong on purpose i think +mutlitail1 () { + while true; do + f=$(ls -1 --sort time $@| head -1 | xargs realpath); + tail -$(tput lines) $f; + done; +} + +alias watchdirty="watch grep -e Dirty: -e Writeback: /proc/meminfo" + +passthrough_disable () { + sudo mv /etc/modprobe.d/vfio.conf /etc/modprobe.d/vfio.conf.disabled +} +passthrough_enable () { + sudo mv /etc/modprobe.d/vfio.conf /etc/modprobe.d/vfio.conf.disabled +} +alias links="xlinks -g -html-g-text-color 0xf58f44 -html-g-background-color 0x191919 -font /home/david/.fonts/ttf-mononoki/mononoki-Regular.ttf" -- cgit v1.2.1