# # .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`" ]; then if [ -d "$HOME/apps/stowpkg/tree/`uname -m`/bin" ]; then PATH="$HOME/apps/stowpkg/tree/`uname -m`/bin:$PATH" fi if [ -d "$HOME/apps/stowpkg/tree/`uname -m`/usr/bin" ]; then PATH="$HOME/apps/stowpkg/tree/`uname -m`/usr/bin:$PATH" fi if [ -d "$HOME/apps/stowpkg/tree/`uname -m`/usr/local/bin" ]; then PATH="$HOME/apps/stowpkg/tree/`uname -m`/usr/local/bin:$PATH" fi 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="$GOROOT/bin:$PATH" fi # Add local Go into PATH if [ -e "$HOME/apps/go" ]; then export GOPATH="$HOME/apps/go" PATH="$GOPATH/bin:$PATH" fi # Add local gems into PATH if which gem > /dev/null 2>&1; then LOCAL_GEMPATH="`gem environment gempath | cut -d : -f 1`/bin" if [ -d "$LOCAL_GEMPATH" ]; then PATH="$LOCAL_GEMPATH:$PATH" fi fi # Add local NixOS into PATH if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh fi # Add XBPS into PATH if [ -d "$HOME/.xbps/usr/bin" ]; then PATH="$HOME/.xbps/usr/bin:$PATH" fi # Add Node Version Manager into PATH # https://www.npmjs.com/package/nhttps://www.npmjs.com/package/n export N_PREFIX="$HOME/.n" if [ -d "$HOME/.n/bin" ]; then PATH="$HOME/.n/bin:$PATH" fi # NVM # https://github.com/nvm-sh/nvm export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm # Rust if [ -e "$HOME/.cargo/env" ]; then . $HOME/.cargo/env 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" # Expand workpath #for folder in `echo $WORKPATH | sed -e "s|:| |g" -e "s|~|$HOME|g"`; do # PROJECTS="$PROJECTS`ls -d $folder/*`" #done # Default editor #if [ ! -z "$DISPLAY" ]; then # # Avoid "Avoiding protocol specified" error # export EDITOR="vim -X" #else # export EDITOR="vim" #fi export EDITOR="vim" # CDPATH configuration # See http://www.caliban.org/bash/#bashtips # # The following CDPATH behavior might trigger unexpected behaviors in some # programs. See example at https://github.com/alecmuffett/eotk/pull/113 # Recommendation is that programs do their own fix (as nothing guarantees # the CDPATH won't be set). if [ "$SETCDPATH" != "false" ]; then if [ -z "$CDPATH" ]; then export CDPATH=".:$HOME:$WORKPATH" else export CDPATH=".:$HOME:$WORKPATH:$CDPATH" fi fi # Buil-in "cd" command replacement avoiding echoing the CDPATH # Based on http://superuser.com/questions/90535/how-do-i-turn-of-auto-echo-in-bash-when-i-cd # But please note that this workaround will not work for invoked programs (see comment above). 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 } mknow() { suffix="$1" folder="`now`" if [ ! -z "$suffix" ]; then folder="$folder-$suffix" fi mkdir $folder && cd $folder } 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 "$*" } mkedit() { mktouch "$*" $EDITOR "$*" } # 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 # Firejail configuration # This my hide important errors, so it's recommended to try running a # firejailed command with FIREJAIL_QUIET=no to debug. export FIREJAIL_QUIET="yes" # 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 # Set the proper GnuPG TTY when running on console # See https://stackoverflow.com/questions/51504367/gpg-agent-forwarding-inappropriate-ioctl-for-device#55032706 # https://superuser.com/questions/1649997/unable-to-decrypt-from-stdin-public-key-decryption-failed-inappropriate-ioctl if [ -z "$DISPLAY" ]; then export GPG_TTY=$(tty) 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 2>&1 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 # Include other profiles if [ -d "$HOME/.profile.d" ]; then for script in `ls $HOME/.profile.d`; do . $HOME/.profile.d/$script done fi # Include custom profiles if [ -d "$HOME/.custom/profile.d" ]; then for script in `ls $HOME/.custom/profile.d`; do . $HOME/.custom/profile.d/$script done fi # Run startup scripts #if [ -d "$HOME/.custom/rc.d" ]; then # run-parts $HOME/.custom/rc.d #fi # Run startup commands #if [ ! -z "$STARTUP" ]; then # $STARTUP #fi