Adding some scripts like manpages for fish

This commit is contained in:
Chris Cochrun 2021-01-13 05:17:22 -06:00
parent 37567dbfc3
commit 52542754c8
5 changed files with 264 additions and 0 deletions

27
fish/functions/man.fish Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env fish
function man --description "wrap the 'man' manual page opener to use color in formatting"
# based on this group of settings and explanation for them:
# http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized
# converted to Fish shell syntax thanks to this page:
# http://askubuntu.com/questions/522599/how-to-get-color-man-pages-under-fish-shell/650192
# start of bold:
set -x LESS_TERMCAP_md (set_color --bold blue)
# end of all formatting:
set -x LESS_TERMCAP_me (set_color normal)
# start of standout (inverted colors):
set -x LESS_TERMCAP_so (set_color --bold green)
# end of standout (inverted colors):
set -x LESS_TERMCAP_se (set_color normal)
# (no change I like the default)
# start of underline:
set -x LESS_TERMCAP_us (set_color --underline)
# end of underline:
set -x LESS_TERMCAP_ue (set_color normal)
# (no change I like the default)
command man $argv
end

View file

@ -0,0 +1,133 @@
[data-qb-domain="192.168.1.7"] #sr-header-area {
position: relative !important;
z-index: 1000 !important;
}
[data-qb-domain="192.168.1.7"] .form-control {
border-radius: 50px !important;
border: 1px solid var(--base02) !important;
background-color: var(--base01) !important;
color: var(--base05) !important;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
[data-qb-domain="192.168.1.7"] .btn {
border-radius: 50px !important;
background-color: var(--base01) !important;
color: var(--base05) !important;
border: 1px solid var(--base02) !important;
}
[data-qb-domain="192.168.1.7"] .btn:focus, .btn:hover {
color: var(--base09) !important;
text-decoration: none;
}
[data-qb-domain="192.168.1.7"] .glyphicon {
top: 3px;
}
[data-qb-domain="192.168.1.7"] .img-thumbnail, body {
background-color: var(--base00);
}
[data-qb-domain="192.168.1.7"] body {
font-family: var(--tridactyl-font-family) !important;
font-size: 14px;
line-height: 1.42857143;
color: var(--base05);
}
[data-qb-domain="192.168.1.7"] .tt-dropdown-menu {
background-color: var(--base00);
border: 1px solid var(--base02);
}
[data-qb-domain="192.168.1.7"] .tt-dropdown-menu .tt-suggestion {
color: var(--base05);
}
[data-qb-domain="192.168.1.7"] .highlight {
background: var(--base00);
}
[data-qb-domain="192.168.1.7"] .panel-body {
background: var(--base00);
}
[data-qb-domain="192.168.1.7"] .panel-heading {
background: var(--base01) !important;
color: var(--base05) !important;
}
[data-qb-domain="192.168.1.7"] .search_categories input[type="checkbox"]:checked + label, #categories input[type="checkbox"]:checked + label {
color: var(--base0B);
background-color: var(--base01);
}
[data-qb-domain="192.168.1.7"] .search_categories label, #categories label, .search_categories .input-group-addon, #categories .input-group-addon {
background-color: var(--base00);
border: #DDD 1px solid;
border-right-color: rgb(221, 221, 221);
border-right-style: solid;
border-right-width: 1px;
border-right: none;
color: var(--base05);
}
[data-qb-domain="192.168.1.7"] .label-default {
background-color: var(--base01);
margin-right: 7px;
}
[data-qb-domain="192.168.1.7"] a:focus, a:hover {
color: var(--base0C);
text-decoration: underline;
}
[data-qb-domain="192.168.1.7"] a {
color: var(--base0D)
}
[data-qb-domain="192.168.1.7"] .alert {
color: var(--base08);
background-color: var(--base00)
}
[data-qb-domain="192.168.1.7"] .text-info {
color: var(--base0A);
}
[data-qb-domain="192.168.1.7"] a.text-info:hover {
color: var(--base0B);
}
[data-qb-domain="192.168.1.7"] .container {
width: 1200px
}
[data-qb-domain="192.168.1.7"] div.col-xs-6:nth-child(3) {
visibility: hidden;
}
[data-qb-domain="192.168.1.7"] .searx-navbar {
background: #eee;
height: 2.3rem;
font-size: 1.3rem;
line-height: 1.3rem;
padding: .5rem;
font-weight: 700;
margin-bottom: 1.3rem;
background-color: var(--base01) !important;
color: var(--base05) !important;
visibility: hidden;
}
[data-qb-domain="192.168.1.7"] .searx-navbar .instance a {
color: var(--base05) !important;
margin-left: 2rem;
}

5
scripts/picdates Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env fish
for pic in *.jpg
ls $pic
end

29
scripts/picdates.py Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env python3
import os
from datetime import datetime
dir = os.listdir()
print(dir)
for file in dir:
print(file)
#print(os.stat(file))
modified = datetime.fromtimestamp(os.stat(file).st_mtime)
print(modified)
year = modified.year
# print(year)
# month = modified.month
# print(month)
# day = modified.day
# print(day)
# root, extension = os.path.splitext(file)
# print(extension)
# if not extenstion:
# continue
if year in dir:
print("dir 2020 exists")
break
continue
#os.makedirs(str(year) + '/' + str(month) + '/' + str(day))

70
scripts/yt Executable file
View file

@ -0,0 +1,70 @@
#!/bin/bash
# dependencies: mpv youtube-dl fzf rofi/dmenu
# search videos and playlists on youtube and play them in mpv, without an API
# usage:
# yt asks for input in stdin, prompts using fzf
# yt search query takes input from the passed arg, prompts using fzf
# yt -r takes input and prompts using rofi ($guicmd)
defcmd="fzf"
guicmd="rofi -dmenu -i" #uncomment next line for dmenu
#guicmd="dmenu -i -l 15"
promptcmd="$defcmd"
if [ -z "$*" ]; then
echo -n "Search: "
read -r query
else
case "$1" in
-r) query=$(echo | $guicmd -p "Search: ")
promptcmd="$guicmd -p Video:";;
*) query="$*";;
esac
fi
if [ -z "$query" ]; then exit; fi
# sanitise the query
query=$(sed \
-e 's|+|%2B|g'\
-e 's|#|%23|g'\
-e 's|&|%26|g'\
-e 's| |+|g'\
<<< "$query")
# fetch the results with the $query and
# delete all escaped characters
response="$(curl -s "https://www.youtube.com/results?search_query=$query" |\
sed 's|\\.||g')"
# if unable to fetch the youtube results page, inform and exit
if ! grep -q "script" <<< "$response"; then echo "unable to fetch yt"; exit 1; fi
# regex expression to match video and playlist entries from yt result page
vgrep='"videoRenderer":{"videoId":"\K.{11}".+?"text":".+?[^\\](?=")'
pgrep='"playlistRenderer":{"playlistId":"\K.{34}?","title":{"simpleText":".+?[^\"](?=")'
# grep the id and title
# return them in format id (type) title
getresults() {
grep -oP "$1" <<< "$response" |\
awk -F\" -v p="$2" '{ print $1 "\t" p " " $NF}'
}
# get the list of videos/playlists and their ids in videoids and playlistids
videoids=$(getresults "$vgrep")
playlistids=$(getresults "$pgrep" "(playlist)")
# if there are playlists or videos, append them to list
[ -n "$playlistids" ] && ids="$playlistids\n"
[ -n "$videoids" ] && ids="$ids$videoids"
# url prefix for videos and playlists
videolink="https://youtu.be/"
playlink="https://youtube.com/playlist?list="
# prompt the results to user infinitely until they exit (escape)
while true; do
clear
echo "Choose Video/Playlist to play: "
choice=$(echo -e "$ids" | cut -d' ' -f2 | $promptcmd) # dont show id
if [ -z "$choice" ]; then exit; fi # if esc-ed then exit
id=$(echo -e "$ids" | grep -Fwm1 "$choice" | cut -d' ' -f1) # get id of choice
echo -e "$choice\t($id)"
case $id in
# 11 digit id = video
???????????) mpv "$videolink$id";;
# 34 digit id = playlist
??????????????????????????????????) mpv "$playlink$id";;
*) exit ;;
esac
done