guest@dotshare [~/groups/shells/bash] $ ls more-infos/ | cat

more infos (scrot, raw, dl)

txgvnn Nov 04, 2018 (shells/bash)

SCROT

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# https://github.com/txgvnn/dots/

color='32'
if [ "$(id -u)" -eq 0 ]; then
    color='31'
fi
if ! declare -f "__git_ps1" >/dev/null; then
    function __git_ps1(){ echo "";}
fi
export GIT_PS1_SHOWDIRTYSTATE=true
PS1="\n\[\e[0;${color}m\]\342\224\214\[\e[1;30m\](\[\e[0;${color}m\]\u\[\e[0;35m\]@\h\[\e[1;30m\])\$(if [[ \$? == 0 ]]; then echo \"\[\e[6;32m\]\342\224\200\"; else echo \"\[\e[6;31m\]\342\224\200\"; fi)\[\e[0m\]\[\e[1;30m\](\[\e[0;34m\]\w\[\e[1;30m\])\342\224\200(\[\e[0;33m\]\t\[\e[1;30m\]\[\e[1;30m\])\$(__git_ps1)\n\[\e[0;${color}m\]\342\224\224>\[\e[0m\]"

function cdtmp(){
    cd "$(mktemp -d -t ${USER}_$(date +%F@%R).XXX)" || exit 1
}
function lstmp(){
    ls /tmp/"$USER"*
}

function cdenv(){
    if [ -z "$1" ]; then
        cd || exit 1
    else
        cd "$1"
    fi

    # .bin #TxGVNN
    if [ -e .bin ]; then
        if [[ $PATH != *"$(pwd)/.bin"* ]]; then
            PS1="\342\224\200\[\e[1;30m\](\[\e[0;35m\].bin\[\e[1;30m\])\[\e[0m\]"$PS1
            export PATH=$(pwd)/.bin:$PATH
        fi
        if [ -e .bin/env ]; then
            . .bin/env
        fi
    fi

    # virtualenv
    if [ -e bin ]; then
        if [[ $PATH != *"$(pwd)/bin"* ]]; then
            PS1="\342\224\200\[\e[1;30m\](\[\e[0;35m\]bin\[\e[1;30m\])\[\e[0m\]"$PS1
            #export PATH=$(pwd)/bin:$PATH
        fi
        if [ -e bin/activate ]; then
            . bin/activate
        fi
    fi
    # docker compose
    if [ -e docker-compose.yml ]; then
        if [[ $PS1 != *"d-compose"* ]]; then
            PS1="\342\224\200\[\e[1;30m\](\[\e[0;35m\]d-compose\[\e[1;30m\])\[\e[0m\]"$PS1
        fi
    else
        PS1=$(echo $PS1 | sed 's/\\342\\224\\200\\\[\\e\[1;30m\\\](\\\[\\e\[0;35m\\\]d-compose\\\[\\e\[1;30m\\\])//g')
    fi
    # vagrant
    if [ -e Vagrantfile ]; then
        if [[ $PS1 != *"vagrant"* ]]; then
            PS1="\342\224\200\[\e[1;30m\](\[\e[0;35m\]vagrant\[\e[1;30m\])\[\e[0m\]"$PS1
        fi
    else
        PS1=$(echo $PS1 | sed 's/\\342\\224\\200\\\[\\e\[1;30m\\\](\\\[\\e\[0;35m\\\]vagrant\\\[\\e\[1;30m\\\])//g')
    fi
}

# SSH and screen
function sshscreen(){
    ssh "$@" -v -t 'if screen -ls | grep gtx -q ; then screen -x gtx ;else screen -S gtx ;fi'
}

# SSH and screen
function sshtmux(){
    ssh "$@" -v -t 'if tmux ls | grep gtx -q ; then tmux at -t gtx ;else tmux new -s gtx ;fi'
}


# Alias
alias cd="cdenv"
alias em="emacs -nw"
# Export
export HISTTIMEFORMAT="%F %T "
## Check pseudoterminal or not?
export TERM=xterm-256color
if [[ $(tty) != */dev/pts/* ]]; then
    export TERM=linux
fi

CLICK TO VIEW

x