Browse Source

Update dotfiles

master
Tovi Jaeschke-Rogers 4 years ago
parent
commit
89075c5636
19 changed files with 349 additions and 189 deletions
  1. +89
    -18
      .bash_profile
  2. +23
    -45
      .bashrc
  3. +4
    -0
      .config/aliasrc
  4. +34
    -1
      .config/nvim/init.vim
  5. +7
    -0
      .gitignore_global
  6. +17
    -13
      .inputrc
  7. +169
    -0
      .local/bin/bcms
  8. +6
    -6
      .local/bin/dmenu-bangs
  9. BIN
      .local/bin/fenc
  10. +0
    -28
      .local/bin/workflow/cabl
  11. +0
    -4
      .local/bin/workflow/change_wp
  12. +0
    -8
      .local/bin/workflow/compile
  13. +0
    -9
      .local/bin/workflow/extern_monitor
  14. +0
    -25
      .local/bin/workflow/extract
  15. BIN
      .local/bin/workflow/greenclip
  16. +0
    -10
      .local/bin/workflow/lock_toggle
  17. +0
    -4
      .local/bin/workflow/voldown
  18. +0
    -4
      .local/bin/workflow/volup
  19. +0
    -14
      .local/bin/workflow/vpn

+ 89
- 18
.bash_profile View File

@ -1,31 +1,102 @@
#!/bin/bash
[[ -f ~/.bashrc ]] && . ~/.bashrc
set -o vi
bind -m vi-insert "\C-l":clear-screen
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
shopt -s extglob
HISTSIZE=
HISTFILESIZE=
export EDITOR='nvim'
export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
export GIT_AUTHOR_EMAIL="tovi@tovijaeschke.xyz"
export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
export GIT_COMMITTER_EMAIL="tovi@tovijaeschke.xyz"
export LESS='-R'
export LESSOPEN='|~/.lessfilter %s'
if [[ $(uname) != "Linux" ]]; then
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
export HOMEBREW_NO_INSTALL_CLEANUP=1
export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@thirty4.com"
export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@thirty4.com"
mount-hdd() {
if [ -z $1 ]; then
sudo umount /dev/disk2s1 && sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other
else
sudo umount /dev/$1 && sudo /usr/local/bin/ntfs-3g /dev/$1 /Volumes/NTFS -olocal -oallow_other
fi
fi
}
export GOPATH="$HOME/code/go"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/games:/usr/local/sbin:/usr/sbin:/sbin:~/.local/bin:/usr/local/go/bin:$GOPATH/bin"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')"
PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')$HOME/.composer/vendor/bin"
fi
export TERMINAL='st'
export EDITOR='vim'
export PAGER='less'
export BROWSER='firefox'
source ~/.config/aliasrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1=" \[\033[0;36m\]\t \[\033[0;35m\]\u\[\033[0;32m\]@\[\033[0;34m\]\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[31m\] \n$\[\033[00m\] "
mkcd() {
if [ ! -d "$1" ]; then
mkdir -p "$1" && cd "$1"
elif [ -d "$1" ]; then
cd "$1"
else
echo "Error"
fi
}
# Go up directory structures
up() {
cd $(printf "%0.0s../" $(seq 1 $1));
}
git() {
if [[ $@ == "mergetool" ]]; then
command git mergetool --no-gui
else
command git $@
fi
}
# git branch -vv | grep 'gone\]' | awk ' { print $1 }' | xargs -p git branch -d
git-prune() {
if [[ $@ == "--apply" ]]; then
command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
else
echo "Run \"git prune --apply\" to delete the following branches:"
command git branch --merged develop | grep -vEw "develop$|master$"
fi
}
color-diff() {
if [ -z ${1+x} ] || [ -z ${2+x} ]; then
echo "Usage: color-diff dir1/ dir2/"
return
fi
diff -bur $1 $2 | colordiff | less
}
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"
export PULSE_PROP="filter.want=echo-cancel"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda/lib64"
export CUDA_HOME="/opt/cuda"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
eval "$(thefuck --alias)"

+ 23
- 45
.bashrc View File

@ -1,49 +1,11 @@
#!/bin/bash
set -o vi
bind -m vi-insert "\C-l":clear-screen
shopt -s extglob
#set -o vi
#bind -m vi-insert "\C-l":clear-screen
HISTSIZE=
HISTFILESIZE=
export EDITOR='nvim'
export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
export GIT_AUTHOR_EMAIL="tovi@tovijaeschke.xyz"
export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
export GIT_COMMITTER_EMAIL="tovi@tovijaeschke.xyz"
export LESS='-R'
export LESSOPEN='|~/.lessfilter %s'
alias ls="ls --color=auto" \
vb='nvim ~/.bashrc && source ~/.bashrc' \
va='nvim ~/.config/aliasrc && source ~/.bashrc'
if [[ $(uname) != "Linux" ]]; then
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
export HOMEBREW_NO_INSTALL_CLEANUP=1
export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@thirty4.com"
export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@thirty4.com"
alias ls="ls -G" \
vb='nvim ~/.bash_profile && source ~/.bash_profile' \
va='nvim ~/.config/aliasrc && source ~/.bash_profile'
mount-hdd() {
if [ -z $1 ]; then
sudo umount /dev/disk2s1 && sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other
else
sudo umount /dev/$1 && sudo /usr/local/bin/ntfs-3g /dev/$1 /Volumes/NTFS -olocal -oallow_other
fi
}
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
@ -52,11 +14,12 @@ fi
source ~/.config/aliasrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1=" \[\033[0;36m\]\t \[\033[0;35m\]\u\[\033[0;32m\]@\[\033[0;34m\]\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[31m\] \n$\[\033[00m\] "
export PS1="\[\033[0;35m\]\u\[\033[0;32m\]@\[\033[0;34m\]\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[31m\] \n$\[\033[00m\] "
mkcd() {
if [ ! -d "$1" ]; then
@ -81,12 +44,10 @@ git() {
fi
}
# git branch -vv | grep 'gone\]' | awk ' { print $1 }' | xargs -p git branch -d
git-prune() {
if [[ $@ == "--apply" ]]; then
if [[ $@ == "prune" ]]; then
command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
else
echo "Run \"git prune --apply\" to delete the following branches:"
command git branch --merged develop | grep -vEw "develop$|master$"
fi
}
@ -99,11 +60,28 @@ color-diff() {
diff -bur $1 $2 | colordiff | less
}
export NVM_DIR="$HOME/.nvm"
export EDITOR='nvim'
shopt -s extglob
export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@thirty4.com"
export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@thirty4.com"
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"
eval $(thefuck --alias)
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
export LESS='-R'
export LESSOPEN='|~/.lessfilter %s'
export TMPDIR=/tmp

+ 4
- 0
.config/aliasrc View File

@ -1,5 +1,6 @@
#!/bin/sh
alias q='exit' \
ls="ls -G" \
dd='sudo dd status=progress' \
h="history | grep" \
back='cd -' \
@ -20,7 +21,10 @@ alias q='exit' \
ddate='date +%d-%m-%Y' \
gitup='git push origin $(git rev-parse --abbrev-ref HEAD)' \
gco='git checkout' \
gbls='git --no-pager branch -a' \
vv='nvim ~/.config/nvim/init.vim' \
vb='nvim ~/.bash_profile && source ~/.bash_profile' \
va='nvim ~/.config/aliasrc && source ~/.bash_profile' \
delorig='find . -name "*.orig" -exec rm {} \;' \
delbak='find . -name "*.bak" -exec rm {} \;' \
site-clone='wget --mirror --convert-links --adjust-extension --page-requisites --no-parent'

+ 34
- 1
.config/nvim/init.vim View File

@ -24,6 +24,7 @@ Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'rbong/vim-flog'
Plug 'ap/vim-css-color'
Plug 'justinmk/vim-sneak'
call plug#end()
" Some basics:
@ -32,6 +33,7 @@ call plug#end()
set nohlsearch
set clipboard+=unnamedplus
set incsearch
set ignorecase
set smartcase
set noswapfile
@ -39,6 +41,12 @@ call plug#end()
set undodir=~/.config/nvim/undodir
set undofile
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[38;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection = '0'
colorscheme gruvbox
set background=dark
@ -74,6 +82,8 @@ call plug#end()
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gr <Plug>(coc-references)
nmap <leader>rr <Plug>(coc-rename)
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR>
inoremap <expr> <C-j> pumvisible() ? "\<Down>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<Up>" : "\<C-k>"
@ -90,6 +100,21 @@ call plug#end()
let g:pdv_cfg_autoEndClass = 0
let g:pdv_cfg_autoEndFunction = 0
" Sneak config
let g:sneak#label = 1
" case insensitive sneak
let g:sneak#use_ic_scs = 1
" immediately move to the next instance of search, if you move the cursor sneak is back to default behavior
let g:sneak#s_next = 1
" remap so I can use , and ; with f and t
map gS <Plug>Sneak_,
map gs <Plug>Sneak_;
" Change the colors
"highlight Sneak guifg=black guibg=#00C7DF ctermfg=black ctermbg=cyan
"highlight SneakScope guifg=red guibg=yellow ctermfg=red ctermbg=yellow
" Cool prompts
let g:sneak#prompt = 'S> '
" Spell-check set to <leader>o, 'o' for 'orthography':
map <leader>o :setlocal spell! spelllang=en_au<CR>
@ -106,7 +131,10 @@ call plug#end()
map <leader>s :!clear && shellcheck %<CR>
" Replace all is aliased to S.
nnoremap S :%s//g<Left><Left>
nnoremap <c-s> :%s//g<Left><Left>
" For chrome extension development
nnoremap <c-h> :set syntax=
" Ensure files are read as what I want:
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
@ -130,6 +158,11 @@ call plug#end()
" Update CHANGELOG message
inoremap <leader>C Update CHANGELOG<esc>:wq<cr>
inoremap <leader>7 Refactor for php7<esc>bbhi
" Copy entire document
noremap <leader>y <Esc>ggyG<C-o>
map <leader>y <Esc>ggyG<C-o>
"""HTML
autocmd FileType html inoremap <leader>b <b></b><Space><++><Esc>FbT>i


+ 7
- 0
.gitignore_global View File

@ -4,3 +4,10 @@ lib/form/base
zz_release_ticket.php
ZzDummyTask.class.php
lib/task/ZzDummyTask.class.php
.DS_Store
todo.txt
todo
TODO.txt
TODO
release*
RELEASE*

+ 17
- 13
.inputrc View File

@ -1,19 +1,23 @@
$include /etc/inputrc
set editing-mode vi
$if mode=vi
set completion-ignore-case on
set show-mode-in-prompt on
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
set keymap emacs
"\C-x\C-r": re-read-init-file
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen
Control-a: beginning-of-line
"\C-x\C-r": re-read-init-file
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen
Control-a: beginning-of-line
"\C-x\C-r": re-read-init-file
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
$endif

+ 169
- 0
.local/bin/bcms View File

@ -0,0 +1,169 @@
#!/bin/bash
# Variables
blog_dir=~/repos/blog-cms
check() {
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit
fi
}
confirm() {
confirmvar=""
while [[ "$confirmvar" == "" ]]
do
read -p "y/n/q: " confirmvar
if [ "${confirmvar}" == "y" ]
then
echo true
elif [ "${confirmvar}" == "n" ]
then
echo false
fi
done
}
newpost() {
c=false
while [[ ${c} == false ]]
do
read -p "Title: " title
echo -e "Subject 1:\n\t0 - no subject\n\t1 - Programming\n\t2 - Pentesting\n\t3 - Personal"
sub1=$(subjectselect)
echo -e "Subject 1:\n\t0 - no subject\n\t1 - Programming\n\t2 - Pentesting\n\t3 - Personal"
sub2=$(subjectselect)
echo -e "Title: ${title}\nSubject 1: ${sub1}\nSubject 2: ${sub2}\n\nAre you sure?\n"
c=$(confirm)
done
dirname=$(echo ${title} | sed 's/\ /_/g')
mkdir -p ${blog_dir}/posts/${dirname}/static
cd ${blog_dir}/posts/${dirname}
echo ${title} >> title
echo ${sub1} >> .sub1
echo ${sub2} >> .sub2
touch {intro.html,body.html}
pwd
ls -al
}
subjectselect() {
read -p "0/1/2/3: " tmpvar
if [ "$tmpvar" == "1" ]
then
echo "Programming"
elif [ "$tmpvar" == "2" ]
then
echo "Pentesting"
elif [ "$tmpvar" == "3" ]
then
echo "Personal"
elif [ "$tmpvar" == "0" ]
then
echo ""
fi
}
listandReturn() { printf "Listing contents of %s.\\n" "$1"
ls -rc "$1" | awk -F '/' '{print $NF}' | nl
read -erp "Pick an entry by number to $2, or press ctrl-c to cancel. " number
chosen="$(ls -rc "$1" | nl | grep -w "$number" | awk '{print $2}')"
basefile="$(basename "$chosen")" && base="${basefile%.*}" ;}
upload() {
#check
listandReturn ${blog_dir}/posts
#cd ${blog_dir}/posts/${basefile}
titlevar=$(cat ${blog_dir}/posts/${basefile}/title)
subvar1=$(cat ${blog_dir}/posts/${basefile}/.sub1)
subvar2=$(cat ${blog_dir}/posts/${basefile}/.sub2)
echo "Add intro pic?"
if [[ $(confirm) == true ]]
then
listandReturn ${blog_dir}/posts/${basefile}/static/
picvar=${basefile}
fi
echo -n Mysql password:
read -s sqlpassword
scp ${blog_dir}/posts/${basefile}/{intro.html,body.html} root@tovijaeschke.xyz:/var/lib/mysql-files/
scp ${blog_dir}/posts/${basefile}/static/* root@tovijaeschke.xyz:/usr/share/nginx/personal/static/
if [[ "$picvar" == "" ]]
then
ssh root@tovijaeschke.xyz "chown mysql:mysql /var/lib/mysql-files/* &&
chmod go+rw /var/lib/mysql-files/* &&
mysql -u root -p${sqlpassword} -D PersonalWebsite -e \"INSERT INTO Posts (subject,subject2,title,intro,body) VALUES ('${subvar1}', '${subvar2}', '${titlevar}', LOAD_FILE('/var/lib/mysql-files/intro.html'), LOAD_FILE('/var/lib/mysql-files/body.html'));\""
else
ssh root@tovijaeschke.xyz "chown mysql:mysql /var/lib/mysql-files/* &&
chmod go+rw /var/lib/mysql-files/* &&
mysql -u root -p${sqlpassword} -D PersonalWebsite -e \"INSERT INTO Posts (subject,subject2,title,pic,intro,body) VALUES ('${subvar1}', '${subvar2}', '${titlevar}', '${picvar}', LOAD_FILE('/var/lib/mysql-files/intro.html'), LOAD_FILE('/var/lib/mysql-files/body.html'));\""
fi
}
preview() {
mkdir -p /tmp/preview
cp -r ${blog_dir}/.preview/* /tmp/preview/
listandReturn ${blog_dir}/posts
title=$(cat ${blog_dir}/posts/${basefile}/title | tr -d '\n')
intro=$(cat ${blog_dir}/posts/${basefile}/intro.html | tr -d '\n')
body=$(cat ${blog_dir}/posts/${basefile}/body.html | tr -d '\n')
cp -r ${blog_dir}/posts/${basefile}/static/ /tmp/preview
sed -i .bak 's|TITLE_PREVIEW|'"${title}"'|g' /tmp/preview/post.html
sed -i .bak 's|INTRO_PREVIEW|'"${intro}"'|g' /tmp/preview/post.html
sed -i .bak 's|BODY_PREVIEW|'"${body}"'|g' /tmp/preview/post.html
if [[ $(uname) == "Linux" ]]; then
firefox /tmp/preview/post.html
else
open -a firefox -g /tmp/preview/post.html
fi
}
deletedraft() {
echo "Which draft would you like to delete?"
listandReturn ${blog_dir}/posts
echo "Are you sure you want to delete \"$(cat ${blog_dir}/posts/${basefile}/title)?\""
c=$(confirm)
if [ ${c} != false ]
then
rm -rf ${blog_dir}/posts/${basefile}
fi
}
deletepost() {
echo -n Mysql password:
read -s sqlpassword
echo -e "\nWhich post would you like to delete?"
ssh root@tovijaeschke.xyz "mysql -u root -p${sqlpassword} -D PersonalWebsite -B --disable-column-names -e \"SELECT id,title FROM Posts;\""
read -p "\nWhich post would you like to delete?" post
ssh root@tovijaeschke.xyz "mysql -u root -p${sqlpassword} -D PersonalWebsite -e \"DELETE FROM Posts WHERE id=${post};\" && \
post=\$(mysql -B -u root -p${sqlpassword} -D PersonalWebsite --disable-column-names -e \"SELECT MAX(id) FROM Posts;\") && \
mysql -u root -p${sqlpassword} -D PersonalWebsite -e \"ALTER TABLE Posts AUTO_INCREMENT=\$post;\""
}
helpmsg() {
printf "\nBLOG UPLOAD SCRIPT\n\n\tn - new draft\n\tp - preview post\n\tu - upload post\n\tdd - delete draft\n\tdp - delete post\n\th - help message\n\n"
}
case "$1" in
n*) newpost ;;
p*) preview ;;
u*) upload ;;
dd*) deletedraft ;;
dp*) deletepost ;;
h*) helpmsg ;;
*) helpmsg ;;
esac

+ 6
- 6
.local/bin/dmenu-bangs View File

@ -23,27 +23,27 @@ COMMANDS["clipboard"]="greenclip print | dmenu -i -l 10 -m 0 -fn 'Inconsolata:si
LABELS["clipboard"]=""
# search local files
COMMANDS["emoji"]="~/.local/bin/dmenu-scripts/dmenu-emoji"
COMMANDS["emoji"]="~/.bin/dmenu-scripts/dmenu-emoji"
LABELS["emoji"]=""
# mount drives
COMMANDS["mount"]="sudo ~/.local/bin/dmenu-scripts/dmenu-mount"
COMMANDS["mount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount"
LABELS["mount"]=""
# umount drives
COMMANDS["unmount"]="sudo ~/.local/bin/dmenu-scripts/dmenu-mount unmount"
COMMANDS["unmount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount unmount"
LABELS["unmount"]=""
# shutdown
COMMANDS["shutdown"]="sudo ~/.local/bin/dmenu-scripts/dmenu-shutdown"
COMMANDS["shutdown"]="sudo ~/.bin/dmenu-scripts/dmenu-shutdown"
LABELS["shutdown"]=""
# PDF man pages
COMMANDS["man"]="~/.local/bin/dmenu-scripts/dmenu-man"
COMMANDS["man"]="~/.bin/dmenu-scripts/dmenu-man"
LABELS["man"]=""
# locate files
COMMANDS["locate"]="~/.local/bin/dmenu-scripts/dmenu-locate"
COMMANDS["locate"]="~/.bin/dmenu-scripts/dmenu-locate"
LABELS["locate"]=""
################################################################################


BIN
.local/bin/fenc View File


+ 0
- 28
.local/bin/workflow/cabl View File

@ -1,28 +0,0 @@
#!/bin/bash
# Dependencies are xclip and xorg-xprop.
# qrencode required for qrcode generation.
# groff/zathura required for man pages.
prim="$(xclip -o)"; [ -z "$prim" ] && exit
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
cd "$(readlink /proc/"$PID"/cwd)"
[[ "${prim}" == *"~"* ]] && prim=$(echo "~/go/src/gitlab.com/tovijaeschke/website" | sed 's@~@'"$HOME"'@g')
[ -f "$prim" ] && xdg-open "$prim" && exit
[ -d "$prim" ] && st -c "$prim" && exit
websearch() { "$BROWSER" "https://duckduckgo.com/?q=$@" ;}
wikipedia() { "$BROWSER" "https://en.wikipedia.org/wiki/$@" ;}
wiktionary() { "$BROWSER" "https://en.wiktionary.org/wiki/$@" ;}
piratebay() { "$BROWSER" "https://piratebays.fi/s/?q=$@" ;}
maps() { "$BROWSER" "https://www.openstreetmap.org/search?query=$@" ;}
ebay() { "$BROWSER" "https://www.ebay.com/sch/$@" ;}
echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && gotourl() { "$BROWSER" "$@" ;}
echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && email() { xdg-email "$@" ;}
command -v qrencode >/dev/null && qrcode() { qrencode "$@" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;}
man -k "^$prim$" >/dev/null && manual() { man -Tpdf "$prim" | zathura - ;}
func="$(declare -F | awk '{print $3}' | dmenu -p "Plumb $prim to?" -i -l 15)"
[ -z "$func" ] || "$func" "$prim"

+ 0
- 4
.local/bin/workflow/change_wp View File

@ -1,4 +0,0 @@
#!/bin/bash
notify-send "Changing wallpaper"
feh --bg-fill ~/pix/cyberpunk/$(ls ~/pix/cyberpunk | shuf -n 1)

+ 0
- 8
.local/bin/workflow/compile View File

@ -1,8 +0,0 @@
#!/bin/bash
case "$1" in
*.asm) nasm -f elf64 "$1" && ld "${1%.*}".o -o "${1%.*}"; rm "${1%.*}".o ;;
*.c) gcc "$1" -o "${1%.*}" ;;
*.go) go build "$1" ;;
Makefile) make ;;
esac

+ 0
- 9
.local/bin/workflow/extern_monitor View File

@ -1,9 +0,0 @@
#!/bin/bash
intern=LVDS-1
extern=VGA-1
if xrandr | grep "$extern connected"; then
xrandr --output ${extern} --auto --right-of ${intern}
else
xrandr --output ${extern} --off --output ${intern} --auto
fi

+ 0
- 25
.local/bin/workflow/extract View File

@ -1,25 +0,0 @@
#!/bin/bash
if [ -f $1 ] ; then
# NAME=${1%.*}
# mkdir $NAME && cd $NAME
case $1 in
*.tar.bz2) tar xvjf ../$1 ;;
*.tar.gz) tar xvzf ../$1 ;;
*.tar.xz) tar xvJf ../$1 ;;
*.lzma) unlzma ../$1 ;;
*.bz2) bunzip2 ../$1 ;;
*.rar) unrar x -ad ../$1 ;;
*.gz) gunzip ../$1 ;;
*.tar) tar xvf ../$1 ;;
*.tbz2) tar xvjf ../$1 ;;
*.tgz) tar xvzf ../$1 ;;
*.zip) unzip ../$1 ;;
*.Z) uncompress ../$1 ;;
*.7z) 7z x ../$1 ;;
*.xz) unxz ../$1 ;;
*.exe) cabextract ../$1 ;;
*) echo "extract: '$1' - unknown archive method" ;;
esac
else
echo "$1 - file does not exist"
fi

BIN
.local/bin/workflow/greenclip View File


+ 0
- 10
.local/bin/workflow/lock_toggle View File

@ -1,10 +0,0 @@
#!/bin/bash
if [ $(pgrep xautolock) ]
then
killall xautolock
notify-send "🔓 Turning off xautolock"
else
xautolock -time 10 -locker slock &
notify-send "🔒 Turning on xautolock"
fi

+ 0
- 4
.local/bin/workflow/voldown View File

@ -1,4 +0,0 @@
#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ -5%
vol=$(amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }')
notify-send -t 500 "Volume: ${vol}"

+ 0
- 4
.local/bin/workflow/volup View File

@ -1,4 +0,0 @@
#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ +5%
vol=$(amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }')
notify-send -t 500 "Volume: ${vol}"

+ 0
- 14
.local/bin/workflow/vpn View File

@ -1,14 +0,0 @@
#!/bin/bash
listandReturn() {
printf "Listing contents of %s.\\n" "$1"
ls -rc "$1" | awk -F '/' '{print $NF}' | nl
read -erp "Pick an entry by number to $2, or press ctrl-c to cancel. " number
chosen="$(ls -rc "$1" | nl | grep -w "$number" | awk '{print $2}')"
basefile="$(basename "$chosen")" && base="${basefile%.*}"
}
listandReturn ~/.openvpn/UDP\ 1194\ Normal/
sudo openvpn --config ~/.openvpn/UDP\ 1194\ Normal/${basefile}

Loading…
Cancel
Save