# # .profile: basic environment setup # # Set language export LC_ALL=pt_BR.UTF-8 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 snap into PATH if [ -d "/snap/bin" ]; then PATH="/snap/bin:$PATH" fi # Add ~/.local/bin folder into PATH if [ -d "$HOME/.local/bin" ]; then PATH=$HOME/.local/bin:$PATH fi # 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 # Add all ~/apps/local folders into PATH if [ -d "$HOME/apps/local" ]; then for folder in `ls $HOME/apps/local`; do PATH=$HOME/apps/local/$folder:$PATH done fi # PATH for stowpkg if [ -d "$HOME/apps/stowpkg/tree/`uname -m`/bin" ]; then PATH="$HOME/apps/stowpkg/tree/`uname -m`/bin:$PATH" fi # Add /vagrant into PATH, useful if we're inside a virtual machine if [ -d "/vagrant/bin" ]; then PATH="/vagrant/bin:/vagrant:$PATH" fi # Add /srv/kvmx into PATH, useful if we're inside a virtual machine if [ -d "/srv/kvmx/bin" ]; then PATH="/srv/kvmx/bin:/srv/kvmx:$PATH" fi # Add /srv/shared into PATH, useful if we're inside a virtual machine if [ -d "/srv/shared/bin" ]; then PATH="/srv/shared/bin:/srv/shared:$PATH" fi # Add composer into PATH if [ -d "$HOME/.composer/vendor/bin" ]; then PATH="$HOME/.composer/vendor/bin:$PATH" fi # Add Go into PATH if [ -e "/usr/lib/go" ]; then export GOROOT="/usr/lib/go" PATH=$PATH:$GOROOT/bin fi # Add local Go into PATH if [ -e "$HOME/apps/go" ]; then export GOPATH="$HOME/apps/go" PATH=$PATH:$GOPATH/bin 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" export WORKPATH="$HOME/file:$HOME/data:$HOME/code:$HOME/apps:$HOME/apps/dotfiles/modules" # See http://www.caliban.org/bash/#bashtips export CDPATH=".:$HOME:$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 ttitle `basename $*` > /dev/null 2>&1 } mkday() { suffix="$1" folder="`today`" if [ ! -z "$suffix" ]; then folder="$folder-$suffix" fi mkdir $folder && cd $folder } mkmonth() { suffix="$1" folder="`month`" if [ ! -z "$suffix" ]; then folder="$folder-$suffix" fi mkdir $folder && cd $folder } mkcd() { mkdir "$*" && cd "$*" } mktouch() { mkdir -p `dirname "$*"` touch "$*" } # 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" # This might cause issues when trying to attach to remote tmux sessions #export TMUX_TMPDIR="$TMP/misc" mkdir -p $TMP # Log folder export LOG="$HOME/temp/log" mkdir -p $LOG # Dir colors eval "`dircolors -b ~/.dircolorsrc`" # SSH and GPG Agents if [ -x "$HOME/apps/utils-ssh/ssh-agent-loadkeys" ]; then . $HOME/apps/utils-ssh/ssh-agent-loadkeys fi #if [ -e "$HOME/apps/utils-ssh/ssh-agent-eval" ]; then # $HOME/apps/utils-ssh/ssh-agent-eval #fi # GPG Agent #if [ -e "$HOME/apps/utils-gpg/gpg-agent-eval" ]; then # $HOME/apps/utils-gpg/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/sync $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 elif [ ! -e "$HOME/load" ]; then mkdir -p $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 # Start the powerline daemon # See http://powerline.readthedocs.io/en/master/usage/shell-prompts.html if [ -x "/usr/bin/powerline-daemon" ]; then /usr/bin/powerline-daemon -q 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="" # Detect if we're inside a vagrant VM if [ -z "$STARTUP_FOLDER" ] && [ -d "/vagrant" ]; then STARTUP_FOLDER="/vagrant" fi # Detect if we're inside a kvmx VM, old convention if [ -z "$STARTUP_FOLDER" ] && [ -f "/srv/kvmx/kvmxfile" ]; then STARTUP_FOLDER="/srv/kvmx" fi # Detect if we're inside a kvmx VM if [ -z "$STARTUP_FOLDER" ] && [ -f "/srv/shared/kvmxfile" ]; then STARTUP_FOLDER="/srv/shared" fi # Make sure we start at the startup folder, defaulting to home cd $STARTUP_FOLDER # Run startup commands #if [ ! -z "$STARTUP" ]; then # $STARTUP #fi # Run startup scripts #if [ -d "$HOME/.custom/profile.d" ]; # run-parts $HOME/.custom/profile.d #fi