diff --git a/.bash_profile b/.bash_profile index d5d0046..5545f00 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,102 +1,5 @@ -#!/bin/bash +# +# ~/.bash_profile +# -set -o vi -bind -m vi-insert "\C-l":clear-screen - -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 - -# 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' ':')$HOME/.composer/vendor/bin" -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\] " - -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" - -[ -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" - -eval "$(thefuck --alias)" +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/.bashrc b/.bashrc index a2d635b..015e023 100644 --- a/.bashrc +++ b/.bashrc @@ -1,116 +1,13 @@ -#!/bin/bash +# +# ~/.bashrc +# -export PATH=~/go/bin:/snap/bin:/usr/sandbox/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/games:/usr/local/sbin:/usr/sbin:/sbin:$PATH +# If not running interactively, don't do anything +[[ $- != *i* ]] && return -set -o vi -bind -m vi-insert "\C-l":clear-screen - -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' - -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 - } -else - - aupdate() { - sudo "apt update && apt upgrade" - } +alias ls='ls --color=auto' +PS1='[\u@\h \W]\$ ' -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' ':')" -fi +set -o vi 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" - - -[ -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" diff --git a/.config/lf/cleaner b/.config/lf/cleaner new file mode 100755 index 0000000..a184d84 --- /dev/null +++ b/.config/lf/cleaner @@ -0,0 +1,4 @@ +#!/bin/sh +if [ -n "$FIFO_UEBERZUG" ]; then + printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG" +fi diff --git a/.config/lf/lfrc b/.config/lf/lfrc new file mode 100644 index 0000000..df34c9b --- /dev/null +++ b/.config/lf/lfrc @@ -0,0 +1,119 @@ +# Luke's lf settings + + +# Note on Image Previews +# For those wanting image previews, like this system, there are four steps to +# set it up. These are done automatically for LARBS users, but I will state +# them here for others doing it manually. +# +# 1. ueberzug must be installed. +# 2. The scope file (~/.config/lf/scope for me), must have a command similar to +# mine to generate ueberzug images. +# 3. A `set cleaner` line as below is a cleaner script. +# 4. lf should be started through a wrapper script (~/.local/bin/lfub for me) +# that creates the environment for ueberzug. This command can be be aliased +# in your shellrc (`alias lf="lfub") or if set to a binding, should be +# called directly instead of normal lf. + +# Basic vars +set shellopts '-eu' +set ifs "\n" +set scrolloff 10 +set icons +set period 1 +set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" +set cleaner '~/.config/lf/cleaner' +set previewer '~/.config/lf/scope' + +# cmds/functions +cmd open ${{ + case $(file --mime-type "$(readlink -f $f)" -b) in + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; + image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; + text/*|application/json|inode/x-empty) $EDITOR $fx;; + image/x-xcf) gimp $f >/dev/null 2>&1 ;; + image) display -- $f ;; + audio/*) mpv --audio-display=no $f ;; + video/*) mpv $f -quiet >/dev/null 2>&1 ;; + application/pdf|application/vnd*|application/epub*) zathura $fx >/dev/null 2>&1 ;; + esac +}} + +cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')" + +cmd extract ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "extract?[y/N]" + read ans + [ $ans = "y" ] && aunpack $fx +}} + +cmd delete ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "delete?[y/N]" + read ans + [ $ans = "y" ] && rm -rf -- $fx +}} + +cmd moveto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Move to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval mv -iv \"$x\" \"$dest\" + done && + notify-send "🚚 File(s) moved." "File(s) moved to $dest." +}} + +cmd copyto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Copy to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval cp -ivr \"$x\" \"$dest\" + done && + notify-send "📋 File(s) copied." "File(s) copies to $dest." +}} + +cmd setbg "$1" +cmd bulkrename $vidir + +# Bindings +map $lf -remote "send $id select '$(fzf)'" +map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" +map gh +map g top +map D delete +map E extract +map C copyto +map M moveto +map push :mkdir +map reload +map set hidden! +map shell +map x $$f +map X !$f +map o &mimeopen $f +map O $mimeopen --ask $f + +map A rename # at the very end +map c push A # new rename +map I push A # at the very beginning +map i push A # before extention +map a push A # after extention +map B bulkrename +map b $setbg $f + +map down +map up +map V push :!nvim + +map W $setsid -f $TERMINAL >/dev/null 2>&1 + +map Y $printf "%s" "$fx" | xclip -selection clipboard diff --git a/.config/lf/scope b/.config/lf/scope new file mode 100755 index 0000000..b5e0803 --- /dev/null +++ b/.config/lf/scope @@ -0,0 +1,43 @@ +#!/bin/sh + +# File preview handler for lf. + +set -C -f +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" + +image() { + if [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then + printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG" + else + mediainfo "$1" + fi +} + +ifub() { + [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1 +} + +# Note that the cache file name is a function of file information, meaning if +# an image appears in multiple places across the machine, it will not have to +# be regenerated once seen. +case "$(file --dereference --brief --mime-type -- "$1")" in + image/*) image "$1" "$2" "$3" "$4" "$5" ;; + text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;; + text/troff) man ./ "$1" | col -b ;; + text/* | */xml | application/json) cat "$1" ;; + application/zip) atool --list -- "$1" ;; + audio/* | application/octet-stream) mediainfo "$1" || exit 1;; + video/* ) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')" + [ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0 + image "$CACHE" "$2" "$3" "$4" "$5" + ;; + */pdf) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')" + [ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" + image "$CACHE.jpg" "$2" "$3" "$4" "$5" + ;; + *opendocument*) odt2txt "$1" ;; + application/pgp-encrypted) gpg -d -- "$1" ;; +esac +exit 1 diff --git a/.config/mutt/accounts/1-tovi.muttrc b/.config/mutt/accounts/1-tovi.muttrc deleted file mode 100644 index 12a166b..0000000 --- a/.config/mutt/accounts/1-tovi.muttrc +++ /dev/null @@ -1,31 +0,0 @@ -# vim: filetype=neomuttrc -# muttrc file for account tovi -set realname = "Tovi Jaeschke-Rogers" -set from = "tovi@tovijaeschke.xyz" -set sendmail = "msmtp -a tovi" -alias me Tovi Jaeschke-Rogers -set folder = /Users/tovijaeschke-rogers/.local/share/mail/tovi -set header_cache = /Users/tovijaeschke-rogers/.cache/mutt-wizard/tovi/headers -set message_cachedir = /Users/tovijaeschke-rogers/.cache/mutt-wizard/tovi/bodies -set mbox_type = Maildir -set spoolfile = +INBOX -set postponed = +Drafts -set record = +Sent -set trash = +Trash -mailboxes $spoolfile $record $postponed $trash -set smtp_pass = "`pass mutt-wizard-tovi`" -set smtp_url = "smtp://tovi@mail.tovijaeschke.xyz:587" - -set crypt_autosign = yes -set crypt_opportunistic_encrypt = yes -set pgp_self_encrypt = yes -set pgp_default_key = 78CC949ADAAF9556 - -bind index,pager gg noop -bind index,pager g noop -bind index,pager M noop -bind index,pager C noop -bind index gg first-entry -macro index o "mailsync -V tovi" "run mbsync to sync tovi" -#unmailboxes * - diff --git a/.config/mutt/muttrc b/.config/mutt/muttrc deleted file mode 100644 index ca595cf..0000000 --- a/.config/mutt/muttrc +++ /dev/null @@ -1,4 +0,0 @@ -# vim: filetype=neomuttrc -source /usr/local/share/mutt-wizard/mutt-wizard.muttrc # mw-autogenerated -source /Users/tovijaeschke-rogers/.config/mutt/accounts/1-tovi.muttrc # mw-autogenerated -macro index,pager i1 'source /Users/tovijaeschke-rogers/.config/mutt/accounts/1-tovi.muttrc!;' "switch to tovi@tovijaeschke.xyz" # mw-autogenerated diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json new file mode 100644 index 0000000..e708ab4 --- /dev/null +++ b/.config/nvim/coc-settings.json @@ -0,0 +1,25 @@ +{ + "languageserver": { + "ccls": { + "command": "ccls", + "filetypes": [ + "c", + "cpp", + "objc", + "objcpp" + ], + "rootPatterns": [ + ".ccls", + "compile_commands.json", + ".vim/", + ".git/", + ".hg/" + ], + "initializationOptions": { + "cache": { + "directory": "/tmp/ccls" + } + } + } + } +} diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index c165128..e57e15a 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,125 +1,175 @@ +" My awesome vimrc + let mapleader ="," if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) - echo "Downloading junegunn/vim-plug to manage plugins..." - silent !mkdir -p ~/.config/nvim/autoload/ - silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim - autocmd VimEnter * PlugInstall + echo "Downloading junegunn/vim-plug to manage plugins..." + silent !mkdir -p ~/.config/nvim/autoload/ + silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim + autocmd VimEnter * PlugInstall endif +function! Cond(cond, ...) + let opts = get(a:000, 0, {}) + return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) +endfunction + call plug#begin('~/.config/nvim/plugged') -Plug 'morhetz/gruvbox' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' -Plug 'ap/vim-css-color' + +if !exists('g:vscode') + Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode')) + + Plug 'nvim-lua/popup.nvim', Cond(!exists('g:vscode')) + Plug 'nvim-lua/plenary.nvim', Cond(!exists('g:vscode')) + Plug 'nvim-telescope/telescope.nvim', Cond(!exists('g:vscode')) + Plug 'nvim-telescope/telescope-fzy-native.nvim', Cond(!exists('g:vscode')) + + Plug 'vimwiki/vimwiki', Cond(!exists('g:vscode')) + + Plug 'ap/vim-css-color', Cond(!exists('g:vscode')) + +endif + Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } -call plug#end() -let g:airline_powerline_fonts=1 +call plug#end() " Some basics: - set go=a - set mouse=a - set nohlsearch - set clipboard+=unnamedplus - set incsearch - set ignorecase - set smartcase - set linebreak - - set noswapfile - set nobackup - set undodir=~/.config/nvim/undodir - set undofile - - "let g:gruvbox_contrast_dark = 'hard' - "if exists('+termguicolors') - " let &t_8f = "\[38;2;%lu;%lu;%lum" - " let &t_8b = "\[38;2;%lu;%lu;%lum" - "endif - "let g:gruvbox_invert_selection = '0' - "colorscheme gruvbox - "set background=dark - - nnoremap c "_c - set nocompatible - filetype plugin on - syntax on - set encoding=utf-8 - set number relativenumber - -" Indent marks - "set listchars=tab:\|_ - "set list - -" Tab 2 spaces - filetype plugin indent on - set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab - -" Disables automatic commenting on newline: - autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o - -" coc - inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - inoremap pumvisible() ? "\" : "\" - - function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - nmap gd (coc-definition) - nmap gr (coc-references) - nmap rr (coc-rename) - nnoremap prw :CocSearch =expand("") - - inoremap pumvisible() ? "\" : "\" - inoremap pumvisible() ? "\" : "\" - -" fzf remaps - "nnoremap :GFiles - nnoremap :GFiles - nnoremap :Files - - let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.5, 'highlight': 'Comment' } } - -" Spell-check set to o, 'o' for 'orthography': - map o :setlocal spell! spelllang=en_au - -" Splits open at the bottom and right, which is non-retarded, unlike vim defaults. - set splitbelow splitright - -" Shortcutting split navigation, saving a keypress: - nnoremap h - nnoremap j - nnoremap k - nnoremap l - -" Check file in shellcheck: - map s :!clear && shellcheck % - -" Replace all is aliased to S. - nnoremap :%s//g - -" For chrome extension development - " nnoremap :set syntax= - -" Navigating with guides - inoremap /<++>"_c4l - vnoremap /<++>"_c4l - map /<++>"_c4l - -" Remember last cursor position - autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif - -" Copy entire document - noremap y ggyG - map y ggyG - - autocmd BufNewFile,BufRead *.gohtml set syntax=html +set clipboard+=unnamedplus +set nohlsearch +set incsearch +set ignorecase + + +if !exists('g:vscode') + set go=a + set mouse=a + set smartcase + set linebreak + + set noswapfile + set nobackup + set undodir=~/.config/nvim/undodir + set undofile + + nnoremap c "_c + set nocompatible + filetype plugin on + syntax on + set encoding=utf-8 + set number relativenumber + + " Tab 2 spaces + filetype plugin indent on + set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab + + " Disables automatic commenting on newline: + autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + + " Remember last cursor position + autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + + " Copy entire document + noremap y ggyG + map y ggyG + + " Set gohtml template files to html syntax + autocmd BufNewFile,BufRead *.gohtml set syntax=html + + " NETRW + + let g:netrw_liststyle = 3 + let g:netrw_banner = 0 + let g:netrw_browse_split = 4 + let g:netrw_winsize = 20 + let g:netrw_altv = 1 + + let g:NetrwIsOpen=0 + function! ToggleNetrw() + if g:NetrwIsOpen + let i = bufnr("$") + while (i >= 1) + if (getbufvar(i, "&filetype") == "netrw") + silent exe "bwipeout " . i + endif + let i-=1 + endwhile + let g:NetrwIsOpen=0 + else + let g:NetrwIsOpen=1 + silent Lexplore + endif + endfunction + + " Add your own mapping. For example: + noremap :call ToggleNetrw() + + " coc + highlight CocErrorSign ctermfg=Black ctermbg=Magenta + + inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() + inoremap pumvisible() ? "\" : "\" + + function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + nmap gd (coc-definition) + nmap gr (coc-references) + nmap rr (coc-rename) + nnoremap prw :CocSearch =expand("") + + inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? "\" : "\" + + try + nmap ej :call CocAction('diagnosticNext') + nmap ek :call CocAction('diagnosticPrevious') + endtry + + " Telescope remaps + lua require("telescope") + + nnoremap gs :lua require('telescope.builtin').grep_string({ search = vim.fn.input("Grep For > ")}) + nnoremap :lua require('telescope.builtin').git_files() + nnoremap :lua require('telescope.builtin').find_files() + + nnoremap fb lua require('telescope.builtin').buffers() + + " VimWiki + + let pentest_wiki = {} + let pentest_wiki.path = '~/Documents/PentestWiki/' + let pentest_wiki.path_html = '~/Documents/PentestWikiHtml/' + let pentest_wiki.syntax = 'markdown' + let pentest_wiki.ext = '.md' + let pentest_wiki.custom_wiki2html = '~/.local/bin/vimwiki_convert.py' + + let g:vimwiki_list = [pentest_wiki] + let g:vimwiki_ext2syntax = {'.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} + + au filetype vimwiki silent! iunmap + + " Spell-check + map o :setlocal spell! spelllang=en_au + + " Shortcutting split navigation, saving a keypress: + nnoremap h + nnoremap j + nnoremap k + nnoremap l + + " Replace all is aliased to S. + nnoremap :%s//g + + " Navigating with guides + inoremap /<++>"_c4l + vnoremap /<++>"_c4l + map /<++>"_c4l +endif diff --git a/.config/nvim/telescope.lua b/.config/nvim/telescope.lua new file mode 100644 index 0000000..39292f5 --- /dev/null +++ b/.config/nvim/telescope.lua @@ -0,0 +1,27 @@ +local actions = require('telescope.actions') +require('telescope').setup { + defaults = { + file_sorter = require('telescope.sorters').get_fzy_sorter, + prompt_prefix = ' >', + color_devicons = true, + + file_previewer = require('telescope.previewers').vim_buffer_cat.new, + grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, + qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, + + mappings = { + i = { + [""] = false, + [""] = actions.send_to_qflist, + }, + } + }, + extensions = { + fzy_native = { + override_generic_sorter = false, + override_file_sorter = true, + } + } +} + +require('telescope').load_extension('fzy_native') diff --git a/.dwm/autostart.sh b/.dwm/autostart.sh deleted file mode 100644 index c62f008..0000000 --- a/.dwm/autostart.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -~/.local/bin/remap-keys -#pulseaudio --start & -dunst & -xautolock -time 10 -locker slock & -feh --bg-fill ~/Pictures/wp/$(ls ~/Pictures/wp/ | shuf -n 1) -#compton -b --backend xrender --config ~/.config/compton/compton.conf & -unclutter & -#transmission-daemon & -#conky -d & - -~/.dwm/dwm-sss & diff --git a/.local/bin/bcms b/.local/bin/bcms deleted file mode 100755 index 3f30ba9..0000000 --- a/.local/bin/bcms +++ /dev/null @@ -1,169 +0,0 @@ -#!/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 diff --git a/.local/bin/c b/.local/bin/c deleted file mode 100755 index 3fb4807..0000000 --- a/.local/bin/c +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -F=$(fzf) - -[ -z "$F" ] || nvim "$F" diff --git a/.local/bin/dmenu-bangs b/.local/bin/dmenu-bangs deleted file mode 100755 index 97735cc..0000000 --- a/.local/bin/dmenu-bangs +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash -# author: unknown -# sentby: MoreChannelNoise (https://www.youtube.com/user/MoreChannelNoise) -# editby: gotbletu (https://www.youtube.com/user/gotbletu) - -# demo: https://www.youtube.com/watch?v=kxJClZIXSnM -# info: this is a script to launch other rofi scripts, -# saves us the trouble of binding multiple hotkeys for each script, -# when we can just use one hotkey for everything. - -declare -A LABELS -declare -A COMMANDS - -### -# List of defined 'bangs' - -# launch programs -COMMANDS["apps"]="dmenu_run -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee'" -LABELS["apps"]="" - -# clipboard -COMMANDS["clipboard"]="greenclip print | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'clipboard: ' | xclip -selection clipboard" -LABELS["clipboard"]="" - -# search local files -COMMANDS["emoji"]="~/.bin/dmenu-scripts/dmenu-emoji" -LABELS["emoji"]="" - -# mount drives -COMMANDS["mount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount" -LABELS["mount"]="" - -# umount drives -COMMANDS["unmount"]="sudo ~/.bin/dmenu-scripts/dmenu-mount unmount" -LABELS["unmount"]="" - -# shutdown -COMMANDS["shutdown"]="sudo ~/.bin/dmenu-scripts/dmenu-shutdown" -LABELS["shutdown"]="" - -# PDF man pages -COMMANDS["man"]="~/.bin/dmenu-scripts/dmenu-man" -LABELS["man"]="" - -# locate files -COMMANDS["locate"]="~/.bin/dmenu-scripts/dmenu-locate" -LABELS["locate"]="" - -################################################################################ -# do not edit below -################################################################################ -## -# Generate menu -## -function print_menu() -{ - for key in ${!LABELS[@]} - do - echo "$key ${LABELS}" - # echo "$key ${LABELS[$key]}" - # my top version just shows the first field in labels row, not two words side by side - done -} -## -# Show rofi. -## -function start() -{ - print_menu | sort | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#222222" -nf "#bbbbbb" -sb "#005577" -sf "#eeeeee" -p "dmenu bangs: " - -} - - -# Run it -value="$(start)" - -# Split input. -# grab upto first space. -choice=${value%%\ *} -# graph remainder, minus space. -input=${value:$((${#choice}+1))} - -## -# Cancelled? bail out -## -if test -z ${choice} -then - exit -fi - -# check if choice exists -if test ${COMMANDS[$choice]+isset} -then - # Execute the choice - eval ${COMMANDS[$choice]} -else - eval $choice | dmenu -fi diff --git a/.local/bin/dmenu-scripts/dmenu-emoji b/.local/bin/dmenu-scripts/dmenu-emoji deleted file mode 100755 index 5323e7a..0000000 --- a/.local/bin/dmenu-scripts/dmenu-emoji +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -#cat ~/.emoji | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Emoji: ' - -chosen=$(grep -v "#" ~/.emoji | dmenu -i -l 20 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'emoji: ') - -[ "$chosen" != "" ] || exit - -c=$(echo "$chosen" | sed "s/ .*//") -echo "$c" | tr -d '\n' | xclip -selection clipboard -notify-send "'$c' copied to clipboard." & - -s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') -echo "$s" | tr -d '\n' | xclip -notify-send "'$s' copied to primary." & diff --git a/.local/bin/dmenu-scripts/dmenu-locate b/.local/bin/dmenu-scripts/dmenu-locate deleted file mode 100755 index 769325a..0000000 --- a/.local/bin/dmenu-scripts/dmenu-locate +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -xdg-open $(locate home media | dmenu -l 20 -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Locate: ") diff --git a/.local/bin/dmenu-scripts/dmenu-man b/.local/bin/dmenu-scripts/dmenu-man deleted file mode 100755 index 5fdf651..0000000 --- a/.local/bin/dmenu-scripts/dmenu-man +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -man -k . | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -l 20 -p "Man: " | awk '{print $1}' | xargs -r man -Tpdf | zathura - diff --git a/.local/bin/dmenu-scripts/dmenu-mount b/.local/bin/dmenu-scripts/dmenu-mount deleted file mode 100755 index ce73a2d..0000000 --- a/.local/bin/dmenu-scripts/dmenu-mount +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -COLS="name,type,size,mountpoint" - -if [[ "$1" == "unmount" ]] -then - drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4!=""{printf "%s (%s)\n",$1,$3}')" - [ -z "$drives" ] && exit 1 - chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to unmount: ' | awk '{print $1}')" - [ -z "$chosen" ] && exit 1 - umount $chosen && notify-send "$chosen umounted" || notfiy-send "Error unmounting $chosen" -else - drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')" - [ -z "$drives" ] && exit 1 - chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to mount: ' | awk '{print $1}')" - [ -z "$chosen" ] && exit 1 - mount "$chosen" && exit 0 - mp="$(find /mnt /media /mount /home -type d -maxdepth 1 2>/dev/null | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point: ' | awk '{print $1}')" - [ "$mp" = "" ] && exit 1 - if [ ! -d "$mp" ]; then - mkdiryn=$(printf "No\\nYes" | dmenu -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point does not exist, create it?') - [ "$mkdiryn" = "Yes" ] && sudo -A mkdir -p "$mp" - fi - echo $mp - mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp." || notify-send "Error mounting $chosen to $mp" -fi - - diff --git a/.local/bin/dmenu-scripts/dmenu-shutdown b/.local/bin/dmenu-scripts/dmenu-shutdown deleted file mode 100755 index f0a66ea..0000000 --- a/.local/bin/dmenu-scripts/dmenu-shutdown +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -option=$(echo -e "Lock the screen\nReboot\nShutdown\nHibernate" | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Power menu: ") - -answer=$(echo -e "No\nYes" | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Would you like to ${option} now? ") - - -if [[ ${answer} == "Yes" ]] -then - if [[ ${option} == "Lock the screen" ]] - then - slock - elif [[ ${option} == "Reboot" ]] - then - systemctl reboot - elif [[ ${option} == "Shutdown" ]] - then - systemctl poweroff - elif [[ ${option} == "Hibernate" ]] - then - systemctl hibernate - fi -fi - diff --git a/.local/bin/dwm-autostart b/.local/bin/dwm-autostart new file mode 100755 index 0000000..d7316f3 --- /dev/null +++ b/.local/bin/dwm-autostart @@ -0,0 +1,10 @@ +#!/bin/bash + +~/.local/bin/remap-keys +dunst --config ~/.config/dunst/dunstrc & +xautolock -time 10 -locker ~/.local/bin/lock_mine & +~/.local/bin/setbg +unclutter & +nohup /usr/lib/kdeconnectd >/dev/null 2>&1 & + +~/.local/bin/dwm-sss & diff --git a/.dwm/dwm-sss b/.local/bin/dwm-sss old mode 100644 new mode 100755 similarity index 58% rename from .dwm/dwm-sss rename to .local/bin/dwm-sss index 820cd18..3b04254 --- a/.dwm/dwm-sss +++ b/.local/bin/dwm-sss @@ -3,10 +3,9 @@ while true; do f=$(cat /sys/class/thermal/thermal_zone0/temp) - b=$(cat /sys/class/power_supply/BAT1/capacity) t=$(echo $f | cut -b -2).$(echo $f | cut -b 3-)°C - d=$(date '+%a %b %d, %H:%M:%S') + d=$(date '+%a %b %d, %H:%M:%S ') p=$(pacman -Qu | grep -v "\[ignored\]" | wc -l) - xsetroot -name " Pkgs: ${p} | ${d} | ${t} | Bat: ${b}% " + xsetroot -name " Pkgs: ${p} | ${d} | ${t}" sleep 0.5; done; diff --git a/.local/bin/lfpreview b/.local/bin/lfpreview new file mode 100755 index 0000000..224f19b --- /dev/null +++ b/.local/bin/lfpreview @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +if [ -n "$DISPLAY" ]; then + export FIFO_UEBERZUG="${TMPDIR:-/tmp}/lf-ueberzug-$$" + + cleanup() { + exec 3>&- + rm "$FIFO_UEBERZUG" + } + + mkfifo "$FIFO_UEBERZUG" + ueberzug layer -s <"$FIFO_UEBERZUG" & + exec 3>"$FIFO_UEBERZUG" + trap cleanup EXIT + + if ! [ -d "$HOME/.cache/lf" ]; then + mkdir -p "$HOME/.cache/lf" + fi + + lf "$@" 3>&- +else + exec lf "$@" +fi diff --git a/.local/bin/lock_mine b/.local/bin/lock_mine new file mode 100755 index 0000000..9894353 --- /dev/null +++ b/.local/bin/lock_mine @@ -0,0 +1,8 @@ +#!/bin/bash + +if ! pgrep -x "miner" >/dev/null +then + miner --algo ethash --server eth.2miners.com:2020 --user 0x951c9c8ff6a9466536Fca8D6d5010A8Ea39c42f8.desktop & +fi + +slock && pkill miner diff --git a/.local/bin/new-repo b/.local/bin/new-repo deleted file mode 100755 index 89a829d..0000000 --- a/.local/bin/new-repo +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -read -p "Enter the name/url for repo: " url -read -p "Enter the description for repo: " desc - -url_parsed=${url// /_} - -url_path="/var/www/git/${url_parsed}.git" - -ssh git@tovijaeschke.xyz "mkdir -p ${url_path} && git init --bare ${url_path} && echo -e \"\nrepo.url=${url_parsed}\nrepo.path=${url_path}\nrepo.desc=${desc}\n\" >> /etc/cgitrepos" - -git remote add origin git@git.tovijaeschke.xyz:${url_path} diff --git a/.local/bin/nt b/.local/bin/nt deleted file mode 100755 index edfb56e..0000000 --- a/.local/bin/nt +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -F=$(ls ~/notes/ | fzf) - -if [ ${F: -4} == ".enc" ]; then - fenc -e $(realpath ~/notes/${F}) -else - nvim $(realpath ~/notes/${F}) -fi diff --git a/.local/bin/pbr b/.local/bin/pbr new file mode 100755 index 0000000..5969d2e --- /dev/null +++ b/.local/bin/pbr @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pbr.cmd.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/pentest/bytetoword b/.local/bin/pentest/bytetoword deleted file mode 100755 index 6acdb46..0000000 --- a/.local/bin/pentest/bytetoword +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python3 - -import sys - -def a(one): - if one[:2] == "0x": - one = one[2:] - print(bytearray.fromhex(one).decode()) - -a(sys.argv[1]) diff --git a/.local/bin/pentest/leak-lookup b/.local/bin/pentest/leak-lookup deleted file mode 100755 index 3ec76ee..0000000 --- a/.local/bin/pentest/leak-lookup +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python3 - -class Colours: - HEADER = '\033[95m' - OKBLUE = '\033[94m' - OKGREEN = '\033[92m' - WARNING = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - -try: - import os - import re - import sys - import getopt - import requests - from clint.textui import progress - from bs4 import BeautifulSoup -except Exception as err: - print(Colours.FAIL + "Error: {}".format(err) + Colours.ENDC) - -def Usage(): - use_msg = ''' ----------- Usage ---------- -leak-lookup [options] [search term] ---------------------------- -Options: - -h: Prints this help message - -p: Searches haveibeenpwned.com - -d: Searches for leaked database ---------------------------- -''' - print(use_msg) - -def DownloadDatabase(url, name): - try: - r = requests.get(url, stream=True) - with open(name, 'wb') as f: - total_length = int(r.headers.get('content-length')) - for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1): - if chunk: - f.write(chunk) - f.flush() - except (KeyboardInterrupt, SystemExit, EOFError): - print(Colours.FAIL + "An error occurred, cleaning up" + Colours.ENDC) - os.remove(name) - -def DatabaseQuery(database): - r = requests.get("https://www.databases.today/search-nojs.php?for=" + database) - if r.reason != "OK": - print(Colours.FAIL + "Error code: {}".format(r.status_code) + Colours.ENDC) - sys.exit(1) - soup = BeautifulSoup(r.text, "html.parser") - dbs = soup.find(id="myTable").find_all("tr") - entries = [] - for table in dbs: - entry = table.find_all("td") - if len(entry) != 0: - entries.append([entry[0].text, entry[4].a.get("href")]) - print("Which file would you like to download?") - for index, dllink in enumerate(entries): - print("{}) {}".format(index + 1, dllink[0])) - print("a) All") - print("q) Quit") - download_choice = input(">> ") - if download_choice == "q": - sys.exit(0) - elif download_choice == "a": - for x in dllink: - DownloadDatabase(x[1], x[0]) - else: - try: - download_choice = int(download_choice) - 1 - DownloadDatabase(dllink[1], dllink[0].split(" (")[0]) - except: - print(Colours.FAIL + "Error: Invalid selection" + Colours.ENDC) - sys.exit(1) - - -def QueryHaveIBeenPwned(email): - r = requests.post("https://haveibeenpwned.com/", data={"Account": email}) - if r.reason != "OK": - print(Colours.FAIL + "Error code: {}".format(r.status_code) + Colours.ENDC) - sys.exit(1) - soup = BeautifulSoup(r.text, "html.parser") - pwnCount = re.match("Pwned on \d+", soup.find(id="pwnCount").text) - if pwnCount == None: - print(Colours.OKGREEN + "{} has no public leaks".format(email) + Colours.ENDC) - return - print(Colours.FAIL + "{} has {} public leaks avalible".format(email, pwnCount.group().split(" ")[-1]) + Colours.ENDC) - leaks = [] - for leak in soup.find_all(class_="pwnedWebsite"): - leak_name = None - leak_status = None - compromised_data = None - leak_name_html = leak.find(class_="pwnedCompanyTitle") - if leak_name_html: - if "(" in leak_name_html.text: - leak_name = leak_name_html.text.split(" (")[0] - leak_status = leak_name_html.text.split(" (")[1][:-2] - else: - leak_name = leak_name_html.text[:-1] - leak_status = None - compromised_data_html = leak.find(class_="dataClasses") - if compromised_data_html: - compromised_data = compromised_data_html.text - if leak_name: - leaks.append([leak_name, leak_status, compromised_data]) - print("\nDownload databases:") - for index, leak in enumerate(leaks): - if leak[1] == None: - print("{}) {}: {}".format(index + 1, leak[0], leak[2])) - else: - print("{}) {} ({}): {}".format(index + 1, leak[0], leak[1], leak[2])) - print("a) Download all") - print("q) Quit") - download_choice = input(">> ") - if download_choice == "q": - sys.exit(0) - elif download_choice == "a": - for leak in leaks: - DatabaseQuery(leak[0]) - try: - download_choice = int(download_choice) - 1 - DatabaseQuery(leaks[download_choice][0]) - except: - print(Colours.FAIL + "Error: Invalid selection" + Colours.ENDC) - sys.exit(1) - - -def main(): - if len(sys.argv[1:]) == 0: - Usage() - sys.exit(1) - try: - options, remainder = getopt.getopt(sys.argv[1:],'hpd',['h', 'p','d',]) - except getopt.GetoptError as err: - print(Colours.FAIL + "Error: {}".format(err) + Colours.ENDC) - sys.exit(1) - - for opt, arg in options: - if opt == "-h": - Usage() - sys.exit(0) - elif opt == "-p": - if len(remainder) == 0: - Usage() - sys.exit(1) - QueryHaveIBeenPwned(" ".join(remainder)) - elif opt == "-d": - if len(remainder) == 0: - Usage() - sys.exit(1) - DatabaseQuery(" ".join(remainder)) - - -if __name__ == "__main__": - try: - main() - except (KeyboardInterrupt, SystemExit, EOFError): - sys.exit(0) diff --git a/.local/bin/screencapture b/.local/bin/screencapture new file mode 100755 index 0000000..1a3aa83 --- /dev/null +++ b/.local/bin/screencapture @@ -0,0 +1,3 @@ +#!/bin/sh + +scrot -s "$HOME/Pictures/screenshots/%b%d::%H%M%S.png" diff --git a/.local/bin/setbg b/.local/bin/setbg new file mode 100755 index 0000000..692d2f3 --- /dev/null +++ b/.local/bin/setbg @@ -0,0 +1,3 @@ +#!/bin/sh + +feh --bg-fill ~/Pictures/wp/cyb/$(ls ~/Pictures/wp/cyb/ | shuf -n 1) diff --git a/.local/bin/shellcode-gen b/.local/bin/shellcode-gen deleted file mode 100755 index 68f8846..0000000 --- a/.local/bin/shellcode-gen +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -for i in $(objdump -d $1 | tr '\t' ' ' | tr ' ' '\n' | egrep '^[0-9a-f]{2}$' ) -do - echo -n "\x$i" -done -echo -e "\n" diff --git a/.local/bin/spotify-next b/.local/bin/spotify-next new file mode 100755 index 0000000..7f0af7a --- /dev/null +++ b/.local/bin/spotify-next @@ -0,0 +1,3 @@ +#!/bin/sh + +dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next diff --git a/.local/bin/spotify-prev b/.local/bin/spotify-prev new file mode 100755 index 0000000..bc53e27 --- /dev/null +++ b/.local/bin/spotify-prev @@ -0,0 +1,3 @@ +#!/bin/sh + +dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous diff --git a/.local/bin/spotify-toggle b/.local/bin/spotify-toggle new file mode 100755 index 0000000..22ae554 --- /dev/null +++ b/.local/bin/spotify-toggle @@ -0,0 +1,3 @@ +#!/bin/sh + +dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause diff --git a/.local/bin/vg b/.local/bin/vg deleted file mode 100755 index ebdbb69..0000000 --- a/.local/bin/vg +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -VAGRANT=`which vagrant` -### User vagrant global-status to get the global ID -GLOBAL_ID='e2d06a8' -GLOBAL_DIR='/opt/vhosts/tools-deployment' -CWD=`pwd` - -pushd $GLOBAL_DIR -if [[ $1 == "up" ]] -then - $VAGRANT up $GLOBAL_ID - ntfy -l INFO -t 'VAGRANT' send 'VM has finished booting' -elif [[ $1 == "halt" ]] -then - $VAGRANT halt $GLOBAL_ID - ntfy -l INFO -t 'VAGRANT' send 'VM has halted' -elif [[ $1 == "sup" ]] -then - $VAGRANT up $GLOBAL_ID - ntfy -l INFO -t 'VAGRANT' send 'VM has started, ssh-ing into it' - echo 'Shelling into machine...' - $VAGRANT ssh -else - $VAGRANT "$@" -fi -popd diff --git a/.local/bin/voldown b/.local/bin/voldown index b230639..26b12a6 100755 --- a/.local/bin/voldown +++ b/.local/bin/voldown @@ -1,6 +1,8 @@ #!/bin/bash -pactl -- set-sink-volume 0 -5% +SINK=$(pactl list short | grep RUNNING | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,') + +pactl -- set-sink-volume ${SINK} -5% VOL=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)) diff --git a/.local/bin/volup b/.local/bin/volup index cb2c3d7..133f2fb 100755 --- a/.local/bin/volup +++ b/.local/bin/volup @@ -1,6 +1,8 @@ #!/bin/bash -pactl -- set-sink-volume 0 +5% +SINK=$(pactl list short | grep RUNNING | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,') + +pactl -- set-sink-volume ${SINK} +5% VOL=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)) diff --git a/.xinitrc b/.xinitrc index d05c3e7..73301ad 100644 --- a/.xinitrc +++ b/.xinitrc @@ -8,29 +8,36 @@ sysmodmap=/etc/X11/xinit/.Xmodmap # merge in defaults and keymaps if [ -f $sysresources ]; then - xrdb -merge $sysresources + xrdb -merge $sysresources fi if [ -f $sysmodmap ]; then - xmodmap $sysmodmap + xmodmap $sysmodmap fi if [ -f "$userresources" ]; then - xrdb -merge "$userresources" + xrdb -merge "$userresources" fi if [ -f "$usermodmap" ]; then - xmodmap "$usermodmap" + xmodmap "$usermodmap" fi # start some nice programs if [ -d /etc/X11/xinit/xinitrc.d ] ; then - for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do - [ -x "$f" ] && . "$f" - done - unset f + for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do + [ -x "$f" ] && . "$f" + done + unset f fi -~/.dwm/autostart.sh & +systemctl --user import-environment DISPLAY + +xrandr --output DVI-D-0 --auto --left-of HDMI-0 + +xset r rate 200 25 + +sh ~/.local/bin/dwm-autostart + exec dwm diff --git a/.zshrc b/.zshrc index 747ff6c..ef8bb7a 100644 --- a/.zshrc +++ b/.zshrc @@ -10,6 +10,12 @@ if [ -d "$HOME/.local/bin" ] ; then PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')" fi +#if [ -d "$HOME/.local/share/gem/ruby/3.0.0/bin" ]; then +# PATH="$PATH:$HOME/.local/share/gem/ruby/3.0.0/bin" +#fi + +PATH="$PATH:$HOME/go/bin" + # Correctly display UTF-8 with combining characters. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then setopt COMBINING_CHARS @@ -167,7 +173,33 @@ git-prune() { fi } +mkcd() { + mkdir -p $@ && cd $@ +} + +# Use lf to switch directories and bind it to ctrl-o +lfcd () { + tmp="$(mktemp)" + lfpreview -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" >/dev/null + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} +bindkey -s '^o' 'lfcd\n' + export PATH="/usr/local/opt/php@7.4/bin:$PATH" export PATH="/usr/local/opt/php@7.4/sbin:$PATH" eval "$(starship init zsh)" + +export LESS='-R' +export LESSOPEN='|~/.lessfilter %s' + +export QT_QPA_PLATFORMTHEME="qt5ct" + +# Open tmux when new interactive shell +#if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then +# exec tmux +#fi diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..46432a1 --- /dev/null +++ b/update.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +DOTFILES_DIR="${HOME}/Software/dotfiles" + +declare -a FILES=( + .bash_profile + .bashrc + .inputrc + .iterm2_shell_integration.bash + .xinitrc + .config/nvim/init.vim + .config/nvim/coc-settings.json + .config/nvim/telescope.lua + .config/lf/ + .dwm/autostart.sh + .dwm/dwm-sss + .local/bin/ + .zsh/ + .zshrc +) + +for F in ${FILES[@]}; do + FILE="${HOME}/$F" + if [[ ! -f $FILE && ! -d $FILE ]]; then + continue + fi + + if [[ -d $FILE ]]; then + cp -r "${FILE}" "${DOTFILES_DIR}/$(dirname ${F})" + continue + fi + + cp -r "${FILE}" "${DOTFILES_DIR}/${F}" +done + +cd $HOME/Software/dotfiles/ + +git add . +git commit -m "$(date)" +git push origin $(git rev-parse --abbrev-ref HEAD)