home/.profile

106 lines
3.4 KiB
Bash
Executable File

#!/bin/sh
# Copyright (c) 2017 rehashedsalt/vintagesalt
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# POSIX NOTICE
# This script should be fully POSIX-compliant
# If it is not, open a bug report at github.com/rehashedsalt/home and I'll take
# care of it
# If emerge exists, add emerge aliases
if `which emerge > /dev/null 2>&1` ; then
alias e-depclean='sudo emerge -a --depclean'
alias e-inst='sudo emerge -a --jobs --tree --quiet-build y'
alias e-upgrade='sudo emerge -DNUua --jobs --tree --quiet-build y --with-bdeps=y --keep-going --backtrack=1000 @world'
alias e-newuse='sudo emerge -Uva --jobs --tree --quiet-build y @world'
alias e-search='emerge -s'
alias e-sync='sudo emerge --sync'
alias e-cleanup='sudo eclean -d distfiles && sudo eclean -d packages'
fi
# Alias for the dotfile setup
if [ -d "$HOME/.dotfiles" ]; then
alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
fi
# Aliases for common utilities
alias cp='cp -i'
alias todo='$EDITOR "$HOME/Documents/todo"'
if [ "`uname`" = "Linux" ]; then
lsarguments='--color=auto --group-directories-first'
alias l="ls -CF --file-type $lsarguments"
alias la="ls -AF --file-type $lsarguments"
alias ls="ls -F $lsarguments"
alias ll="ls -AhlF --file-type $lsarguments"
unset lsarguments
else
lsarguments='-F'
alias l="ls -$lsarguments"
alias la="ls -A $lsarguments"
alias ls="ls $lsarguments"
alias ll="ls -Ahl $lsarguments"
fi
alias waitwhat='echo $?'
# urxvt isn't a very well-known terminal
if [ "$TERM" = "rxvt-unicode-256color" ]; then
export TERM=xterm-256color
fi
# Set up a default PS1
# This *should* work for all terminals. I know it works on ksh
_ps1() {
exitcode="$?"
r="\e[0m"
fg_blue="\e[34m"
fg_red="\e[31m"
fg_green="\e[32m"
fg_bold="\e[1m"
hostname_prefix="${fg_blue}"
# Change PWD color in SSH sessions
if [ "$SSH_CLIENT" ]; then
# Also add the machine's hostname
hostname_prefix="${fg_bold}${fg_red}`hostname`${r}${fg_red}:"
fi
# Show the tilde instead of $HOME
cpwd="${PWD/#$HOME/\~}"
# Alert us if the last command failed
fail=""
if ! [ "$exitcode" = "0" ]; then
fail="${fg_bold}${fg_red}?"
fi
printf "[${hostname_prefix}${cpwd}${r}]${fail}${r}${fg_green}\$${r} "
}
if ! [ "$ZSH_NAME" ]; then
# I've got a different ZSH theme
export PS1='`_ps1`'
fi
# Minor configuration settings
export EDITOR=`which vim`
export PATH=$PATH:$HOME/.local/bin
export XDG_CONFIG_HOME="$HOME/.config"