This commit is contained in:
xeruf 2023-04-07 19:33:05 +02:00
parent 409c37fc97
commit 7d2e650a04
3 changed files with 35 additions and 19 deletions

View File

@ -31,6 +31,9 @@ fi
xdh="$XDG_DATA_HOME"
xch="$XDG_CONFIG_HOME"
xsh="$XDG_STATE_HOME"
alias xdh="cd $XDG_DATA_HOME"
alias xch="cd $XDG_CONFIG_HOME"
alias xsh="cd $XDG_STATE_HOME"
if test -d "$DATA"; then
da=$(builtin cd $DATA/_* && pwd)
d1=$(builtin cd $DATA/1* && pwd)
@ -323,7 +326,7 @@ sshl() {
ssh -G "$1" | grep --silent "^user root$" &&
! [[ "$1" =~ "pve.*" ]] &&
! [[ "$1" =~ "encee.*" ]] &&
! [[ "$1" =~ ".*fmh.de" ]] &&
! [[ "$1" =~ ".*fmh.*" ]] &&
! [[ "$1" =~ "delta*" ]] &&
local pass=pass
test "$all" &&
@ -568,27 +571,34 @@ compdef mkcd=mkdir
# Other stuff {{{1
# This is a function rather than a script as it potentially needs to cd out of the directory
alias unmount=umoul
# This is a function rather than a script as it potentially needs to cd out
# if the current directory is the one to unmount
umoul() {
local arg
local mnt="${MNT:-${XDG_RUNTIME_DIR}/mnt}"
# get the last arg
for arg; do true; done
if test "$arg"
then mountpoints="$(test -d "$arg" && realpath "$arg" || echo "${MNT:-${XDG_RUNTIME_DIR}/mnt}/$arg")"
mountpoint "$mountpoints" 2>/dev/null || test -b "$mountpoints" ||
mountpoints="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)"
test "$mountpoints" || return 1
else mountpoints="$PWD"
case "$arg" in
(-a|--all)
mountpoints=$(mount | grep "$mnt" | cut -d' ' -f3)
("")
mountpoints="$(pwd | grep -v /home || echo /)"
while test "$mountpoints" != "/"; do
mountpoint "$mountpoints" >/dev/null && break
mountpoints="$(dirname "$mountpoints")"
done
test "$(dirname "$mountpoints")" != "/" ||
mountpoints="$(mount |
grep --invert-match -e " /[^m][^/]*\(/[^/]*\)\? " -e "/sys" -e "/run/user" -e "/run/docker" |
fzf --select-1 --exit-0 | awk '{print $3}')" ||
grep --invert-match -e " /[^m][^/]*\(/[^/]*\)\? " -e "/sys" -e "/run/user" -e "/run/docker" -e "/home" |
fzf --exit-0 | awk '{print $3}')" ||
return $?
fi
(*)
mountpoints="$(test -d "$arg" && realpath "$arg" || echo "$mnt/$arg")"
mountpoint "$mountpoints" 2>/dev/null || test -b "$mountpoints" ||
mountpoints="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)"
test "$mountpoints" || return 1
esac
while true; do
case "$PWD" in
("$mountpoints"*) popd || builtin cd "$(dirname $mountpoints)";;

View File

@ -13,6 +13,8 @@ test "$DISPLAY" || return 0
alias graphics='lspci -vnn | grep VGA --color=never && xrandr --listproviders'
alias clip='cliphist list | fzf | cliphist decode | wl-copy'
# WIP Edit mozilla config
mozedit() (
set -eo pipefail

View File

@ -1,13 +1,17 @@
#!/bin/sh
#!/bin/sh -x
# Mount a partition by label or device identifier automatically
# Includes interactive selection if no argument is given
set -eo pipefail
_help="$0 <device> [mountpoint] [options...]"
case $1 in
(-v) shift
bash -x "$0" "$@";;
("") # TODO include size
arg=$(lsblk --list --noheadings --output name,label,fstype,mountpoint |
grep -v '/' | grep ".\+ [^ ]\+" | fzf --select-1 --exit-0 |
arg=$(
{ #for ip in $(sudo nmblookup -S \* | grep '^[0-9]' | cut -d' ' -f1)
#do timeout --kill-after=.1s .1s showmount --no-headers --exports "$ip" 2>/dev/null | sed "s|\([^ ]*\) .*|$ip:\1|"
#done &
lsblk --list --noheadings --output name,label,fstype,mountpoint | grep -v LUKS | grep -v '/' | grep ".\+ [^ ]\+"; } | fzf --exit-0 |
sed "s/^\([^ ]\+ \+\)\?\([^ ]\+\) \+[^ ]\+ *$/\2/");;
(--help) echo "$_help" && exit 0;;
(-u) shift