Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples
  4.  
  5.  
  6.  
  7. ##################
  8. # initialization #
  9. ##################
  10.  
  11. export PS1='$PWD\[\e[1;96m\]$(__git_ps1 " (%s)")\[\e[0m\]> '
  12.  
  13. # if not running interactively, don't do anything
  14. [ -z "$PS1" ] && return
  15.  
  16. # don't put duplicate lines or lines starting with space in the history.
  17. # See bash(1) for more options
  18. HISTCONTROL=ignoreboth
  19.  
  20. # append to the history file, don't overwrite it
  21. shopt -s histappend
  22.  
  23. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  24. HISTSIZE=1000
  25. HISTFILESIZE=2000
  26.  
  27. # check the window size after each command and, if necessary,
  28. # update the values of LINES and COLUMNS.
  29. shopt -s checkwinsize
  30.  
  31. # if set, the pattern "**" used in a pathname expansion context will
  32. # match all files and zero or more directories and subdirectories.
  33. #shopt -s globstar
  34.  
  35. # make less more friendly for non-text input files, see lesspipe(1)
  36. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  37.  
  38. # set variable identifying the chroot you work in (used in the prompt below)
  39. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  40. debian_chroot=$(cat /etc/debian_chroot)
  41. fi
  42.  
  43.  
  44.  
  45. #######################
  46. # check color support #
  47. #######################
  48.  
  49. # set a fancy prompt (non-color, unless we know we "want" color)
  50. case "$TERM" in
  51. xterm-color) color_prompt=yes;;
  52. esac
  53.  
  54. # uncomment for a colored prompt, if the terminal has the capability; turned
  55. # off by default to not distract the user: the focus in a terminal window
  56. # should be on the output of commands, not on the prompt
  57. #force_color_prompt=yes
  58.  
  59. if [ -n "$force_color_prompt" ]; then
  60. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  61. # We have color support; assume it's compliant with Ecma-48
  62. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  63. # a case would tend to support setf rather than setaf.)
  64. color_prompt=yes
  65. else
  66. color_prompt=
  67. fi
  68. fi
  69.  
  70.  
  71.  
  72. ####################
  73. # terminal colours #
  74. ####################
  75.  
  76. if tty -s
  77. then
  78. und=$(tput sgr 0 1) # Underline
  79. bold=$(tput bold) # Bold
  80. black=$(tput setaf 0) # Black
  81. red=$(tput setaf 1) # Red
  82. green=$(tput setaf 2) # Green
  83. yellow=$(tput setaf 3) # Yellow
  84. blue=$(tput setaf 4) # Blue
  85. magenta=$(tput setaf 5) # Magenta
  86. cyan=$(tput setaf 6) # Cyan
  87. white=$(tput setaf 7) # White
  88. reset=$(tput sgr0) # Reset
  89. info=${bold}*${reset} # Feedback
  90. pass=${bold}${blue}*${reset}
  91. warn=${bold}${red}*${reset}
  92. fi
  93.  
  94. unset color_prompt force_color_prompt
  95.  
  96. # If this is an xterm set the title to user@host:dir
  97. case "$TERM" in
  98. xterm*|rxvt*)
  99. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  100. ;;
  101. *)
  102. ;;
  103. esac
  104.  
  105.  
  106.  
  107. #########################################################
  108. # enable color support of ls and also add handy aliases #
  109. #########################################################
  110.  
  111. if [ -x /usr/bin/dircolors ]; then
  112. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  113. alias ls='ls --color=auto'
  114. alias dir='dir --color=auto'
  115. alias vdir='vdir --color=auto'
  116.  
  117. alias grep='grep --color=auto'
  118. alias fgrep='fgrep --color=auto'
  119. alias egrep='egrep --color=auto'
  120. fi
  121.  
  122.  
  123.  
  124. #########################
  125. # some useful functions #
  126. #########################
  127.  
  128. function artisan
  129. {
  130. wd="$PWD";
  131. while [[ "$PWD" != "/" ]];
  132. do
  133. if [ ! -f ./artisan ];
  134. then
  135. cd ..
  136. else
  137. cmd="php artisan $@";
  138. eval $cmd;
  139. break
  140. fi
  141. done
  142. if [[ "$PWD" = "/" ]];
  143. then
  144. printf "${red}artisan not found.${clear}\n";
  145. fi
  146. cd "$wd";
  147. }
  148.  
  149.  
  150.  
  151. #########################
  152. # set up useful aliases #
  153. #########################
  154.  
  155. # You may want to put all your additions into a separate file like
  156. # ~/.bash_aliases, instead of adding them here directly.
  157. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  158.  
  159. if [ -f ~/.bash_aliases ]; then
  160. . ~/.bash_aliases
  161. fi
  162.  
  163. alias ll='ls -alF'
  164. alias la='ls -A'
  165. alias l='ls -CF'
  166.  
  167. 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$//'\'')"'
  168. alias jt='jetbrains-toolbox'
  169. alias xtr='xtrlock -b'
  170. alias x='xtr'
  171. alias xserve='php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 artisan serve'
  172. alias vncserver='x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/tony/.vnc/passwd -rfbport 5900 -shared'
  173. alias vncserver-right='x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/tony/.vnc/passwd -rfbport 5900 -shared -clip 1920x1080+1920+0'
  174. alias psr='phpcs --standard=PSR2 --extensions=php --colors --no-cache -p'
  175. alias psrfix='phpcbf --standard=PSR2 --extensions=php --parallel=10 -p'
  176. alias gitclean='git branch --merged | egrep -v "(^\*|master|[0-9])" | xargs git branch -d'
  177.  
  178. #################
  179. # env variables #
  180. #################
  181.  
  182. # hide spurious GTK errors
  183. export NO_AT_BRIDGE=1
  184. # set vim as default editor
  185. export EDITOR=vim
  186. # export NVM path
  187. NVM_DIR="/home/$USER/.nvm"
  188. export NVM_DIR
  189. # loads nvm (node version manager)
  190. [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
  191. export JAVA_HOME=/usr/share/java
  192. # export NPM path
  193. NODE_PATH=$PATH:`npm root -g`
  194. export NODE_PATH
  195.  
  196. PATH=/home/tony/.local/bin:/home/tony/.composer/vendor/bin:/usr/share/phpstorm/bin:$PATH
  197. export PATH
  198.  
  199. #######################
  200. # bash tab completion #
  201. #######################
  202.  
  203. # enable programmable completion features (you don't need to enable
  204. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  205. # sources /etc/bash.bashrc).
  206. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  207. . /etc/bash_completion
  208. fi
  209.  
  210. if [ -f ~.git-completion.bash ]; then
  211. source ~/.git-completion.bash
  212. fi
  213.  
  214. [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
  215.  
  216.  
  217.  
  218. ############
  219. # SSH auth #
  220. ############
  221.  
  222.  
  223.  
  224. # ensures the ssh key stored in the agent for as long as the session lives
  225. ssh_folder="/home/$USER/.ssh/"
  226. keys=( "id_rsa" )
  227.  
  228. for keyfile in "${keys[@]}"
  229. do
  230.  
  231. ssh-add -L|grep -q ${ssh_folder}${keyfile}
  232.  
  233. if [ $? -eq 0 ]; then
  234. echo "${green}✔ SSH key ${bold}${keyfile}${reset}${green} added.${reset}"
  235. else
  236. if [ $(grep -Fxq "4,ENCRYPTED" ${ssh_folder}${keyfile}) ]; then
  237. ssh-add ${ssh_folder}${keyfile} > /dev/null
  238. else
  239. ssh-add ${ssh_folder}${keyfile} > /dev/null 2>&1
  240. fi
  241. echo "${green}✔ SSH key ${bold}${keyfile}${reset}${green} added.${reset}"
  242. fi
  243. done
  244.  
  245. #complete -C /home/tony/.local/bin/mc mc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement