config/shell: update aliases

This commit is contained in:
xerus2000 2020-11-16 12:29:31 +01:00
parent 0bb8e67c7d
commit 4f75e71ff7
3 changed files with 43 additions and 18 deletions

View File

@ -13,6 +13,13 @@ 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 -delete || rm "$@"
}
rr() { mv "$@" /tmp }
alias logoff="loginctl terminate-user $USER"
# Some aliases
alias editgrub='sudoedit /etc/default/grub && sudo update-grub'
@ -20,7 +27,10 @@ alias editenv='sudoedit /etc/environment'
editright() {
test ! -f "$1" && ( mkdir -p $(dirname "$1") || sudo mkdir -p $(dirname "$1") )
echo "Editing $1..."
(test -w "$1" || (test ! -f "$1" && test -w $(dirname "$1"))) && $EDITOR "$1" || sudoedit "$1"
if test -w "$1" || (test ! -f "$1" && test -w $(dirname "$1"))
then $EDITOR "$1"
else sudoedit "$1"
fi
}
# Underline arg
@ -89,7 +99,6 @@ alias twtest='( TIMEWARRIORDB=/tmp/timewarriordb && mv ${TIMEWARRIORDB} /tmp/twd
# Quick shortcuts
alias c='clear'
alias v='editright'
alias rm='rm -d'
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
alias lar='last | tac'

View File

@ -1,18 +1,10 @@
#!/bin/sh
# Show type & contents of given files or PWD
#if test $# -gt 1
#then
# for arg in "$@"; do
# b --pager=never "$arg"
# done
#else
arg=$(test $# -gt 0 && echo "${@:-1}" || echo .)
file $arg | grep -v --color=never directory
case "$(file --dereference --mime $arg)" in
*inode/directory*) ls -l --color=auto --almost-all --human-readable --group-directories-first --file-type --dereference-command-line "$@";;
*binary) ;;
*) bat --style header "$@";;
esac
#fi
for last; do true; done
last=${last:-.}
file "$last" | grep -v --color=never directory
case "$(file --dereference --mime "$last")" in
*inode/directory*) ls -l --color=auto --human-readable --group-directories-first --file-type --dereference-command-line --all --reverse "$@";;
*binary) ;;
*) bat --style header "$@";;
esac

24
.local/bin/ex Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
# ex - archive extractor
# usage: ex <file>
if test -f $1 && test -r $1; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*.deb) ar x $1 ;;
*.tar.xz) tar xf $1 ;;
*.tar.zst) unzstd $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a readable file"
fi