diff --git a/skel/.i3/config b/skel/.i3/config index d4ace6f..9fd1c4d 100644 --- a/skel/.i3/config +++ b/skel/.i3/config @@ -144,7 +144,9 @@ set $yw #ccdc90 set $gn #88b090 set $rd #e89393 # border background text -client.focused #2f2f2f #2f2f2f #ffffff +#client.focused #2f2f2f #2f2f2f #ffffff +#client.focused #ffffff #ffffff #000000 +client.focused #6a6a6a #6a6a6a #ffffff client.unfocused $bg $bg $ia client.focused_inactive $bg $bg $ac client.urgent $rd $rd $tx @@ -223,7 +225,7 @@ exec --no-startup-id /usr/bin/numlockx # Run firefox/firefox-bin exec --no-startup-id firefox -p a || firefox-bin -p a # Start syncthing if it hasn't already been started -#exec --no-startup-id /bin/zsh -c 'pidof syncthing||screen -dmS syncthing ~/bin/syncthing' +exec --no-startup-id /bin/zsh -c 'pidof syncthing||screen -dmS syncthing ~/bin/syncthing' exec --no-startup-id nextcloud # Start kdeconnect #exec --no-startup-id "~/bin/indicator-kdeconnect" diff --git a/skel/.i3/run.sh b/skel/.i3/run.sh index 8fb49a1..f727148 100755 --- a/skel/.i3/run.sh +++ b/skel/.i3/run.sh @@ -1,5 +1,22 @@ #!/usr/bin/env zsh -if [ "$1" = "lock" ];then +ARG="$1" +shift +if [ "$ARG" = "move" ]; then + shift + eval "$(xdotool getwindowfocus getwindowgeometry | grep Geometry: | perl -pe 's/^\s*Geometry: /WinH=/;s/x/\nWinW=/g')" + eval "$(xdotool getwindowfocus getwindowgeometry | grep Position: | perl -pe 's/^\s*Position: /WinY=/;s/,/\nWinX=/g;s/\s\(.+//')" + eval "$(xrandr | grep -w connected | perl -pe 's/.+?(\d+x\d+)\+\d+\+\d+.*/\1/g;s/^/MonH=/;s/x/\nMonW=/;' | head -n2)" + if [ "$ARG" = "top" ]; then + echo $((WinY)) + xdotool getwindowfocus windowmove $((WinY - 1)) 0 + elif [ "$ARG" = "right" ]; then + xdotool getwindowfocus windowmove $((MonH - WinH)) $((WinX - 1)) + elif [ "$ARG" = "left" ]; then + xdotool getwindowfocus windowmove 0 $((WinX - 1)) + elif [ "$ARG" = "bottom" ]; then + xdotool getwindowfocus windowmove $((WinY - 1)) $((MonW - WinW)) + fi +elif [ "$ARG" = "lock" ];then #!/bin/bash declare -i ID @@ -14,19 +31,19 @@ if [ "$1" = "lock" ];then echo "Touchpad enabled." fi fi -if [ "$1" = "pass" ];then +if [ "$ARG" = "pass" ];then pass -c $(ls ~/.password-store/*/*|cut -b-37 --complement|rofi -dmenu|sed -e 's/\.gpg//') fi -if [ "$1" = "screensaver" ];then +if [ "$ARG" = "screensaver" ];then cat /tmp/noss||i3lock -di `shuf -n1 -e ~/.i3/wall/*` fi -if [ "$1" = "wall" ];then +if [ "$ARG" = "wall" ];then #if [[ -d ~/.i3/wallOM ]];then feh --bg-scale "`shuf -n1 -e ~/.i3/wallOM/*`";else feh --bg-scale "`shuf -n1 -e ~/.i3/wall/*`";fi; #feh --bg-scale "$(shuf -n1 -e ~/.i3/wallOM/*)" #feh --bg-scale ~/.i3/image.png feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/sync/wallpaper/"$(hostname)"/*))" fi -if [ "$1" = "swap" ];then +if [ "$ARG" = "swap" ];then python << EOF import i3 swap = [output for output in i3.get_outputs() if output['active']] @@ -36,7 +53,7 @@ if len(swap) == 2: i3.command('move', 'workspace to output right') EOF fi -if [ "$1" = "boot" ];then +if [ "$ARG" = "boot" ];then test -f ~/.screenlayout/default.sh && ~/.screenlayout/default.sh /usr/bin/xset -b /usr/bin/xset +fp /usr/share/fonts/X11/misc @@ -58,7 +75,7 @@ if [ "$1" = "boot" ];then xinput --set-prop 'Logitech USB Optical Mouse' 'Device Accel Constant Deceleration' 3 $(which ck-launch-session 2>/dev/null) $(which i3) fi -if [ "$1" = "screen-lock" ];then +if [ "$ARG" = "screen-lock" ];then revert(){ xset dpms 0 0 0 } @@ -67,11 +84,11 @@ if [ "$1" = "screen-lock" ];then slock revert fi -if [ "$1" = "paste" ]; then +if [ "$ARG" = "paste" ]; then sleep 2 DISPLAY=:0.0 xdotool type --clearmodifiers --file <(xsel) fi -if [ "$1" = "ping" ]; then +if [ "$ARG" = "ping" ]; then shift # Return code local RET=0 @@ -80,35 +97,35 @@ if [ "$1" = "ping" ]; then # -4 : ipv4 only # check if nc has -z if nc -h |& grep -q -- -z; then - nc -w 1 -z4 "$1" "$2" >& /dev/null && RET=1 + nc -w 1 -z4 "$ARG" "$1" >& /dev/null && RET=1 # check if nc has --transfer (-x) elif nc -h |& grep -q -- --transfer; then - nc -w 1 -4 "$1" "$2" -x & /dev/null && RET=1 + nc -w 1 -4 "$ARG" "$1" -x & /dev/null && RET=1 fi echo $RET fi -if [ "$1" = "ip" ]; then +if [ "$ARG" = "ip" ]; then shift local RET=0 if [ "$(hostname)" = "MMLin" ]; then - if grep -q "$1" < <(ifconfig enp2s0f0); then + if grep -q "$ARG" < <(ifconfig enp2s0f0); then RET=1 fi elif [ "$(hostname)" = "G2" ]; then - if grep -q "$1" < <(ifconfig enp1s0;ifconfig wlp2s0); then + if grep -q "$ARG" < <(ifconfig enp1s0;ifconfig wlp2s0); then RET=1 fi elif [ "$(hostname)" = "SGen" ]; then - if grep -q "$1" < <(ifconfig enp0s25); then + if grep -q "$ARG" < <(ifconfig enp0s25); then RET=1 fi fi echo $RET fi -if [ "$1" = "copy" ]; then +if [ "$ARG" = "copy" ]; then (printf '-chegg ';xsel | perl -pe 's/[^a-zA-Z ]//g;chomp()') | xsel && notify-send "Copied" || notify-send "Error" fi -if [ "$1" = "screenshot" ]; then +if [ "$ARG" = "screenshot" ]; then \rm -f ~/last-photo/*(N) sleep .2 #DISPLAY=:0.0 xfce4-screenshooter -r -s ~/last-photo @@ -118,7 +135,7 @@ if [ "$1" = "screenshot" ]; then #DISPLAY=:0.0 scrot -s "$HOME/last-photo/$(date +'%Y-%m-%d_%T').png" \cp ~/last-photo/* ~/Pictures fi -if [ "$1" = "shutdownprompt" ]; then +if [ "$ARG" = "shutdownprompt" ]; then RESP=$(printf 'Sleep\nNMRestart\nShutdown\nRestart\nLogout\n' | rofi -i -dmenu 2>/dev/null) if [[ ! -z "$RESP" ]]; then case "$RESP" in @@ -143,13 +160,13 @@ if [ "$1" = "shutdownprompt" ]; then esac fi fi -if [ "$1" = "run" ]; then +if [ "$ARG" = "run" ]; then PATH="$HOME/bin:/usr/games/bin:$PATH" rofi -show run fi -if [ "$1" = "window" ]; then +if [ "$ARG" = "window" ]; then rofi -show window fi -if [ "$1" = "clip" ]; then +if [ "$ARG" = "clip" ]; then # Get the rofi-selected index of what to paste local INDEX="$(gpaste-client --oneline | colrm 80 | rofi -dmenu | perl -pe 's/:.*//')" # If they made a selection, select it @@ -157,3 +174,24 @@ if [ "$1" = "clip" ]; then gpaste-client select "$INDEX" fi fi +if [ "$ARG" = "ssh_helper" ]; then + if command -v iwgetid >/dev/null; then + SSID="$(iwgetid wlan0 -r)" + elif command -v nmcli >/dev/null; then + SSID="$(nmcli -t -f active,ssid dev wifi | perl -ne 'print if s/yes://;')" + fi + case "$(hostname)" in + sgen|egen|runner2) + SSID=ATTskUYuI2 + ;; + esac + logger "Found SSID for $(hostname): $SSID" + case "$SSID" in + ATTskUYuI2) + ssh -q -W "${1}" "${2}@192.168.1.200" + ;; + *) + ssh -q -W "${1}" -p 23 "${2}@austenwares.com" + ;; + esac +fi diff --git a/skel/.vimrc b/skel/.vimrc index 421534b..f89fbb6 100644 --- a/skel/.vimrc +++ b/skel/.vimrc @@ -6,7 +6,6 @@ endif "let g:formatters_cpp = ['my_custom_cpp'] "let g:formatdef_my_custom_java = '"astyle --mode=java -xc --style=google -j -s2 -xG -S -K -N -xn -xl -n -p -H"' "let g:formatters_java = ['my_custom_java'] -"let g:UltiSnipsUsePythonVersion=3 command! WW %!sudo tee > /dev/null % "TODO: Fix this "let g:rbpt_loadcmd_toggle = 1 @@ -118,6 +117,8 @@ set grepprg=grep\ -nH\ $* " Trial mappings { "nnoremap o m`o`` "nnoremap O m`O`` + " Always search in the forward direction + nnoremap # #/ " } @@ -175,6 +176,8 @@ set grepprg=grep\ -nH\ $* syntax on " } +"lacheck does not work +let b:ale_linters = {'tex': [ "alex", "chktex", "proselint", "redpen", "vale", "write-good" ]} "Polyglot conflicts with another latex editor let g:polyglot_disabled = ['latex'] "Signify @@ -187,29 +190,29 @@ let g:signify_difftool = 'diff' " \ 'file': '\v\.(exe|so|dll|class)$', " \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', " \ } -"Airline -"let g:airline_left_sep='▶' -"let g:airline_right_sep='◀' -"let g:airline#extensions#syntastic#enabled=0 "let g:ycm_show_diagnostics_ui=0 "let g:ycm_path_to_python_interpreter='/usr/bin/python2.7' -"let g:syntastic_cpp_compiler = 'clang++' -"let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++' -"let g:syntastic_cpp_compiler_options = ' -std=c++11' -"let g:airline#extensions#whitespace#enabled=0 -"let g:airline#extensions#whitespace#show_message=0 -"let g:airline#extensions#tmuxline#enabled=1 "let g:formatprg_cpp="astyle" "let g:formatprg_args_expr_cpp=" --mode=c --style=1tbs -xe -k1 -j" " These flags don't work for some reason " -xn -xc -xl -S "inoremap pumvisible() ? "\" : "\" "inoremap pumvisible() ? "\" : "\" -"let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsUsePythonVersion=3 + +"let g:UltiSnipsJumpForwardTrigger="" "let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsExpandTrigger = "" +let g:UltiSnipsJumpForwardTrigger = "" +let g:UltiSnipsJumpBackwardTrigger = "" +let g:SuperTabDefaultCompletionType = '' + +let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`', '$':'$'} + +"let g:UltiSnipsExpandTrigger="" "let g:UltiSnipsListSnippets="" "let g:UltiSnipsEditSplit="vertical" -inoremap pumvisible() ? "\" : "\u\" +"inoremap pumvisible() ? "\" : "\u\" filetype off if has("win32") call plug#begin('~/vimfiles/plugged') @@ -239,9 +242,11 @@ endif "Fuzzy file search | https://github.com/kien/ctrlp.vim Plug 'https://gitea.austenwares.com/vim/tabular', { 'on': 'Tab' } "Quickly make tables in vim | https://github.com/godlygeek/tabular - "Plug 'https://gitea.austenwares.com/vim/UltiSnips' + Plug 'https://gitea.austenwares.com/vim/UltiSnips' "Adds snippet support | https://github.com/sirver/UltiSnips - "Plug 'https://gitea.austenwares.com/vim/vim-snippets' + "Plug 'https://github.com/ajh17/VimCompletesMe' + "Supposed to be a good tab plugin + Plug 'https://gitea.austenwares.com/vim/vim-snippets' "Add snippets | https://github.com/honza/vim-snippets Plug 'https://gitea.austenwares.com/vim/eregex.vim' "Real regexes in vim | https://github.com/othree/eregex.vim @@ -295,6 +300,8 @@ endif " Staging { "Plug 'https://gitea.austenwares.com/vim/vim-symfony' "Plug 'dracula/vim' + Plug 'https://gitea.austenwares.com/vim/ale' + Plug 'https://github.com/ervandew/supertab' "Plug 'idanarye/vim-vebugger' "Debugger | https://github.com/idanarye/vim-vebugger diff --git a/skel/.zsh/borg.zsh b/skel/.zsh/borg.zsh index 4793d16..38250d8 100644 --- a/skel/.zsh/borg.zsh +++ b/skel/.zsh/borg.zsh @@ -1,15 +1,15 @@ b-list() { if [[ -z "$1" ]]; then - column -t <(borg list "$BORG_REPO") + column -t <(borg list "::") else - borg list "$BORG_REPO::$1" + borg list "::$1" fi } b-delete() { while (( $# > 0 )); do if [[ ! -z "$1" ]]; then echo "Deleting... $1" - borg delete "$BORG_REPO::$1" + borg delete "::$1" fi shift done @@ -24,16 +24,16 @@ b-create() { if [[ -f "/home/stonewareslord/syncthing/me/backup/$(hostname)/mount" ]]; then "$SUDO" "/home/stonewareslord/syncthing/me/backup/$(hostname)/mount" fi - "$SUDO" borg create -vpsx --exclude-caches --compression lzma,7 --exclude-from "$IGNORE_FILE" $BORG_REPO::$(hostname)-$(uuidgen) / /boot /home + "$SUDO" borg create -vpsx --exclude-caches --compression lzma,7 --exclude-from "$IGNORE_FILE" "::$(hostname)-$(uuidgen)" / /boot /home } b-rename() { - borg rename -v "$BORG_REPO::$1" "$2" + borg rename -v "::$1" "$2" } b-info() { - borg info "$BORG_REPO::$1" + borg info "::$1" } b-diff() { - borg list "$BORG_REPO" + borg list "::" echo -n "First ID: " read ID1 echo -n "Second ID: " @@ -60,8 +60,8 @@ b-diff() { echo "FILE_SIZE_LIST2: $FILE_SIZE_LIST2" echo "COMPLETED_FILE1: $COMPLETED_FILE1" echo "COMPLETED_FILE2: $COMPLETED_FILE2" - borg list --short "$BORG_REPO::$ID1" | pv -N "Getting List 1" > "$FILE_LIST1" - borg list --short "$BORG_REPO::$ID2" | pv -N "Getting List 2" > "$FILE_LIST2" + borg list --short "::$ID1" | pv -N "Getting List 1" > "$FILE_LIST1" + borg list --short "::$ID2" | pv -N "Getting List 2" > "$FILE_LIST2" # Find differences and calculate them diff <(pv -cN "List 1 Diff" "$FILE_LIST1") <(pv -cN "List 1 Diff" "$FILE_LIST2") > >(ag '^<' | perl -pe 's/^< //' > "$A_DIFFS") > >(ag '^>' | perl -pe 's/^> //' > "$B_DIFFS") # Truncate everything @@ -88,7 +88,7 @@ b-diff() { echo "$COMPLETED_FILE2" } b-size() { - borg list "$BORG_REPO" + borg list "::" echo -n "ID: " read ID if [ -z "$ID" ]; then @@ -101,7 +101,7 @@ b-size() { echo "FILE_LIST: $FILE_LIST" echo "FILE_SIZE_LIST: $FILE_SIZE_LIST" echo "COMPLETED_FILE: $COMPLETED_FILE" - borg list --short "$BORG_REPO::$ID" | pv -N "Getting List" > "$FILE_LIST" + borg list --short "::$ID" | pv -N "Getting List" > "$FILE_LIST" while read i do test -f /"$i" && du -sh /"$i" 2>/dev/null >> "$FILE_SIZE_LIST" @@ -114,8 +114,8 @@ b-size() { b-extract() { local BACKUP="$1" shift - borg extract "$BORG_REPO::$BACKUP" $* + borg extract "::$BACKUP" $* } b-cmd() { - echo "$BORG_REPO" $* + echo "::" $* } diff --git a/skel/.zshrc b/skel/.zshrc index 240141d..6fe1d41 100644 --- a/skel/.zshrc +++ b/skel/.zshrc @@ -15,21 +15,12 @@ export HISTFILE="$HOME/.zsh_history" setopt APPEND_HISTORY setopt EXTENDED_HISTORY setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS -export DISABLE_AUTO_TITLE=true export EDITOR='vim' export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x' zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.cache/zsh -compress(){ - INFILE="${1:r}.tpxz" - if [ -f "$INFILE" ]; then - echo "Won't replace $1" >&2 - return 1 - fi - tar --xattrs -I pixz -cpf "$INFILE" $* -} # Check if a command exists -ex(){ +ex() { command -v "$1" >/dev/null return $? } @@ -42,67 +33,24 @@ else fi # For pasting in commands that start with $ $ () { - $* + "$@" } -# A service implementation -sv () { - command="${@: -1}" - while (( $# > 1 )); do - if [[ "$command" == "i" ]]; then - echo "Status of $1" - rc-service "$1" status - shift - continue - fi - sudo true || return 2 - if [[ "$1" == "sshd" ]] || [[ "$1" == "ssh" ]]; then - echo "Checking sshd config..." - sudo sshd -t && echo "Config good. Continuing" || (echo "Aborting due to bad ssh config";return 1) - fi - if [[ "$command" == "r" ]]; then - echo "Restarting $1" - sudo rc-service "$1" restart - elif [[ "$command" == "s" ]]; then - echo "Starting $1" - sudo rc-service "$1" start - elif [[ "$command" == "x" ]]; then - echo "Stopping $1" - sudo rc-service "$1" stop - else - sudo rc-service "$1" "$command" - fi - shift - done -} -compdef _services sv # Run gui application as root by copying xauth credentials -asroot(){ +asroot() { # Use temporary file for added security - TEMPFILE=$(tempfile) - xauth extract $TEMPFILE $DISPLAY + TEMPFILE="$(tempfile)" + xauth extract "$TEMPFILE" "$DISPLAY" sudo zsh -c "xauth merge $TEMPFILE;(srm $TEMPFILE||rm $TEMPFILE)&'$@';" } # De-symlink dsl() { while (( $# > 0 )); do - readlink $1 2>&1 >/dev/null && mv $(readlink $1) $1 + readlink "$1" 2>&1 >/dev/null && mv "$(readlink "$1")" "$1" shift done } -# Update the sync project -update-sync-project() { - if [[ ! -L ~/.zshrc ]]; then - echo "zshrc isn't a link" - return 1 - fi - local ABSPATH="$(\dirname "$(\dirname "$(\readlink -e ~/.zshrc)")")" - git -C "$ABSPATH" pull origin master - if (( $# > 0 )); then - "$ABSPATH/scripts/sync.sh" $* - fi -} # Remove directory by removing subdirectories up a level -dedir(){ +dedir() { # Try removing the directory if it's empty, fail silently if you can't =rmdir "$1" 2>/dev/null && return # Make a uuid to avoid name conflicts @@ -116,7 +64,7 @@ dedir(){ =rmdir "$name" || return 3 } # Run multitail on logs -mt(){ +mt() { if [[ -z "$1" ]]; then echo "Opts:\nm xe gitea dm syncthing g" >&2 return 1 @@ -130,111 +78,39 @@ mt(){ syncthing) sudo multitail /var/log/syncthing.{err,log};; g) sudo watch -c genlop -tc;; sync) watch grep -e Dirty: -e Writeback: /proc/meminfo;; - *) multitail "$1" + *) multitail "$@" esac } -run(){ +run() { test -f "${1:r}" && rm "${1:r}" echo "Building..." >&2 gcc -Wall -g -std=c99 "${1:r}.c" -o "${1:r}" && (echo "Running..." >&2;./"${1:r}") } -upload() { - tar -cf - "$*" | base64 | curl --data-urlencode text@- -d title="File uploaded at $(date '+%d/%h/%y %H:%M:%S') on $(hostname)" -d name=$USER -d expire="1440" https://austenwares.com/paste/api/create | sed -e 's/view/view\/raw/' -} -download() { - URL="$(printf $1 | perl -pe 's/\/paste\/view(?!\/raw)/\/paste\/view\/raw/')" - curl "$URL" | base64 -d | tar -xf - -} -update-tool() { - if [ "$EUID" -ne 0 ]; then - echo "This function should be run as root" - return 1 - fi - local RESP="" - while [[ "$RESP" != "q" ]]; do - CMD=${RESP:0:1} - case "$CMD" in - u) update -q;; - l) layman -S ;; - g) upgrade;; - e) etc-update;; - p) emerge -Av @preserved-rebuild --usepkg=n --keep-going=y;; - m) emerge -Av @module-rebuild --usepkg=n;; - d) emerge -Ava --depclean;; - h) haskell-updater -- --usepkg=n;; - c) perl-cleaner --reallyall;; - y) python-updater;; - r) revdep-rebuild;; - q) return;; - esac - RESP=${RESP:1} - if [[ ! -z "$RESP" ]]; then - continue - fi - echo "Commands:" - echo "u: update" - echo "l: layman -S" - echo "g: upgrade" - echo "e: etc-update" - echo "p: emerge @preserved-rebuild --usepkg=n --keep-going=y" - echo "m: emerge @module-rebuild --usepkg=n" - echo "d: emerge --ask --depclean" - echo "h: haskell-updater -- --usepkg=n" - echo "c: perl-cleaner --reallyall" - echo "y: python-updater" - echo "r: revdep-rebuild" - echo "q: quit" - echo -n '\a> ' - read RESP - done -} -if ex vim; then - alias vi='vim' -fi -if ex rc-service; then - alias service='rc-service' -fi -if ex ip; then - alias ip='ip -c' -fi -if ex adb; then - alias apush="adb push -p" - alias apull="adb pull -p" -fi -alias cleaner="sudo ~/run.sh 'perl-cleaner --reallyall' 'python-updater' 'haskell-updater -- --usepkg=n'" -alias jsonpretty='python -m json.tool' -alias nmrestart='nmcli radio wifi off;nmcli radio wifi on' -if ex mtr; then - alias mtr='mtr -t' -fi -if ex telegram-cli; then - alias tg='telegram-cli -NWA --disable-link-preview' -fi -alias perm='stat -c "%a %n"' +ex vim && alias vi='vim' +ex rc-service && alias service='rc-service' +ex ip && alias ip='ip -c' +ex adb && alias apush="adb push -p" +ex adb && alias apull="adb pull -p" +ex mtr && alias mtr='mtr -t' +ex telegram-cli && alias tg='telegram-cli -NWA --disable-link-preview' +ex eix && alias eix="eix -F" +ex tmux && alias tmux='tmux -2' +ex tree && alias tree='tree -C' +ex ocp && alias ocp="ocp -vs0 -dcurses" +alias jupyter='docker run --rm --user="$(id -u):$(id -g)" -v "$PWD":/home/jovyan/work -p 8888:8888 jupyter/scipy-notebook' alias afci='git x ./autoformat.sh;git commit -am "Autoformatted"' -if ex eix; then - alias eix="eix -F" -fi +alias con='git x php bin/console' +alias disphost='export DISPLAY=:0.0' +alias l='ls -CF' +alias la='ls -A' +alias less='less -R' +alias ll='ls -AlhF' +alias logout='sudo pkill -u "$USER"' alias mouse1="xmodmap <(echo pointer = 1 2 3)" alias mouse2="xmodmap <(echo pointer = 3 2 1)" -if ex ocp; then - alias ocp="ocp -vs0 -dcurses" -fi -alias con='git x php bin/console' -alias srm='shred -uzv' -alias disphost='export DISPLAY=:0.0' -alias ll='ls -AlhF' -alias la='ls -A' -alias l='ls -CF' -alias logout='sudo pkill -u $USER' -if ex tmux; then - alias tmux='tmux -2' -fi -alias less='less -R' -if ex tree; then - alias tree='tree -C' -fi +alias nmrestart='nmcli radio wifi off;sleep 1;nmcli radio wifi on' alias resource='. ~/.zshrc' +alias srm='shred -uzv' if [ "$(uname)" != "Darwin" ]; then # Not Mac export PATH="$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$HOME/.cargo/bin" @@ -252,49 +128,19 @@ fi if test -f /etc/gentoo-release; then # Gentoo alias etup='sudo etc-update' - ins(){ + ins() { # Sudo echo so we have immediate results on weather sudo worked sudo echo "Args: $*" # Beep, verbose, ask sudo emerge --autounmask-write -Ava $* echo "\a" } - upgrade(){ + upgrade() { # Sudo echo so we have immediate results on weather sudo worked sudo echo "Args: $*" sudo emerge --update --newuse --deep --verbose --tree --keep-going=y --verbose-conflicts --alert --ask --binpkg-respect-use=y --binpkg-changed-deps=y --backtrack=30 $* @world echo "\\a" } - # For emerging with absolute paths - em(){ - # Beep, verbose, ask - EMERGE_ARGS="-Ava" - X="" - for var in "$@" - do - if [[ "$var" =~ ^- ]]; then - EMERGE_ARGS="$EMERGE_ARGS $var" - else - X="$X =$var" - fi - done - echo sudo emerge "$EMERGE_ARGS""$X" - sudo emerge "$EMERGE_ARGS""$X" - echo "\a" - } - update(){ - # If this is a server computer - sudo rm -f '/usr/portage/metadata/timestamp.chk' - if ex eix-update; then - sudo zsh -c "emaint sync -a&&eix-update" - else - sudo emaint sync -a - fi - sudo -k - if [ "$1" != "-q" ]; then - echo '\a' - fi - } elif test -f /etc/lsb-release; then # Ubuntu alias install='sudo apt install' @@ -319,9 +165,7 @@ alias ............='k ../../../../../../../../../../..' alias .............='k ../../../../../../../../../../../..' alias ..............='k ../../../../../../../../../../../../..' alias ...............='k ../../../../../../../../../../../../../..' -if ex youtube-dl; then - alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'" -fi +ex youtube-dl && alias ytdl="youtube-dl -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'" if ex wemux; then alias tux="wemux" elif ex tmux; then @@ -331,9 +175,8 @@ if ex git; then alias g="git" fi alias stdns="sudo sh -c 'echo nameserver 1.1.1.1 > /etc/resolv.conf'" -alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\"" +#alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\"" alias fk='k `fzf --no-mouse -m -1 -x`' -#alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem | sudo tee /sys/power/state >/dev/null);sudo -k" alias susp="sudo true && (slock&until echo mem|sudo tee /sys/power/state>/dev/null;do sleep 1;done;sleep 4;nmcli radio wifi off;sleep 3;nmcli radio wifi on)" if ex sudo; then alias s='sudo -Hu' @@ -353,7 +196,7 @@ fi if ex rg; then alias -g G='|& rg' alias rg='rg -i' - # I'm so sorry ggreer + # I'm so sorry, ggreer alias ag=rg elif ex ag; then alias -g G='|& ag' @@ -368,8 +211,8 @@ timer() { echo done | pv -Sptels "$1" >/dev/null } -fixsh(){ - sed -i -e $1"d" ~/.ssh/known_hosts +fixsh() { + sed -i'' -e "${1}d" ~/.ssh/known_hosts } mv() { /bin/mv -v "$@" } m() { mv "$@" } @@ -392,68 +235,28 @@ linx() { elif (( $# == 1 )) && [[ -f "$1" ]]; then linx < "$1" else - tar -cf - $* | linx + tar -cf - "$@" | linx fi } -grename() { - echo incomplete - return - FILES=($*) - REGEX='s///' - echo -n "Command (frneVVVq): " - while read input; do - case $input in - f) - echo "File list:" - printf '%s\n' $FILES - ;; - r) - echo "Regex:" - echo "$REGEX" - ;; - n) - echo "Simulated replacement:" - perl-rename -n "$REGEX" $FILES - ;; - e) - echo "Editing regex..." - TEMPFILE=$(tempfile) - (cat <(printf '%s\n' $FILES);echo;echo "$REGEX") > $TEMPFILE - vim $TEMPFILE +'normal G$h' - REGEX=$(tac $TEMPFILE|grep -m1 '.') - rm $TEMPFILE - ;; - VVV) - echo "Actual results:" - perl-rename -v $REGEX $FILES - return - ;; - q) - return - ;; - esac - echo -n "Command (frneVVVq): " - done -} -bp(){ +bp() { printf '\a' } -ltar(){ - tar -cf - $@|pv -WcN tar|xz|pv -WcN lzma +ltar() { + tar -cf - "$@"|pv -WcN tar|xz|pv -WcN lzma #tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest #tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest } -ctar(){ - tar -cf - $@|pv -WcN tar|gzip|pv -WcN gzip +ctar() { + tar -cf - "$@"|pv -WcN tar|gzip|pv -WcN gzip } -offline(){ +offline() { if [ ! -z "$@" ] ; then - sudo unshare -n -- sudo -u $USER zsh -c "$@" + sudo unshare -n -- sudo -u "$USER" zsh -c "$@" else - sudo unshare -n -- sudo -u $USER LP_MARK_PREFIX=" $(tput setaf 1)(offline)$(tput sgr0) " zsh + sudo unshare -n -- sudo -u "$USER" LP_MARK_PREFIX=" $(tput setaf 1)(offline)$(tput sgr0) " zsh fi } -dnstest(){ +dnstest() { echo "resolv.conf:" cat /etc/resolv.conf echo "Testing DNS:" @@ -466,13 +269,9 @@ dnstest(){ echo "Testing DNS" curl -L portquiz.net } -tsh(){ - ssh -X $* - if which ponysay >/dev/null; then - ponysay "Connection closed!" - else - echo "\n\n\n\n\n\n\n\n\n\nSESSION CLOSED\n\n\n\n\n\n\n\n\n\n" - fi +tsh() { + ssh "$@" + echo "\n\n\n\n\n\n\n\n\n\nSESSION CLOSED\n\n\n\n\n\n\n\n\n\n" } compdefas () { local a @@ -482,11 +281,11 @@ compdefas () { } compdefas ssh tsh compdefas mv m mv -mcl(){ +mcl() { mkdir -p $1 cd $1 } -create-repo(){ +create-repo() { PRIVATE="true" while getopts ":p" opt; do case $opt in @@ -507,27 +306,7 @@ create-repo(){ read -s password curl --user "$username:$password" -d name="$1" -d private="$PRIVATE" https://gitea.austenwares.com/api/v1/user/repos } -hsh(){ - FILE="$1" - ARGS="" - while (( $# > 0 )); do - if [[ "md5" = "$1" ]] || [[ "md5sum" = "$1" ]] || [[ "m" = "$1" ]]; then - ARGS="$ARGS "md5sum - elif [[ "sha1" = "$1" ]] || [[ "sha1sum" = "$1" ]] || [[ "s" = "$1" ]]; then - ARGS="$ARGS "sha1sum - elif [[ "sha2" = "$1" ]] || [[ "sha256sum" = "$1" ]]; then - ARGS="$ARGS "sha256sum - elif [[ "sha512" = "$1" ]] || [[ "sha512sum" = "$1" ]]; then - ARGS="$ARGS "sha512sum - fi - shift - done - ARGS=$(echo "$ARGS"|xargs) - echo "Calculating ($ARGS) of \"$FILE\"" - echo pv "$FILE" \| pee $ARGS - pv "$FILE" | pee $(echo $ARGS) -} -rc(){ +rc() { case $1 in z) vim ~/.zshrc;; v) vim ~/.vimrc;; @@ -542,31 +321,7 @@ rc(){ *) echo "Opts:\nz v i\nuse make unmask mask accept_keywords keywords license" esac } -pub-git-rm(){ - if (( $# == 0 )) ; then - git remote rm local - git remote rm ncsu - git remote rm gitlab - git remote rm aws - fi - while (( $# > 0 )) ; do - git remote rm "$1" - shift - done -} -pub-git-push(){ - if (( $# == 0 )) ; then - git push local --all && git push local --tags - git push ncsu --all && git push ncsu --tags - git push gitlab --all && git push gitlab --tags - git push aws --all && git push aws --tags - fi - while (( $# > 0 )) ; do - git push "$1" --all && git push "$1" --tags - shift - done -} -k(){ +k() { #More than 1 arguement if [[ $# > 1 ]] ; then vim $@ @@ -623,16 +378,7 @@ if ex fasd; then eval "$(fasd --init auto)" fi -#Old config options that are no longer in use -#alias pg="pcregrep -M" -#if command -v greadlink 2>&1 >/dev/null; then -# alias readlink='greadlink' -#fi -#alias steamo='sudo kill -9 `pidof steam`;sudo unshare -n -- sh -c "ifconfig lo up;sudo -u $USER steam" > /dev/null 2>&1 & disown' #alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state|to\ full|percentage"' -#alias aoeu='setxkbmap -layout us -option "' -#alias asdf='setxkbmap -layout dvorak -option ""' -#alias sudo='sudo -H' echo -ne '[# ]\r' source ~/.zsh-git/lpr/liquidprompt source ~/.zsh-git/omg/base.sh