dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 3c6f16075b271fb331c748b69caf0aad7f45ee40
parent 91115d67a86c1ea7a8a11cc739de53b302a6f48b
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 14 Nov 2019 11:55:35 +0100

Remove unused bin/ scripts, and zsh and fffs configuration

Diffstat:
D.config/fffs/plugins-zsh | 4----
D.local/bin/crun | 39---------------------------------------
D.local/bin/dmenu_run | 5-----
D.local/bin/dmenumount | 60------------------------------------------------------------
D.local/bin/dmenurecord | 105-------------------------------------------------------------------------------
D.local/bin/dmenuumount | 41-----------------------------------------
D.local/bin/languagetool-vim | 13-------------
D.local/bin/nethogs | 2--
D.local/bin/spoof-mac-address.sh | 30------------------------------
D.local/bin/textqr | 32--------------------------------
D.zshrc | 240-------------------------------------------------------------------------------
11 files changed, 0 insertions(+), 571 deletions(-)

diff --git a/.config/fffs/plugins-zsh b/.config/fffs/plugins-zsh @@ -1,4 +0,0 @@ -https://github.com/zsh-users/zsh-autosuggestions -https://github.com/zsh-users/zsh-completions -https://github.com/zsh-users/zsh-syntax-highlighting -https://github.com/zsh-users/zsh-history-substring-search diff --git a/.local/bin/crun b/.local/bin/crun @@ -1,39 +0,0 @@ -#!/bin/sh - -# CRUN compiles C/C++ code to a temporary file, and executes it. -# Author: Anders Damsgaard, andersd@risup.net -# License: GNU Public License, v. 3+ - -# Define compilers and the common compiler flags -CC=cc -CXX=cpp -CFLAGS="-g -Wall -Wextra " - -fullfilename=$(basename "$1") -extension="${fullfilename##*.}" -filename="${fullfilename%.*}" -tmpname=/tmp/$filename - -# Check if the corresponding file is older than the source -# and recompile it if that's the case. -# arg 1: compiler, arg 2: source code file -compile() { - if [ -e "$tmpname" ]; then - if test "$2" -nt "$tmpname"; then - $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" - fi - else - $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" - fi -} - -# Compile source to file in /tmp -if [ "$extension" = "c" ]; then - compile $CC "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" -fi - -if [ "$extension" = "cpp" ]; then - compile $CXX "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" -fi - -$tmpname diff --git a/.local/bin/dmenu_run b/.local/bin/dmenu_run @@ -1,5 +0,0 @@ -#!/bin/sh -set -eu -cmd="$(dmenu_path | dmenu "$@")" -out="$(eval "$cmd" 2>&1)" -[ "$out" != "" ] && notify-send "\$ $cmd" "$out" diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount @@ -1,60 +0,0 @@ -#!/bin/sh - -# Gives a dmenu prompt to mount unmounted drives and Android phones. If -# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll -# be prompted to give a mountpoint from already existsing directories. If you -# input a novel directory, it will prompt you to create that directory. - -getmount() { \ - [ -z "$chosen" ] && exit 1 - mp="$(find $1 2>/dev/null | dmenu -i -p "Mount point")" - [ "$mp" = "" ] && exit 1 - if [ ! -d "$mp" ]; then - mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") - [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") - fi - } - -mountusb() { \ - chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" - sudo -A mount "$chosen" 2>/dev/null && notify-send "πŸ’» USB mounting" "$chosen mounted." && exit 0 - alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}') - getmount "/mnt /media /mount /home -maxdepth 1 -type d $alreadymounted" - partitiontype="$(lsblk -no "fstype" "$chosen")" - case "$partitiontype" in - "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; - *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; - esac - notify-send "πŸ’» USB mounting" "$chosen mounted to $mp." - } - -mountandroid() { \ - chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1) - getmount "$HOME -maxdepth 3 -type d" - simple-mtpfs --device "$chosen" "$mp" - notify-send "πŸ€– Android Mounting" "Android device mounted to $mp." - } - -asktype() { \ - case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in - USB) mountusb ;; - Android) mountandroid ;; - esac - } - -anddrives=$(simple-mtpfs -l 2>/dev/null) -usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')" - -if [ -z "$usbdrives" ]; then - [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit - echo "Android device(s) detected." - mountandroid -else - if [ -z "$anddrives" ]; then - echo "USB drive(s) detected." - mountusb - else - echo "Mountable USB drive(s) and Android device(s) detected." - asktype - fi -fi diff --git a/.local/bin/dmenurecord b/.local/bin/dmenurecord @@ -1,105 +0,0 @@ -#!/bin/sh - -# Usage: -# `record`: Ask for recording type via dmenu -# `record screencast`: Record both audio and screen -# `record video`: Record only screen -# `record audio`: Record only audio -# `record kill`: Kill existing recording -# -# If there is already a running instance, user will be prompted to end it. - -updateicon() { \ - echo "$1" > /tmp/recordingicon - pkill -RTMIN+9 i3blocks - } - -killrecording() { - recpid="$(cat /tmp/recordingpid)" - # kill with SIGTERM, allowing finishing touches. - kill -15 "$recpid" - rm -f /tmp/recordingpid - updateicon "" - pkill -RTMIN+9 i3blocks - # even after SIGTERM, ffmpeg may still run, so SIGKILL it. - sleep 3 - kill -9 "$recpid" - exit - } - -screencast() { \ - ffmpeg -y \ - -f x11grab \ - -framerate 60 \ - -s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \ - -i :0.0 \ - -f alsa -i default \ - -r 30 \ - -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \ - "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "βΊοΈπŸŽ™οΈ" - } - -video() { ffmpeg \ - -f x11grab \ - -s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \ - -i :0.0 \ - -c:v libx264 -qp 0 -r 30 \ - "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "⏺️" - } - -webcamhidef() { ffmpeg \ - -f v4l2 \ - -i /dev/video0 \ - -video_size 1920x1080 \ - "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ₯" - } - -webcam() { ffmpeg \ - -f v4l2 \ - -i /dev/video0 \ - -video_size 640x480 \ - "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ₯" - } - - -audio() { \ - ffmpeg \ - -f alsa -i default \ - -c:a flac \ - "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & - echo $! > /tmp/recordingpid - updateicon "πŸŽ™οΈ" - } - -askrecording() { \ - choice=$(printf "screencast\\nvideo\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:") - case "$choice" in - screencast) screencast;; - audio) audio;; - video) video;; - webcam) webcam;; - "webcam (hi-def)") webcamhidef;; - esac - } - -asktoend() { \ - response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && - [ "$response" = "Yes" ] && killrecording - } - - -case "$1" in - screencast) screencast;; - audio) audio;; - video) video;; - kill) killrecording;; - *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; -esac diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount @@ -1,41 +0,0 @@ -#!/bin/sh -# A dmenu prompt to unmount drives. -# Provides you with mounted partitions, select one to unmount. -# Drives mounted at /, /boot and /home will not be options to unmount. - -unmountusb() { - [ -z "$drives" ] && exit - chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') - [ -z "$chosen" ] && exit - sudo -A umount "$chosen" && pgrep -x dunst && notify-send "$chosen unmounted." - } - -unmountandroid() { \ - chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") - [ -z "$chosen" ] && exit - fusermount -u "$chosen" && pgrep -x dunst && notify-send "$chosen unmounted." - } - -asktype() { \ - case $(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?") in - USB) unmountusb ;; - Android) unmountandroid ;; - esac - } - -drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}') - -if ! grep simple-mtpfs /etc/mtab; then - [ -z "$drives" ] && echo "No drives to unmount." && exit - echo "Unmountable USB drive detected." - unmountusb -else - if [ -z "$drives" ] - then - echo "Unmountable Android device detected." - unmountandroid - else - echo "Unmountable USB drive(s) and Android device(s) detected." - asktype - fi -fi diff --git a/.local/bin/languagetool-vim b/.local/bin/languagetool-vim @@ -1,13 +0,0 @@ -#!/bin/sh -set -eu - -if [ "$#" -lt 1 ]; then - f="$(mktemp)" - cat > "$f" -else - f="$1" -fi - -languagetool -l en-US \ - --languagemodel /usr/share/ngrams --word2vecmodel /usr/share/word2vec \ - "$f" 2>/dev/null diff --git a/.local/bin/nethogs b/.local/bin/nethogs @@ -1,2 +0,0 @@ -#!/bin/sh -sudo /usr/bin/nethogs diff --git a/.local/bin/spoof-mac-address.sh b/.local/bin/spoof-mac-address.sh @@ -1,30 +0,0 @@ -#!/bin/bash -e -device=wlp3s0 - -yellow=$(tput setaf 3) -reset=$(tput sgr0) - -function printmac { - ip link show $device | awk '{print $2}' | tail -n 1 -} - -echo -en "${yellow}Mac address of $device before:${reset}\t" -printmac - -echo "Bringing $device down" -sudo ip link set $device down - -sleepduration=$(echo 10 + $RANDOM/1000 | bc) -echo -e "${yellow}Sleeping $sleepduration seconds...${reset}" -sleep "$sleepduration" - -echo "Spoofing MAC address for $device" -sudo macchanger -r "$device" - -sleep 1 - -echo "Bringing $device up" -sudo ip link set $device up - -echo -en "${yellow}Mac address of $device after:${reset}\t" -printmac diff --git a/.local/bin/textqr b/.local/bin/textqr @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -set -e - -pgrep -x dmenu && exit 1 - -names="Susan\nAnders\nChristian\nJesper\nSimon\nFar\nMor\nLars" -recipient=$(echo -e "${names[@]}" | dmenu -i -p "To:" || exit 1) - -shopt -s extglob # use extended pattern matching -case "$recipient" in - ?(\+)+([0-9])) - number="$recipient" - ;; - +(?)) - number="$(phone_numbers.sh "$recipient")" - ;; - *) - echo "Usage: ${0##*/} RECIPIENT MESSAGE" - exit 1 -esac - -keyboard-layout-switch.sh dk -message=$(echo "πŸ’¬" | dmenu -i -p "Message:") || exit 1 -keyboard-layout-switch.sh us - -qrencode -o - -s 1 \ - "$number $message" | - feh --auto-zoom \ - --fullscreen \ - --force-aliasing \ - --image-bg white \ - - diff --git a/.zshrc b/.zshrc @@ -1,240 +0,0 @@ -#### ZSH PERFORMANCE DEBUG -debug_startup=false -[ "$debug_startup" = true ] && zmodload zsh/zprof - - -#### ZSH OPTIONS - -# man zshoptions -setopt append_history # zsh sessions append their history to the hist file -setopt autopushd # make cd push the old dir to the dir stack -setopt extendedglob # globs (. is file, / is dir) see `man zshexpn` -setopt hist_ignore_dups # ignore duplicate cmds in history -setopt histignorespace # don't store cmds prefixed with space in history -setopt interactivecomments # allow in-line comments in prompt -setopt prompt_subst # perform param exp, cmd subst, arith exp in prompt -setopt share_history # import new commands from the history file -unsetopt autocd # cd into directory if called by name -unsetopt beep # beep on error -unsetopt hist_verify # verify before executing cmd from history (e.g. !!) -unsetopt notify # report status of bg jobs immediately -unsetopt nomatch # show error if wildcards do not match any files - -autoload -Uz add-zsh-hook cdr chpwd_recent_dirs colors compinit \ - edit-command-line select-bracketed select-quoted zmv - -compinit -colors -add-zsh-hook chpwd chpwd_recent_dirs - -zstyle completion:*:*:cdr:*:* menu selection -zstyle :chpwd:* recent-dirs-insert fallback -zstyle :chpwd:* recent-dirs-pushd true - -zle -N edit-command-line -zle -N select-bracketed -zle -N select-quoted -zle -N fzf-history-widget -zle -N history-substring-search-up -zle -N history-substring-search-down - -HISTFILE=~/.zhistory -HISTSIZE=$((2 ** 16)) -SAVEHIST=$((2 ** 17)) - -#### BINDINGS - -set -o vi -bindkey -v -bindkey jk vi-cmd-mode -bindkey -M vicmd v edit-command-line -bindkey -a ? fzf-history-widget -bindkey -a k history-substring-search-up -bindkey -a j history-substring-search-down -bindkey '^R' history-incremental-search-backward -bindkey "^j" history-beginning-search-backward -bindkey "^k" history-beginning-search-forward -bindkey '^P' up-line-or-search -bindkey '^N' down-line-or-search -bindkey '^ ' autosuggest-accept -bindkey '^_' autosuggest-execute - -# use Ctrl-Z as fg -_foreground() { - if [[ $#BUFFER -eq 0 ]]; then - BUFFER="fg" - zle accept-line - else - zle push-input - zle clear-screen - fi -} -zle -N _foreground -bindkey '^Z' _foreground - -# launch $EDITOR with Ctrl-e -_editor() { - BUFFER="$EDITOR" - zle accept-line -} -zle -N _editor -bindkey '^e' _editor - -# launch $EDITOR+fzf with Ctrl-f -_editor_fuzzy_find() { - #BUFFER="$EDITOR -c ':fzf'" # (n)vim - BUFFER="$EDITOR +':fzf'" # vis - zle accept-line -} -zle -N _editor_fuzzy_find -bindkey '^f' _editor_fuzzy_find - -# launch $EDITOR+fzf for recent files with Ctrl-o -_editor_fuzzy_history() { - #BUFFER="$EDITOR -c ':History'" # (n)vim - BUFFER="$EDITOR +':fzfmru'" # vis - zle accept-line -} -zle -N _editor_fuzzy_history -bindkey '^o' _editor_fuzzy_history - -# launch $EDITOR+fzf+rg with Ctrl-g -_editor_fuzzy_grep() { - #BUFFER="$EDITOR -c ':Rg'" # (n)vim - BUFFER="$EDITOR +':Rg'" # vis - zle accept-line -} -zle -N _editor_fuzzy_grep -bindkey '^g' _editor_fuzzy_grep - -# launch $TERMINAL with Alt-p -_terminal() { - BUFFER="setsid $TERMINAL >/dev/null 2>&1" - zle accept-line -} -zle -N _terminal -bindkey '\ep' _terminal - -# remember -n flag for dry runs -alias zmv='noglob zmv' -alias zcp='noglob zmv -C' -alias zln='noglob zmv -L' -alias zsy='noglob zmv -Ls' - - -#### ZSH APPEARANCE - -# show execution time of previous command if more than 1 sec -convertsecs() { - ((d=${1}/3600/24)) - ((h=${1}/3600%24)) - ((m=(${1}%3600)/60)) - ((s=${1}%60)) - if [ "$d" -gt "0" ]; then - printf " %dd%02dh%02dm%02ds" $d $h $m $s - elif [ "$h" -gt "0" ]; then - printf " %dh%02dm%02ds" $h $m $s - elif [ "$m" -gt "0" ]; then - printf " %dm%02ds" $m $s - elif [ "$s" -gt "0" ]; then - printf " %ds" $s - fi -} -preexec() { - timer=${timer:-$SECONDS} -} -precmd() { - if [ $timer ]; then - timer_show=$(convertsecs $(($SECONDS - $timer))) - export EXECTIME="${timer_show}" - unset timer - fi -} - -_fix_cursor() { - echo -ne '\e[5 q' -} - -precmd_functions+=(_fix_cursor) - -git_branch() { - branch_name=$(git symbolic-ref --short HEAD 2> /dev/null) - [ -n "$branch_name" ] && echo "$branch_name$(git_modified) " || : -} - -git_grep_modified_files() { - grep -e "^.M" -e "^M." -e "^A." -e "^D." -e "^.D" -} - -git_modified() { - [ -n "$(git status --porcelain 2> /dev/null | \ - git_grep_modified_files)" ] && echo "*" || : -} - -function prompt_with_vimode { - echo - echo -n '%(1j.%jbg .)' # background jobs - echo -n "$1" - [ -z "$1" ] && # show prompt symbol if no insert/normal mode is passed - echo -n '%(!.%{$fg_bold[red]%}#.$)' || : - echo -n '%{$reset_color%} ' -} - -insert_mode='' -normal_mode='N' # normal mode indicator - -rprompt() { - echo -n "%(?..%{$fg[red]%}[%?]%{$reset_color%})" # return status - echo -n "${EXECTIME} " # runtime of prev cmd - echo -n "$(git_branch)" - echo -n "%~ " # pwd - [ "$USER" != "ad" ] && echo -n "%n@" || : - [ "$HOST" != "idkfa" ] && echo -n "%m" || : -} - -set_prompt() { - PROMPT="$(prompt_with_vimode $insert_mode)" - RPROMPT="$(rprompt)" -} -add-zsh-hook precmd set_prompt - -function zle-keymap-select { - if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi -} -zle -N zle-keymap-select - - -#### PLUGINS -if [ -f "$HOME/.config/fffs/lib/zsh/sources" ]; then - . "$HOME/.config/fffs/lib/zsh/sources" -else - fffs zsh init - . "$HOME/.config/fffs/lib/zsh/sources" -fi - - -#### EXTRA COMMANDS - -# pass **<tab> -_fzf_complete_pass() { - _fzf_complete "--no-multi --preview-window=right:hidden" "$@" < <( - pwdir=${PASSWORD_STORE_DIR-~/.password-store/} - stringsize="${#pwdir}" - find "$pwdir" -name "*.gpg" -print | - cut -c "$((stringsize + 1))"- | - sed -e 's/\(.*\)\.gpg/\1/' - ) -} - -[ -f /usr/share/fzf/key-bindings.zsh ] && \ - . /usr/share/fzf/key-bindings.zsh ] || : -[ -f /usr/share/doc/fzf/key-bindings.zsh ] && \ - . /usr/share/doc/fzf/key-bindings.zsh ] || : - -# report startup diagnostics if requested -[ "$debug_startup" = true ] && zprof || :