aliases
This commit is contained in:
parent
409c37fc97
commit
7d2e650a04
|
@ -31,6 +31,9 @@ fi
|
||||||
xdh="$XDG_DATA_HOME"
|
xdh="$XDG_DATA_HOME"
|
||||||
xch="$XDG_CONFIG_HOME"
|
xch="$XDG_CONFIG_HOME"
|
||||||
xsh="$XDG_STATE_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
|
if test -d "$DATA"; then
|
||||||
da=$(builtin cd $DATA/_* && pwd)
|
da=$(builtin cd $DATA/_* && pwd)
|
||||||
d1=$(builtin cd $DATA/1* && pwd)
|
d1=$(builtin cd $DATA/1* && pwd)
|
||||||
|
@ -320,12 +323,12 @@ sshl() {
|
||||||
local authcache="/var/tmp/ssh-keys"
|
local authcache="/var/tmp/ssh-keys"
|
||||||
mkdir -p "$authcache"
|
mkdir -p "$authcache"
|
||||||
local file="$authcache/$1"
|
local file="$authcache/$1"
|
||||||
ssh -G "$1" | grep --silent "^user root$" &&
|
ssh -G "$1" | grep --silent "^user root$" &&
|
||||||
! [[ "$1" =~ "pve.*" ]] &&
|
! [[ "$1" =~ "pve.*" ]] &&
|
||||||
! [[ "$1" =~ "encee.*" ]] &&
|
! [[ "$1" =~ "encee.*" ]] &&
|
||||||
! [[ "$1" =~ ".*fmh.de" ]] &&
|
! [[ "$1" =~ ".*fmh.*" ]] &&
|
||||||
! [[ "$1" =~ "delta*" ]] &&
|
! [[ "$1" =~ "delta*" ]] &&
|
||||||
local pass=pass
|
local pass=pass
|
||||||
test "$all" &&
|
test "$all" &&
|
||||||
$pass scp ~/.bash_aliases "$1:" &&
|
$pass scp ~/.bash_aliases "$1:" &&
|
||||||
$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
|
$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
|
||||||
|
@ -568,27 +571,34 @@ compdef mkcd=mkdir
|
||||||
|
|
||||||
# Other stuff {{{1
|
# 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() {
|
umoul() {
|
||||||
local arg
|
local arg
|
||||||
|
local mnt="${MNT:-${XDG_RUNTIME_DIR}/mnt}"
|
||||||
# get the last arg
|
# get the last arg
|
||||||
for arg; do true; done
|
for arg; do true; done
|
||||||
if test "$arg"
|
case "$arg" in
|
||||||
then mountpoints="$(test -d "$arg" && realpath "$arg" || echo "${MNT:-${XDG_RUNTIME_DIR}/mnt}/$arg")"
|
(-a|--all)
|
||||||
mountpoint "$mountpoints" 2>/dev/null || test -b "$mountpoints" ||
|
mountpoints=$(mount | grep "$mnt" | cut -d' ' -f3)
|
||||||
mountpoints="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)"
|
("")
|
||||||
test "$mountpoints" || return 1
|
mountpoints="$(pwd | grep -v /home || echo /)"
|
||||||
else mountpoints="$PWD"
|
|
||||||
while test "$mountpoints" != "/"; do
|
while test "$mountpoints" != "/"; do
|
||||||
mountpoint "$mountpoints" >/dev/null && break
|
mountpoint "$mountpoints" >/dev/null && break
|
||||||
mountpoints="$(dirname "$mountpoints")"
|
mountpoints="$(dirname "$mountpoints")"
|
||||||
done
|
done
|
||||||
test "$(dirname "$mountpoints")" != "/" ||
|
test "$(dirname "$mountpoints")" != "/" ||
|
||||||
mountpoints="$(mount |
|
mountpoints="$(mount |
|
||||||
grep --invert-match -e " /[^m][^/]*\(/[^/]*\)\? " -e "/sys" -e "/run/user" -e "/run/docker" |
|
grep --invert-match -e " /[^m][^/]*\(/[^/]*\)\? " -e "/sys" -e "/run/user" -e "/run/docker" -e "/home" |
|
||||||
fzf --select-1 --exit-0 | awk '{print $3}')" ||
|
fzf --exit-0 | awk '{print $3}')" ||
|
||||||
return $?
|
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
|
while true; do
|
||||||
case "$PWD" in
|
case "$PWD" in
|
||||||
("$mountpoints"*) popd || builtin cd "$(dirname $mountpoints)";;
|
("$mountpoints"*) popd || builtin cd "$(dirname $mountpoints)";;
|
||||||
|
|
|
@ -13,6 +13,8 @@ test "$DISPLAY" || return 0
|
||||||
|
|
||||||
alias graphics='lspci -vnn | grep VGA --color=never && xrandr --listproviders'
|
alias graphics='lspci -vnn | grep VGA --color=never && xrandr --listproviders'
|
||||||
|
|
||||||
|
alias clip='cliphist list | fzf | cliphist decode | wl-copy'
|
||||||
|
|
||||||
# WIP Edit mozilla config
|
# WIP Edit mozilla config
|
||||||
mozedit() (
|
mozedit() (
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh -x
|
||||||
# Mount a partition by label or device identifier automatically
|
# Mount a partition by label or device identifier automatically
|
||||||
|
# Includes interactive selection if no argument is given
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
_help="$0 <device> [mountpoint] [options...]"
|
_help="$0 <device> [mountpoint] [options...]"
|
||||||
case $1 in
|
case $1 in
|
||||||
(-v) shift
|
(-v) shift
|
||||||
bash -x "$0" "$@";;
|
bash -x "$0" "$@";;
|
||||||
("") # TODO include size
|
("") # TODO include size
|
||||||
arg=$(lsblk --list --noheadings --output name,label,fstype,mountpoint |
|
arg=$(
|
||||||
grep -v '/' | grep ".\+ [^ ]\+" | fzf --select-1 --exit-0 |
|
{ #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/");;
|
sed "s/^\([^ ]\+ \+\)\?\([^ ]\+\) \+[^ ]\+ *$/\2/");;
|
||||||
(--help) echo "$_help" && exit 0;;
|
(--help) echo "$_help" && exit 0;;
|
||||||
(-u) shift
|
(-u) shift
|
||||||
|
|
Loading…
Reference in New Issue