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 0e9e483eefab6b378814ade6a78cc7c417d08739
parent f31610d30e5d6713603d1e93c274746992fd9e4f
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sat, 15 Jun 2019 14:31:04 +0200

Update dmenumount script, more visrc experimentation

Diffstat:
M.config/vis/visrc.lua | 27+++++++++++++++++++++++++++
M.local/bin/dmenumount | 25+++++++++++++------------
2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -38,6 +38,23 @@ interpreters = { ["latex"] = "!tmux new-window -a 'latexmk -pdf -pvc -f $vis_filepath'", } +vis:command_register("shell", function(argv, force, cur_win, selection, range) + local out = io.popen("irg"):read() + if out then + if argv[1] then + vis:command(string.format('e "%s"', out)) + else + vis:command(string.format('open "%s"', out)) + end + vis:feedkeys("<vis-redraw>") + end +end, 'run argv in shell, ignore return status with ') + +checkers = { + ["latex"] = "!tmux split-window -p 25 'shellcheck --color=never $vis_filepath | less'", + ["bash"] = "!tmux split-window -p 25 'shellcheck --color=never $vis_filepath | less'", +} + vis:command_register("prev", function(argv, force, cur_win, selection, range) local file = io.popen('sed -n 2p ~/.mru') local output = file:read() @@ -94,4 +111,14 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) end return true; end) + vis:map(vis.modes.NORMAL, leader..'c', + function() + local command = checkers[vis.win.syntax] + if command then + --vis:command(":new") + --vis:command("<" .. command) + vis:command(command) + end + return true; + end) end) diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount @@ -1,13 +1,13 @@ #!/bin/sh -# Gives a dmenu prompt to mount unmounted drives. -# 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. -pgrep -x dmenu_themed && exit 1 + +# 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" | dmenu_themed -i -p "Type in mount point.")" + mp="$(find $1 2>/dev/null | dmenu_themed -i -p "Mount point")" [ "$mp" = "" ] && exit 1 if [ ! -d "$mp" ]; then mkdiryn=$(printf "No\\nYes" | dmenu_themed -i -p "$mp does not exist. Create it?") @@ -17,21 +17,22 @@ getmount() { \ mountusb() { \ chosen="$(echo "$usbdrives" | dmenu_themed -i -p "Mount which drive?" | awk '{print $1}')" - sudo -A mount "$chosen" && notify-send "${0##/*}" "$chosen mounted." && exit 0 - getmount "/mnt /media /mount /home -maxdepth 5 -type d" + 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";; + *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; esac - notify-send "${0##/*}" "$chosen mounted to $mp." + notify-send "💻 USB mounting" "$chosen mounted to $mp." } mountandroid() { \ chosen=$(echo "$anddrives" | dmenu_themed -i -p "Which Android device?" | cut -d : -f 1) getmount "$HOME -maxdepth 3 -type d" simple-mtpfs --device "$chosen" "$mp" - notify-send "${0##/*}" "Android device mounted to $mp." + notify-send "🤖 Android Mounting" "Android device mounted to $mp." } asktype() { \ @@ -51,7 +52,7 @@ if [ -z "$usbdrives" ]; then else if [ -z "$anddrives" ]; then echo "USB drive(s) detected." - mountusb + mountusb else echo "Mountable USB drive(s) and Android device(s) detected." asktype