aboutsummaryrefslogtreecommitdiff
path: root/profile.dot.link
blob: aa06c2b9acff1297334564771946324dd35ccbd1 (plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#
# .profile: basic environment setup
#

# Set language
export LANG=pt_BR.UTF-8

# Source functions and variables from other places
if [ -e "$HOME/.aliases" ]; then
  . $HOME/.aliases
fi

# Funcoes ZZ
#if [ -e "/usr/bin/funcoeszz" ]; then
#  . /usr/bin/funcoeszz
#fi

# Set PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/games:/usr/local/bin:/usr/local/sbin:/usr/local/games

# Add ~/bin folder into PATH
if [ -d "$HOME/bin" ]; then
  PATH=$HOME/bin:$PATH
fi

# Add all ~/apps folders into PATH
if [ -d "$HOME/apps" ]; then
  PATH=$HOME/apps:$PATH

  for folder in `ls $HOME/apps`; do
    PATH=$HOME/apps/$folder:$PATH
  done
fi

# Export PATH
export PATH=$PATH

# Where most projects live
# Use $HOME instead of ~ for zsh compatibility
export WORKPATH="$HOME/file:$HOME/data:$HOME/code:$HOME/apps:$HOME/.dotfiles:$HOME/.dotfiles/modules"

# See http://www.caliban.org/bash/#bashtips
export CDPATH=".:~:$WORKPATH"

# Expand workpath
#for folder in `echo $WORKPATH | sed -e "s|:| |g" -e "s|~|$HOME|g"`; do
#  PROJECTS="$PROJECTS`ls -d $folder/*`"
#done

# Based on http://superuser.com/questions/90535/how-do-i-turn-of-auto-echo-in-bash-when-i-cd
if [ "$0" = "bash" ]; then
  cd() {
    if [ -z "$*" ]; then
      destination=~
    else
      destination=$*
    fi

    # Check if its a project under CPATH
    cdpath=`command cd "${destination}" 2> /dev/null`

    # Got to folder
    command cd "${destination}" > /dev/null

    # Update screen title
    #
    # Doesn't deal about getting out of a project path
    # or if going into a project subfolder
    #
    #if [ ! -z "$cdpath" ] && [ ! -z "$STY" ]; then
    #  folder="`basename $cdpath`"
    #
    #  if echo "$PROJECTS" | grep -q "/$folder$"; then
    #    # Got inside a project folder
    #    stitle `basename $folder`
    #  fi
    #fi
  }
fi

# Special cd: change folder and set title
scd() {
  cd "$*"
  stitle `basename $*` > /dev/null 2>&1
  xtitle `basename $*` > /dev/null 2>&1
}

mkday() {
  mkdir `today` && cd `today`
}

mkmonth() {
  mkdir `month` && cd `month`
}

mkcd() {
  mkdir "$*" && cd "$*"
}

# Default editor
#if [ ! -z "$DISPLAY" ]; then
#  # Avoid "Avoiding protocol specified" error
#  export EDITOR="vim -X"
#else
#  export EDITOR="vim"
#fi
export EDITOR="vim"

# Basic git configuration
# See http://stackoverflow.com/questions/4192014/git-ps1-extremely-slow-in-kernel-tree
export GIT_PS1_SHOWDIRTYSTATE=""
export GIT_PS1_SHOWUNTRACKEDFILES=""

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ ! -z "$BASH" ]; then
  if ! shopt -oq posix; then
    if [ -f /usr/share/bash-completion/bash_completion ]; then
      . /usr/share/bash-completion/bash_completion
    elif [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
    fi
  fi
fi

# Load git completion if needed
#if [ ! -z "$BASH" ]; then
#  if ! type __git_ps1 2> /dev/null | head -1 | grep -q function; then
#    if [ -e "/etc/bash_completion.d/git-prompt" ]; then
#      . /etc/bash_completion.d/git-prompt
#    elif [ -e "/etc/bash_completion.d/git" ]; then
#      . /etc/bash_completion.d/git
#    fi
#  fi
#fi

# Less configuration
# See http://seclists.org/fulldisclosure/2014/Nov/74
export LESSSECURE="1"
export LESSOPEN=""
export LESSCLOSE=""

# Lynx configuration
export LYNX_LSS="$HOME/.lynx/lynx.lss"
export LYNX_CFG="$HOME/.lynx/lynx.cfg"

# Temporary folder
export TMPDIR="$HOME/temp/misc"
export TMP="$HOME/temp/misc"
export TMUX_TMPDIR="$HOME/temp/misc"
mkdir -p $TMP

# Dir colors
eval "`dircolors -b ~/.dircolorsrc`"

# SSH and GPG Agents
if [ -x '/usr/bin/keychain' ]; then
  mkdir -p $HOME/.keychain

  if [ -e "$HOME/.ssh/id_rsa" ]; then
    /usr/bin/keychain -q $HOME/.ssh/id_rsa
  fi

  if [ -e "$HOME/.ssh/id_ed25519" ]; then
    /usr/bin/keychain -q $HOME/.ssh/id_ed25519
  fi

  if [ -e "$HOME/.keychain/$HOSTNAME-sh" ]; then
    . $HOME/.keychain/$HOSTNAME-sh
  fi

  if [ -e "$HOME/.keychain/$HOSTNAME-sh-gpg" ]; then
    . $HOME/.keychain/$HOSTNAME-sh-gpg
  fi
fi

#if [ -e "$HOME/apps/scripts/ssh-agent-eval" ]; then
#  $HOME/apps/scripts/ssh-agent-eval
#fi

# GPG Agent
#if [ -e "$HOME/apps/scripts/gpg-agent-eval" ]; then
#  $HOME/apps/scripts/gpg-agent-eval
#fi

# Remove lost found folder if empty
if [ -d "$HOME/lost+found" ]; then
  rmdir $HOME/lost+found &> /dev/null
fi

# Make sure basic folder structure exists
mkdir -p $HOME/apps $HOME/file $HOME/mail $HOME/temp/public

# Make sure data symlink exists
if [ -e "/var/data" ] && [ ! -e "$HOME/data" ]; then
  ln -s /var/data $HOME/data
fi

# Make sure code symlink exists
if [ -e "/var/data/code" ] && [ ! -e "$HOME/code" ]; then
  ln -s /var/data/code $HOME/code
fi

# Make sure download symlink exists
if [ -e "/var/data/load" ] && [ ! -e "$HOME/load" ]; then
  ln -s /var/data/load $HOME/load
fi

# Custom configuration
if [ -e "$HOME/.custom/profile" ]; then
  . $HOME/.custom/profile
fi

# Python
if [ -e "$HOME/apps/python" ]; then
  export PYTHONPATH="$HOME/apps/python"

  if [ -e "$HOME/apps/python/venv/bin/activate" ]; then
    source $HOME/apps/python/venv/bin/activate
  fi
fi

# Bash specifics
#if [ -n "$BASH_VERSION" ]; then
if [ "$0" = "bash" ]; then
  # Command prompt if no system-wide custom prompt is available
  if [ "$TERM" != "linux" ] && [ -e "/usr/share/powerline/bindings/bash/powerline.sh" ]; then
    powerline-daemon -q
    POWERLINE_BASH_CONTINUATION=1
    POWERLINE_BASH_SELECT=1
    . /usr/share/powerline/bindings/bash/powerline.sh
  elif ! type command_prompt &> /dev/null && [ -e "$HOME/apps/shellprompt/prompt" ]; then
    . $HOME/apps/shellprompt/prompt
  fi
fi

# Avoid Enter SOCKS5 password for user@127.0.0.1 when using ssh+tor
export SOCKS5_PASSWORD=""

# Make sure we start at home
cd