The aptly named.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
5.1 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. export EDITOR=vim
  2. set -o vi
  3. # If not running interactively, don't do anything
  4. [ -z "$PS1" ] && return
  5. # shopt -s checkwinsize
  6. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  7. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  8. debian_chroot=$(cat /etc/debian_chroot)
  9. fi
  10. # set a fancy prompt (non-color, unless we know we "want" color)
  11. case "$TERM" in
  12. xterm-color) color_prompt=yes;;
  13. esac
  14. # Get our git stuff
  15. source ~/code/dotfiles/git-completion.sh
  16. source ~/code/dotfiles/git-prompt.sh
  17. force_color_prompt=yes
  18. # Prompt colors
  19. BGREEN='\[\033[1;32m\]'
  20. GREEN='\[\033[0;32m\]'
  21. BRED='\[\033[1;31m\]'
  22. BPURPLE='\e[1;36m'
  23. PURPLE='\e[0;36m'
  24. RED='\[\033[0;31m\]'
  25. CYAN='\[\033[0;36m\]'
  26. LCYAN='\[\033[1;36m\]'
  27. BBLUE='\[\033[1;34m\]'
  28. BLUE='\[\033[0;34m\]'
  29. GREY='\[033[0;37m\]'
  30. DGREY='\[033[1;30m\]'
  31. NORMAL='\[\033[00m\]'
  32. # Prompt vars
  33. TIME="\@"
  34. HOST="\h"
  35. USER="\u"
  36. CWD="\w"
  37. PUID="\$"
  38. GIT="\$(__git_ps1)"
  39. if [ -n "$force_color_prompt" ]; then
  40. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  41. color_prompt=yes
  42. else
  43. color_prompt=
  44. fi
  45. fi
  46. if [ "$color_prompt" = yes ]; then
  47. PS1="${BLUE}(${GREEN}${CWD}${BLUE}) ${NORMAL}${HOST}${BRED}${GIT}${NORMAL} [$?${NORMAL}]${GREEN} ${PUID}${NORMAL} "
  48. else
  49. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  50. fi
  51. unset color_prompt force_color_prompt
  52. # If this is an xterm set the title to user@host:dir
  53. case "$TERM" in xterm*|rxvt*)
  54. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  55. ;; *)
  56. ;; esac
  57. # enable color support of ls and also add handy aliases
  58. if [ -x /usr/bin/dircolors ]; then
  59. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  60. alias ls='ls -CFX --color=auto'
  61. #alias dir='dir --color=auto' alias vdir='vdir --color=auto'
  62. alias grep='grep --color=auto'
  63. alias fgrep='fgrep --color=auto'
  64. alias egrep='egrep --color=auto'
  65. fi
  66. # some more ls aliases
  67. alias ll='ls -alF'
  68. alias la='ls -A'
  69. alias l='ls -CF'
  70. #mah aliases, son
  71. alias atr0phy='ssh br4n@atr0phy.net'
  72. alias at0rphy='ssh -L 9050:127.0.0.1:9050 br4n@atr0phy.net'
  73. alias evoluent='xinput --set-button-map 14 3 1 1 4 5 7 8 9 0 10 11'
  74. alias cls='clear && ls -X --color=auto'
  75. alias notes="vim +VimwikiIndex"
  76. alias tmpvim="vim /tmp/$(uuid)"
  77. alias snip="scrot -s ~/Documents/screenshots/%b%d-%H:%M.png"
  78. # Add an "alert" alias for long running commands. Use like so:
  79. # sleep 10; alert
  80. alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
  81. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  82. . /etc/bash_completion
  83. fi
  84. # add this configuration to ~/.bashrc
  85. export HH_CONFIG=hicolor # get more colors
  86. shopt -s histappend # append new history items to .bash_history
  87. export HISTCONTROL=ignorespace # leading space hides commands from history
  88. export HISTFILESIZE=10000 # increase history file size (default is 500)
  89. export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
  90. export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" # mem/file sync
  91. # if this is interactive shell, then bind hh to Ctrl-r
  92. bind '"\C-r": "hh\n"'
  93. export NVM_DIR="/home/brandon.cornejo/.nvm"
  94. [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
  95. # Clipboard jazz
  96. # A shortcut function that simplifies usage of xclip.
  97. # - Accepts input from either stdin (pipe), or params.
  98. # ------------------------------------------------
  99. cb() {
  100. local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
  101. # Check that xclip is installed.
  102. if ! type xclip > /dev/null 2>&1; then
  103. echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
  104. # Check user is not root (root doesn't have access to user xorg server)
  105. elif [[ "$USER" == "root" ]]; then
  106. echo -e "$_wrn_col""Must be regular user (not root) to copy a file to the clipboard.\e[0m"
  107. else
  108. # If no tty, data should be available on stdin
  109. if ! [[ "$( tty )" == /dev/* ]]; then
  110. input="$(< /dev/stdin)"
  111. # Else, fetch input from params
  112. else
  113. input="$*"
  114. fi
  115. if [ -z "$input" ]; then # If no input, print usage message.
  116. echo "Copies a string to the clipboard."
  117. echo "Usage: cb <string>"
  118. echo " echo <string> | cb"
  119. else
  120. # Copy input to clipboard
  121. echo -n "$input" | xclip -selection c
  122. # Truncate text for status
  123. if [ ${#input} -gt 80 ]; then input="$(echo $input | cut -c1-80)$_trn_col...\e[0m"; fi
  124. # Print status.
  125. echo -e "$_scs_col""Copied to clipboard:\e[0m $input"
  126. fi
  127. fi
  128. }
  129. # Aliases / functions leveraging the cb() function
  130. # ------------------------------------------------
  131. # Copy contents of a file
  132. function cbf() { cat "$1" | cb; }
  133. # Copy SSH public key
  134. alias cbssh="cbf ~/.ssh/id_rsa.pub"
  135. # Copy current working directory
  136. alias cbwd="pwd | cb"
  137. # Copy most recent command in bash history
  138. alias cbhs="cat $HISTFILE | tail -n 1 | cb"
  139. # ASCII ART GOODNESS
  140. echo -e "$(<~/.motd)"
  141. # Search command history
  142. bind '"\e[A": history-search-backward'
  143. bind '"\e[B": history-search-forward'