Moved scripts to bin dir.

This commit is contained in:
2018-09-15 12:31:45 -03:00
parent c7464eea4d
commit 5543ac26a6
10 changed files with 10 additions and 0 deletions

9
bin/gdfuse.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
su renato -l -c "google-drive-ocamlfuse -label $1 $*"
exit 0
## gogole-drive-ocaml user renato
#gdfuse#SILVROSA /home/renato/SILVROSA fuse uid=1000,gid=1000,allow_other,user,_netdev 0 0

18
bin/listluatexfonts.texlua Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env texlua
kpse.set_program_name("listluatexfonts")
cachefile = kpse.expand_var("$TEXMFVAR") .. "/luatex-cache/generic/names/luaotfload-names.luc"
fontlist = dofile(cachefile)
assert(fontlist,"Could not load font name database")
local tmp = {}
for _,font in ipairs(fontlist.mappings) do
tmp[#tmp + 1] = font.fontname
end
table.sort(tmp)
for _,fontname in ipairs(tmp) do
print(fontname)
end

3
bin/md2pdf.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
pandoc -s -f markdown -t latex --pdf-engine=lualatex -o $1.pdf $1 metadata.yml latex.yml

6
bin/pandoc-md2pdf.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
ORIGIN=$1
DEST=${ORIGIN%.*}
pandoc -f markdown -t latex --pdf-engine=xelatex -V papersize=a4 -V documentclass=article -V margin-top=1in -V margin-left=1in -V margin-right=1in -V margin-bottom=1in -V fontfamily=times -V fontsize=12pt -V lang=pt-BR -o $DEST.pdf $ORIGIN; xdg-open $DEST.pdf

2
bin/sha1base64c30.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
echo $1 | sha1sum | head -c 30 | xxd -r -p | base64

3
bin/speedtest.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
# setup : pip3 install speedtest-cli jsonf
speedtest-cli --server 10506 --share --json | python3 -m json.tool

9
bin/ssh-to-zsh.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
# $1 = IP ADDR
# alt: ssh -t [ip] zsh
ssh -t $1 'PS1='\''${${functions[zsh_directory_name]::="
unsetopt promptsubst
unfunction zsh_directory_name
unset PS1
. /home/renato/.zshrc
"}+}${(D):-}${PS1=%m%# }'\' exec zsh -o promptsubst -f

40
bin/vnc.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
DEFAULT_DISPLAY=:0
X11VNC_DISPLAY="$DEFAULT_DISPLAY"
if [ -x /usr/bin/x11vnc ]; then
[ "$1" == '-nocache' ] && CACHE_FLAG='-noncache' || CACHE_FLAG='-noncache'
[ "$2" == '-guess' ] && GUESS_FLAG='-auth guess' || GUESS_FLAG=''
[ -f /root/.vnc/passwd ] && PASSWORD="/root/.vnc/passwd"
[ -f $HOME/.vnc/passwd ] && PASSWORD="$HOME/.vnc/passwd"
[ ! -z "$PASSWORD" ] && x11vnc -display $X11VNC_DISPLAY -xkb -rfbauth $PASSWORD -rfbport 5900 -shared -forever -nowf -norc -notruecolor -bg $GUESS_FLAG $CACHE_FLAG -noxdamage
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "\n*********************************************************************"
echo "*** Could not start x11vnc! Trying again with gdm MAGIC_COOKIE! ***"
echo "*********************************************************************\n"
# Old GDM location for Ubuntu <= 17.10
MAGIC_COOKIE_FILE=`sudo find /var/run/gdm/ -iname database | grep for-gdm`
# New GDM location for Ubuntu >= 17.10
[ -z "$MAGIC_COOKIE_FILE" ] && NUM_MAGIC_COOKIE_FILE_SESSIONS=`sudo find /run/user/ -iwholename '*/gdm/*' -iname '*Xauthority' 2>/dev/null | wc -l`
if [ -z "$MAGIC_COOKIE_FILE" -a "$NUM_MAGIC_COOKIE_FILE_SESSIONS" -gt 1 ]; then
# Find the current user's session
MAGIC_COOKIE_FILE=`sudo find /run/user/$(id -u) -iwholename '*/gdm/*' -iname '*Xauthority'`
X11VNC_DISPLAY=":1"
else
# Find the GDM user's session (or whichever shows up first in ps list)
# This should pick up the original gdm session which grabs :0
# If you login after gdm login screen, your Xorg server may end up on another display!
# Workaround for now is to restart x11vnc on that display number
[ -z "$MAGIC_COOKIE_FILE" ] && MAGIC_COOKIE_FILE=`sudo find /run/user/ -iwholename '*/gdm/*' -iname '*Xauthority' | head -n1`
fi
# Old lightdm location for Ubuntu <= 17.10
[ -z "$MAGIC_COOKIE_FILE" ] && MAGIC_COOKIE_FILE=`sudo find /var/lib -name '.Xauthority' -o -wholename '/var/run/lightdm/root/:0' | head -n1`
#sudo bash -c "[ -z \"$MAGIC_COOKIE_FILE\" -a -e /var/run/lightdm/root/:0 ]" && MAGIC_COOKIE_FILE='/var/run/lightdm/root/:0'
[ -n "$MAGIC_COOKIE_FILE" -a -z "$GUESS_FLAG" ] && AUTH_COOKIE_FLAG="-auth $MAGIC_COOKIE_FILE"
[ ! -z "$PASSWORD" ] && sudo x11vnc -display $X11VNC_DISPLAY -xkb -rfbauth $PASSWORD -rfbport 5900 -shared -forever -nowf -norc -notruecolor -bg $GUESS_FLAG $CACHE_FLAG -noxdamage ${AUTH_COOKIE_FLAG}
fi
fi

View File

@@ -0,0 +1,259 @@
######################################################################
# mako's zshrc file, v0.1
#
#
######################################################################
# next lets set some enviromental/shell pref stuff up
# setopt NOHUP
#setopt NOTIFY
#setopt NO_FLOW_CONTROL
setopt APPEND_HISTORY
# setopt AUTO_LIST # these two should be turned off
# setopt AUTO_REMOVE_SLASH
# setopt AUTO_RESUME # tries to resume command of same name
unsetopt BG_NICE # do NOT nice bg commands
setopt CORRECT # command CORRECTION
setopt EXTENDED_HISTORY # puts timestamps in the history
# setopt HASH_CMDS # turns on hashing
setopt HIST_ALLOW_CLOBBER
setopt HIST_REDUCE_BLANKS
setopt INC_APPEND_HISTORY SHARE_HISTORY
setopt ALL_EXPORT
setopt MENUCOMPLETE
# Set/unset shell options
setopt notify globdots correct pushdtohome cdablevars autolist
setopt correctall autocd recexact longlistjobs
setopt autoresume histignoredups pushdsilent noclobber
setopt autopushd pushdminus extendedglob rcquotes mailwarning
unsetopt bgnice autoparamslash
# Autoload zsh modules when they are referenced
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
# mapfile : parameter already exists
#zmodload -ap zsh/mapfile mapfile
# For MAC:
# ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'
# ioreg -n AppleSmartBattery -r | awk '$1~/ExternalConnected/{gsub("Yes", "+");gsub("No", "%"); print substr($0, length, 1)}'
function battery_charge {
b_now=$(cat /sys/class/power_supply/BAT0/energy_now)
b_full=$(cat /sys/class/power_supply/BAT0/energy_full)
b_status=$(cat /sys/class/power_supply/BAT0/status)
# I am displaying 10 chars -> charge is in {0..9}
charge=$(expr $(expr $b_now \* 10) / $b_full)
# choose the color according the charge or if we are charging then always green
if [[ charge -gt 5 || "Charging" == $b_status ]]; then
echo -n "%{$fg[green]%}"
elif [[ charge -gt 2 ]]; then
echo -n "%{$fg[yellow]%}"
else
echo -n "%{$fg[red]%}"
fi
# display charge * '▸' and (10 - charge) * '▹'
i=0;
while [[ i -lt $charge ]]
do
i=$(expr $i + 1)
echo -n "▸"
done
while [[ i -lt 10 ]]
do
i=$(expr $i + 1)
echo -n "▹"
done
# display a plus if we are charging
if [[ "Charging" == $b_status ]]; then
echo -n "%{$fg_bold[green]%} +"
fi
# and reset the color
echo -n "%{$reset_color%} "
}
function battery_zsh {
BATDIR="/sys/class/power_supply/BAT0"
max=`cat $BATDIR/energy_full`
current=`cat $BATDIR/energy_now`
percent=$(( 100 * $current / $max ))
color_green="%{%}"
color_yellow="%{%}"
color_red="%{%}"
color_reset="%{%}"
if [ $percent -ge 80 ] ; then
color=$color_green;
elif [ $percent -ge 40 ] ; then
color=$color_yellow;
else
color=$color_red;
fi
echo $color$percent%%$color_reset
}
PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin/:$PATH"
TZ="America/Sao_Paulo"
HISTFILE=$HOME/.zhistory
HISTSIZE=1000
SAVEHIST=1000
HOSTNAME="`hostname`"
PAGER='less'
EDITOR='vim'
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
PS1="[$PR_MAGENTA%n$PR_NO_COLOR@$PR_GREEN%U%m%u$PR_NO_COLOR:$PR_RED%2c$PR_NO_COLOR]%(!.#.$) "
RPS1="$(battery_charge) $(battery_zsh) $PR_MAGENTA(%D{%d-%m-%y %H:%M})$PR_NO_COLOR"
#LANGUAGE=
LC_ALL='pt_BR.UTF-8'
LANG='pt_BR.UTF-8'
LC_CTYPE=C
DISPLAY=:0
if [ $SSH_TTY ]; then
MUTT_EDITOR=vim
else
MUTT_EDITOR=emacsclient.emacs-snapshot
fi
unsetopt ALL_EXPORT
# # --------------------------------------------------------------------
# # aliases
# # --------------------------------------------------------------------
alias slrn="slrn -n"
alias man='LC_ALL=PT-BR LANG=PT-BR man'
alias f=finger
alias ll='ls -ashpGl --color '
alias ls='ls -G --color '
alias offlineimap-tty='offlineimap -u TTY.TTYUI'
alias hnb-partecs='hnb $HOME/partecs/partecs-hnb.xml'
alias rest2html-css='rst2html --embed-stylesheet --stylesheet-path=/usr/share/python-docutils/s5_html/themes/default/print.css'
alias dmesg="sudo dmesg"
#if [[ $HOSTNAME == "kamna" ]] {
# alias emacs='emacs -l ~/.emacs.kamna'
#}
# alias =clear
stty erase ^H &>/dev/null
bindkey "^[[3~" delete-char
#chpwd() {
# [[ -t 1 ]] || return
# case $TERM in
# sun-cmd) print -Pn "\e]l%~\e\\"
# ;;
# *xterm*|screen|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a"
# ;;
# esac
#}
#chpwd
autoload -U compinit
compinit
bindkey '^r' history-incremental-search-backward
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[4~" end-of-line
bindkey ' ' magic-space # also do history expansion on space
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:processes' command 'ps -axw'
zstyle ':completion:*:processes-names' command 'ps -awxho command'
# Completion Styles
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions
#
#NEW completion:
# 1. All /etc/hosts hostnames are in autocomplete
# 2. If you have a comment in /etc/hosts like #%foobar.domain,
# then foobar.domain will show up in autocomplete!
zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# command for process lists, the local web server details and host completion
#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args'
#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html'
zstyle '*' hosts $hosts
# Filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
'*?.old' '*?.pro'
# the same for old style completion
#fignore=(.o .c~ .old .pro)
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:scp:*' tag-order \
files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order \
files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order \
users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order \
hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show
source $HOME/.bash_aliases
source $HOME/.profile
PATH="$HOME/bin:$HOME/.local/bin:$HOME/.cabal/bin:$PATH"
#source /home/renato/WebApp/silvrosa.llm-node.google-api.sh
alias batt='upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state|to\ full|to\ empty|percentage"'
# Instalacao das Funcoes ZZ (www.funcoeszz.net)
# script
export ZZPATH=/usr/local/bin/funcoeszz
# pasta zz/
export ZZDIR=
source /home/renato/.zzzshrc