From bffe2ce0a13e1b5f0cf1e3d086904cce74afecd4 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Wed, 23 Dec 2020 13:43:15 +0100 Subject: [PATCH] config/shell: update functions & add directory shortcuts --- .config/shell/functions | 24 ++++++++++++------------ .local/bin/moul | 4 ++++ .local/bin/mvk | 9 +++++++++ .local/bin/s | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) create mode 100755 .local/bin/moul create mode 100755 .local/bin/mvk diff --git a/.config/shell/functions b/.config/shell/functions index ed2ab9e..bddfb11 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -5,15 +5,21 @@ alias -g ___='"$(eval "$(fc -ln -1)" | tail -n 1)"' alias -g G="| grp" alias -g X="| xargs" alias -g X1="| xargs -n 1" -alias -g xdh="$XDG_DATA_HOME" -alias -g xch="$XDG_CONFIG_HOME" fi +alias info='info --vi-keys' + +xdh="$XDG_DATA_HOME" +xch="$XDG_CONFIG_HOME" +d1=$(cd $DATA/1* && pwd) +d2=$(cd $DATA/2* && pwd) +d3=$(cd $DATA/3* && pwd) +d4=$DATA/4* + ulimit -c unlimited # Enable core dumps which lsb_release >/dev/null && export DIST=$(lsb_release --id | cut -d' ' -f2) || true -alias info='info --vi-keys' unalias rd rd() { test -d "$1" && find "$1" -type d -empty -printf "Removing %p\n" -delete || rm "$@" @@ -65,7 +71,7 @@ edshell() { esac checksum="$(md5sum $file)" $EDITOR $file - test "$checksum" != "$(md5sum $file)" && source $HOME/.zprofile && exec $SHELL + test "$checksum" != "$(md5sum $file)" && source "$HOME/.zprofile" && exec $SHELL } edbin() { @@ -110,7 +116,7 @@ alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G' alias lar='last | tac' tr() { tree -a -L 2 --du -h -C "$@" | ${PAGER:-less} } -alias browse-safe='sudo systemctl disable --now systemd-resolved && sudo rm /etc/resolv.conf && sudo cp /etc/resolv.conf.bak /etc/resolv.conf && sudo chattr +i /etc/resolv.conf' +alias browse-safe='sudo systemctl disable --now systemd-resolved && sudo rm -f /etc/resolv.conf && echo "nameserver 185.228.168.10" | sudo tee /etc/resolv.conf && sudo chattr +i /etc/resolv.conf' alias browse-unsafe='sudo chattr -i /etc/resolv.conf && sudo mv /etc/resolv.conf /etc/resolv.conf.bak && sudo systemctl enable --now systemd-resolved' xo() { @@ -248,7 +254,7 @@ cl() { # FILES -alias f='noglob fd --no-ignore-vcs' +alias f='noglob fd --hidden --color=always --no-ignore-vcs' #alias f='find -not -path "*.sync*" -and -not \( -name daten -prune \)' #alias f1='find -mindepth 1 -maxdepth 1' @@ -268,12 +274,6 @@ mvf() { smv "$1" "$(dirname $1)/$2" } -# Creates directory $2 and moves $1 into it -mvk() { - mkdir -p $(case "$2" in (*/) echo "$2";; (*) dirname "$2";; esac) - mv "$1" "$2" -} - # Moves from $1 to $2 and replaces the original with a relative symlink mvln() { file=$(test -f "$1" && echo 1 || echo 0) diff --git a/.local/bin/moul b/.local/bin/moul new file mode 100755 index 0000000..2ab910c --- /dev/null +++ b/.local/bin/moul @@ -0,0 +1,4 @@ +#!/bin/sh +# Mount a partition by label automatically +sudo mkdir -p "${2:-/mnt/$1}" +sudo mount -L "$1" "${2:-/mnt/$1}" diff --git a/.local/bin/mvk b/.local/bin/mvk new file mode 100755 index 0000000..6d3bf73 --- /dev/null +++ b/.local/bin/mvk @@ -0,0 +1,9 @@ +#!/bin/sh +# Creates the last arg as directory and moves everything else into it + +for last; do true; done + +mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) +mv "$@" + + diff --git a/.local/bin/s b/.local/bin/s index 8f86c52..73e7e6b 100755 --- a/.local/bin/s +++ b/.local/bin/s @@ -1,5 +1,5 @@ #!/bin/sh # shows size statistics for subfolders # max depth is equal to the first argument if it is a number or 1 -case "$1" in [0-9]) local depth=$1; shift;; esac +case "$1" in [0-9]) depth=$1; shift;; esac sudo du --max-depth "${depth:-1}" -xhat 50M "$@" | sort -h | grep -v "^0"