useful functions for .bashrc/.zshrc

ssh domain.name will open tmux terminal on the remote side or reconnect to the old one.
Also it reconnects when get issue with connection.

1
2
3
4
5
6
7
8
9
10
11
12
function ssh () {
    if ! command -v autossh &> /dev/null; then echo "Install autossh"; fi
    AUTOSSH_POLL=20
    export AUTOSSH_POLL
    if [ $# -eq 1 ]; then
        autossh -M 0 $@ -t "tmux attach -t alter || tmux new -s alter";
    elif [ $# -gt 1 ]; then
        /usr/bin/ssh -A $@
    else
        /usr/bin/ssh -h
    fi
}

Insert to pastebin service your message:
$ echo 'test1' | pb
https://pb.idone.su/view/8f60b2b5
$ curl https://pb.idone.su/view/raw/8f60b2b5
test1

$ pb «test2»
https://pb.idone.su/view/32974896
$ curl https://pb.idone.su/view/raw/32974896
test2

1
2
3
4
5
6
7
8
function pb(){
    if [ -n "$1" ]; then
        echo "$1" | curl -d expire=1440 -d private=1 --data-urlencode text@- https://pb.idone.su/index.php/api/create
    else
        stdin="$(cat)"
        echo "$stdin" | curl -d expire=1440 -d private=1 --data-urlencode text@- https://pb.idone.su/index.php/api/create
    fi
}