2018-08-17 23:38:00 +02:00
|
|
|
alias vim="nvim"
|
|
|
|
|
|
2016-03-07 19:38:16 +01:00
|
|
|
### COMMON OPERATIONS
|
|
|
|
|
alias ll='ls -AlFh'
|
|
|
|
|
alias la='ls -A'
|
|
|
|
|
|
|
|
|
|
alias spm="sudo pacman"
|
|
|
|
|
|
|
|
|
|
alias tml="tmux list-sessions"
|
|
|
|
|
alias tma="tmux ls 2>/dev/null && tmux attach-session || tmux"
|
2017-01-23 17:04:08 +01:00
|
|
|
alias tmn="tmux new-session -A -s"
|
2016-03-07 19:38:16 +01:00
|
|
|
|
2018-08-12 14:31:14 +02:00
|
|
|
alias clipc="xclip -selection primary"
|
2016-03-07 19:38:16 +01:00
|
|
|
alias clipo="xclip -out -selection clipboard"
|
|
|
|
|
|
|
|
|
|
alias rgrep="grep -r"
|
|
|
|
|
|
|
|
|
|
alias vimrc="vim -c ':e \$MYVIMRC'"
|
|
|
|
|
alias zshrc="vim -c ':e ~/.zshrc' ; source ~/.zshrc"
|
|
|
|
|
|
|
|
|
|
alias calc='python3 -ic "from math import *; import cmath"'
|
|
|
|
|
|
|
|
|
|
alias le_haxxor_1='clear && dmesg | pv -qL 20'
|
|
|
|
|
alias le_haxxor_2='clear && hexdump -C /dev/urandom | pv -qlL 2'
|
|
|
|
|
|
|
|
|
|
alias root='sudo -sE'
|
|
|
|
|
|
|
|
|
|
### USEFUL DEFAULT OPTIONS
|
|
|
|
|
alias tmux="tmux -2"
|
|
|
|
|
|
|
|
|
|
alias chmod="chmod -c"
|
|
|
|
|
alias chown="chown -c"
|
|
|
|
|
|
|
|
|
|
alias ls="ls --group-directories-first --classify --color=auto"
|
|
|
|
|
|
2020-10-05 22:05:25 +02:00
|
|
|
alias diff="diff --color=auto"
|
|
|
|
|
|
2016-03-07 19:38:16 +01:00
|
|
|
alias grep='grep --color=auto'
|
|
|
|
|
alias fgrep='fgrep --color=auto'
|
|
|
|
|
alias egrep='egrep --color=auto'
|
|
|
|
|
|
|
|
|
|
alias rm='rm -v'
|
|
|
|
|
alias cp='cp -vi'
|
|
|
|
|
alias mv='mv -vi'
|
|
|
|
|
alias ln='ln -v'
|
|
|
|
|
|
|
|
|
|
alias du='du -h'
|
|
|
|
|
alias df='df -h'
|
|
|
|
|
|
|
|
|
|
### SHORTENING COMMAND NAMES
|
|
|
|
|
alias cs="cryptsetup"
|
|
|
|
|
alias v="vim"
|
|
|
|
|
alias g="git"
|
|
|
|
|
alias c="cd"
|
|
|
|
|
alias l="ls"
|
|
|
|
|
alias s="sudo"
|
|
|
|
|
alias cl="clear"
|
2016-03-13 15:32:57 +01:00
|
|
|
|
|
|
|
|
alias nocolor="sed -r \"s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g\""
|
2017-08-09 21:51:54 +02:00
|
|
|
|
|
|
|
|
alias ip="ip -color"
|
2017-09-09 13:55:49 +02:00
|
|
|
|
|
|
|
|
alias vimtask="vim -c :TW"
|
2017-10-10 20:16:46 +02:00
|
|
|
|
|
|
|
|
alias tw="task"
|
|
|
|
|
alias twl="task list"
|
|
|
|
|
alias twa="task add"
|
|
|
|
|
alias twd="task done"
|
2018-02-03 23:03:25 +01:00
|
|
|
alias inbox="task add +inbox"
|
2018-01-29 13:15:50 +01:00
|
|
|
|
2021-02-09 20:56:34 +01:00
|
|
|
alias yaml2json="python -c 'import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout, indent=4)'"
|
2019-12-18 10:10:40 +01:00
|
|
|
alias json2yaml="python -c 'import sys, yaml, json; yaml.safe_dump(json.loads(sys.stdin.read()), stream=sys.stdout)'"
|
2018-01-29 12:42:35 +01:00
|
|
|
|
|
|
|
|
alias currentbranch='git rev-parse --abbrev-ref HEAD'
|
2018-08-12 14:31:14 +02:00
|
|
|
|
|
|
|
|
alias pass=mypass
|
|
|
|
|
|
|
|
|
|
alias issh="ssh -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null"
|
2018-08-10 17:23:37 +02:00
|
|
|
alias gfix='git commit --amend --no-edit'
|
|
|
|
|
alias gfixa='git commit --amend --no-edit --all '
|
|
|
|
|
alias gfixp='git commit --amend --no-edit --patch'
|
|
|
|
|
|
|
|
|
|
alias issh="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
|
|
|
|
|
|
|
|
|
alias newpw="pwgen --secure 25 1"
|
|
|
|
|
|
2018-12-28 18:19:00 +01:00
|
|
|
alias sys="systemctl"
|
|
|
|
|
alias sysu="systemctl --user"
|
|
|
|
|
|
2019-04-14 11:54:29 +02:00
|
|
|
alias gpg=gpg2
|
|
|
|
|
|
2018-08-10 17:23:37 +02:00
|
|
|
gitmaster() {
|
|
|
|
|
git stash push -m gitmaster-$(date -uIseconds) -u || return 1
|
|
|
|
|
_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
|
git fe || return 1
|
|
|
|
|
git checkout master || return 1
|
|
|
|
|
git merge origin/master || return 1
|
|
|
|
|
git checkout $_branch
|
|
|
|
|
git stash pop
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_remote() {
|
|
|
|
|
[[ -n "$SSH_CONNECTION" ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cd() {
|
|
|
|
|
builtin cd "$@" && ls
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mount() {
|
|
|
|
|
if [[ $# == 0 ]] ; then
|
|
|
|
|
command mount | column -t
|
|
|
|
|
else
|
|
|
|
|
command mount "$@"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extr()
|
|
|
|
|
{
|
|
|
|
|
if [[ -f "$1" ]] ; then
|
|
|
|
|
case "$1" in
|
|
|
|
|
*.tar.bz2 ) tar xvjf "$1" ;;
|
|
|
|
|
*.tar.gz ) tar xvzf "$1" ;;
|
|
|
|
|
*.tar.xz ) tar xvJf "$1" ;;
|
|
|
|
|
*.bz2 ) bunzip2 "$1" ;;
|
|
|
|
|
*.rar ) unrar x "$1" ;;
|
|
|
|
|
*.gz ) gunzip "$1" ;;
|
|
|
|
|
*.tar ) tar xvf "$1" ;;
|
|
|
|
|
*.tbz2 ) tar xvjf "$1" ;;
|
|
|
|
|
*.tgz ) tar xvzf "$1" ;;
|
|
|
|
|
*.zip ) unzip "$1" ;;
|
|
|
|
|
*.Z ) uncompress "$1" ;;
|
|
|
|
|
*.7z ) 7z x "$1" ;;
|
|
|
|
|
*)
|
|
|
|
|
echo "$1 cannot be extracted via $0"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
else
|
|
|
|
|
echo "$1 is not a valid file"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ruler() {
|
|
|
|
|
for s in '....^....|' '1234567890'; do
|
|
|
|
|
w=${#s}
|
|
|
|
|
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
|
|
|
|
|
str=$(echo $str | cut -c -$COLUMNS)
|
|
|
|
|
echo $str
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addext() {
|
|
|
|
|
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
|
|
|
|
|
mv "$1" "$1$2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rmext() {
|
|
|
|
|
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ckwww() {
|
|
|
|
|
ping -c 3 www.google.com
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
httpcode() {
|
|
|
|
|
curl http://httpcode.info/$1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bak() {
|
|
|
|
|
if ! [[ "$1" ]] ; then
|
|
|
|
|
printf '%s\n' "usage: $0 FILE"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
if ! [[ -e "$1" ]] ; then
|
|
|
|
|
printf '%s\n' "\"$1\" not found"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
name="$1.$(date +%Y%m%d%H%M%S.bak)"
|
|
|
|
|
if [[ -e "${name}" ]] ; then
|
|
|
|
|
printf '%s\n' "Backup file \"$name\" already exists"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
cp --archive --verbose --no-clobber "$1" "${name}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fstab() {
|
|
|
|
|
# yeah
|
|
|
|
|
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serve() {
|
|
|
|
|
python3 -m http.server 8800
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
manpdf() {
|
|
|
|
|
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
|
|
|
|
|
man -t "$1" | ps2pdf - - | zathura -
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myip4() {
|
|
|
|
|
curl "http://ipv4.icanhazip.com"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myip6() {
|
|
|
|
|
curl "http://ipv6.icanhazip.com" 2>/dev/null || echo "no ip6"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diffdir() {
|
|
|
|
|
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
|
|
|
|
|
diff <(cd "$1" && find -type f -exec md5sum {} \;) <(cd "$2" && find -type f -exec md5sum {} \;)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diffdir2() {
|
|
|
|
|
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
|
|
|
|
|
comm -13 <(cd "$1" && find -type f | sort -g) <(cd "$2" && find -type f | sort -g)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bm() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
dev)
|
|
|
|
|
cd "$HOME/development/projects"
|
|
|
|
|
;;
|
|
|
|
|
dot)
|
|
|
|
|
cd "$HOME/dotfiles"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "unknown target"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
man() {
|
|
|
|
|
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
|
|
|
|
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
|
|
|
|
LESS_TERMCAP_me=$'\E[0m' \
|
|
|
|
|
LESS_TERMCAP_se=$'\E[0m' \
|
|
|
|
|
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
|
|
|
|
LESS_TERMCAP_ue=$'\E[0m' \
|
|
|
|
|
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
|
|
|
|
man "$@"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolvecd() {
|
|
|
|
|
cd "$(readlink -f $(pwd))"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssht () {
|
|
|
|
|
ssh -t $@ "tmux a || tmux";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t() {
|
|
|
|
|
if [[ "$1" ]] ; then
|
|
|
|
|
tmux new-session -A -s "$1"
|
|
|
|
|
else
|
|
|
|
|
tmux attach-session
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b() {
|
|
|
|
|
bookmarks=${DOTFILES}/bookmarks
|
|
|
|
|
bookmark="$1"
|
|
|
|
|
if ! [[ "${bookmark}" ]] ; then
|
|
|
|
|
printf 'Need a bookmark' >&2
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
if ! [[ -r "${bookmark}" ]] ; then
|
|
|
|
|
printf 'Invalid bookmark %s' "${bookmark}" >&2
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
target="$(head -1 ${bookmark})"
|
|
|
|
|
if ! [[ -e "${target}" ]] ; then
|
|
|
|
|
printf 'Traget not found: %s' "${target}" >&2
|
|
|
|
|
fi
|
|
|
|
|
cd "$(eval ${target})"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb() {
|
|
|
|
|
echo $(( $1 * $(cat /sys/class/backlight/intel_backlight/max_brightness) / 100)) | sudo tee /sys/class/backlight/intel_backlight/brightness
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clip() {
|
|
|
|
|
tee >(xclip -selection clipboard) | tee >(xclip -selection primary)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gb() {
|
2018-10-17 11:02:17 +02:00
|
|
|
_superproject="$(git rev-parse --show-superproject-working-tree)"
|
2020-12-08 22:04:06 +01:00
|
|
|
_root="$(git rev-parse --show-toplevel)"
|
2018-10-17 11:02:17 +02:00
|
|
|
if [[ -n "${_superproject}" ]] ; then
|
2020-12-08 22:04:06 +01:00
|
|
|
if [[ "$(pwd)" == "${_root}" ]] ; then
|
|
|
|
|
builtin cd "${_superproject}"
|
|
|
|
|
else
|
|
|
|
|
builtin cd "${_root}"
|
|
|
|
|
fi
|
2018-10-17 11:02:17 +02:00
|
|
|
else
|
2020-12-08 22:04:06 +01:00
|
|
|
builtin cd "${_root}"
|
2018-10-17 11:02:17 +02:00
|
|
|
fi
|
2018-08-10 17:23:37 +02:00
|
|
|
}
|
2019-07-04 14:36:45 +02:00
|
|
|
|
|
|
|
|
meetingnotes() {
|
|
|
|
|
[[ "${1}" ]] || return 1
|
|
|
|
|
file="$(date +%Y-%m-%d)-${1}.md"
|
|
|
|
|
cp ~/snippets/meetingnotes.md "${file}"
|
|
|
|
|
$EDITOR "${file}"
|
|
|
|
|
}
|