export DOTFILES_PATH=$HOME/.dotfiles BASE16_SHELL="$DOTFILES_PATH/colors/shell" [[ -s "$BASE16_SHELL" ]] && source "$BASE16_SHELL" if [ -t 0 ]; then source "$DOTFILES_PATH/variables.bash" # disable ctrl-s terminal freeze [[ $- == *i* ]] && stty -ixon # filesystem aliases alias lx='ls -lXB' # order by filetype alias lk='ls -lSr' # order by filesize reversed alias lt='ls -ltr' # order by file modified time alias lc='ls -ltcr' # order by filectime alias lu='ls -ltur' # order by file access time alias ls='ls -h --color --group-directories-first' # flat view w/ directories first alias l='ls -h --color --group-directories-first' # same as above alias ll='ls -lv --group-directories-first' # non-flat view alias lm='ll | more' alias lr='ll -R' # please don't alias la='ll -A' # show all alias tree='tree -Csuh' # navigation aliases alias cd..="cd .." alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ......="cd ../../../../.." # tmux aliases alias tmux='TERM=screen-256color-bce tmux' # syntax higlighting for vim in tmux alias tmnew="tmux new -s" alias tmls="tmux list-sessions" alias tmatt="tmux attach -t" # git aliases alias gs="git status" alias gl="git log" alias gpl="git pull" alias gp="git push" alias gac="git add -A && git commit -m" # networking aliases alias p="ping 8.8.8.8" # emacs aliases alias emacs="emacs -nw" # arch aliases alias archupdate="pacaur -Syyu --noconfirm --noedit" # wm aliases alias startbar="source $DOTFILES_PATH/wm/extras/bar/start.bash" stopbar() { if [[ -f "$BAR_PID_FILE" ]]; then kill -SIGINT $(cat "$BAR_PID_FILE") rm -f "$BAR_PID_FILE" killall lemonbar else echo "Bar is not running." fi } export -f stopbar # misc aliases alias keyrepeat="xset r rate 250 80" export EDITOR="vim" if command -v nvim >/dev/null 2>&1; then alias vim="nvim" alias ovim="\\vim" export EDITOR="nvim" fi # prompt COLOR_RESET='\[\e[0m\]' PROMPT_SUCCESS_COLOR='\[\e[0;34m\]' PROMPT_FAILURE_COLOR='\[\e[0;31m\]' DIR_COLOR='\[\e[0;33m\]' # prompt rendering functions sps() { name="$PWD" [[ "$name" =~ ^"$HOME"(/|$) ]] && name="~${name#$HOME}" curdir=$(echo "$PWD" | sed -r 's|.*/(.+)$|\1|g') name=$(echo "$name" | sed -r 's|/(..)[^/]*|/\1|g' | sed -r 's|(.*/)(.+)$|\1|g') [[ "$name" == "~" ]] && curdir="" echo "$name$curdir" } prompt_command_func() { RET=$? if [ $RET -eq 0 ]; then STATUS_COLOR=$PROMPT_SUCCESS_COLOR else STATUS_COLOR=$PROMPT_FAILURE_COLOR fi; PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(eval "sps")$COLOR_RESET " } export PROMPT_COMMAND="prompt_command_func" # man pages with vim vman() { if command -v nvim >/dev/null 2>&1; then nvim -c "SuperMan $*" else vim -c "SuperMan $*" fi if [ "$?" != "0" ]; then echo "No manual entry for $*" fi } alias _man="\\man" alias man="vman" # save the current directory for later retrieval scwd() { addon="" if [[ -n $1 ]]; then addon="-$1" fi echo "$PWD" > "$DOTFILES_PATH/cwd$addon.tmp" } export -f scwd bind '"\C-s"':"\"scwd\C-m\"" # go to the saved current directory gcwd() { addon="" if [[ -n $1 ]]; then addon="-$1" fi cd $(cat $DOTFILES_PATH/cwd$addon.tmp) } export -f gcwd bind '"\C-g"':"\"gcwd\C-m\"" complete -cf sudo complete -cf man # allow a per-device script that is pulled in if [ -a "$HOME/.bashrc_env" ]; then . "$HOME/.bashrc_env" fi fi