phatboislym

bashrc additions

Oct 27th, 2022 (edited)
1,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.33 KB | None | 0 0
  1. apt() {
  2.   command nala "$@"
  3. }
  4. sudo() {
  5.   if [ "$1" = "apt" ]; then
  6.     shift
  7.     command sudo nala "$@"
  8.   else
  9.     command sudo "$@"
  10.   fi
  11. }
  12.  
  13. # create directory and jump to directory
  14. # function teleport() { mkdir -p "$@" && eval cd "\"\$$#\""; } #old version
  15. function teleport() { mkdir -p "$1" && cd "$1"; }
  16.  
  17. # history for commands and utilities
  18. function usage() { \history | grep $1; }
  19.  
  20. # cd into directory and list files
  21. function spy() { cd "$1" && list; }
  22.  
  23. # copy files to pwd
  24. function grab() { cp -irv "$@" .; }
  25.  
  26. # search aliases
  27. function aka() { alias | grep -i $*; }
  28.  
  29. # copy file with a progress bar
  30. copy()
  31. {
  32.     set -e
  33.     strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
  34.     | awk '{
  35.     count += $NF
  36.     if (count % 10 == 0) {
  37.         percent = count / total_size * 100
  38.         printf "%3d%% [", percent
  39.         for (i=0;i<=percent;i++)
  40.             printf "="
  41.             printf ">"
  42.             for (i=percent;i<100;i++)
  43.                 printf " "
  44.                 printf "]\r"
  45.             }
  46.         }
  47.     END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
  48. }
  49.  
  50. # copy and go to the directory
  51. cpg()
  52. {
  53.     if [ -d "$2" ];then
  54.         cp $1 $2 && cd $2
  55.     else
  56.         cp $1 $2
  57.     fi
  58. }
  59.  
  60. # move and go to the directory
  61. mvg()
  62. {
  63.     if [ -d "$2" ];then
  64.         mv $1 $2 && cd $2
  65.     else
  66.         mv $1 $2
  67.     fi
  68. }
  69.  
  70. # automatically do an ls after each cd
  71. scd()
  72. {
  73.     if [ -n "$1" ]; then
  74.         builtin cd "$@" && ls
  75.     else
  76.         builtin cd ~ && ls
  77.     fi
  78. }
  79.  
  80. # file, search and directory manipulation improvements
  81. alias rm='rm -iv'
  82. alias cp='cp -irv'
  83. alias mkdir='mkdir -pv'
  84. alias rmdir='rm -irv'
  85. alias mv='mv -iv'
  86. alias find='exa -a */ | grep -i $1'
  87. alias lookup='grep –r -l'
  88. alias files="ls -l | egrep -v '^d'" # files only
  89. alias directories="ls -l | egrep '^d'" # directories only
  90. alias list='exa --git --icons --color=always --group-directories-first'
  91.  
  92. # chmod aliases
  93. alias plusx='chmod --preserve-root a+x'
  94. alias minusx='chmod --preserve-root a-x'
  95. alias 000='chmod -R --preserve-root 000'
  96. alias 644='chmod -R --preserve-root 644'
  97. alias 666='chmod -R --preserve-root 666'
  98. alias 755='chmod -R --preserve-root 755'
  99. alias 777='chmod -R --preserve-root 777'
  100. alias chmod='chmod --preserve-root'
  101.  
  102. # Python aliases
  103. alias python='python3'
  104. alias doctest='python3 -m doctest -v'
  105. alias unittest='python3 -m unittest -v'
  106. alias pep8='pycodestyle --show-source --show-pep8 --statistics -qq'
  107. alias autopep8='autopep8 --in-place --aggressive --aggressive'
  108.  
  109. # other aliases
  110. alias cat='bat'
  111. alias sudo='sudo '
  112. alias version='lsb_release -a'
  113. alias update='sudo apt-get update && sudo apt-get upgrade'
  114. alias reboot='sudo shutdown -r now'
  115. alias refresh='reset; list'
  116. alias lowercase='tr A-Z a-z'
  117. alias uppercase='tr a-z A-Z'
  118. alias neovim='vi'
  119. alias clip='xclip -selection clipboard'
  120. alias default='gio open'
  121. alias os='cat /etc/os-release'
  122. alias pushit='git.bash'
  123. alias history='history | less'
  124. alias cflags='gcc -Wall -Wextra -Werror -pedantic'
  125. alias tree='exa --tree'
  126. alias enter='entr'
  127. alias dir='exa'
  128. alias jump='autojump'
  129. alias nvim='.local/squashfs-root/usr/bin/nvim'
  130. alias vim='.local/squashfs-root/usr/bin/nvim'
  131. alias yum='nala'
  132. alias dnf='nala'
  133. alias apt-get='sudo apt-get'
  134. alias path='echo -e ${PATH//:/\\n}'
  135. alias now='date +"%T"'
  136. alias ping='ping -c 5'
  137. alias wget='wget -c'
  138. alias reload='source ~/.bashrc'
  139. alias jobs='jobs -l'
  140.  
  141. # git aliases
  142. alias add="git add"
  143. alias branch="git branch"
  144. alias checkout="git checkout"
  145. alias clone="git clone"
  146. alias commit="git commit -m"
  147. alias init="git init"
  148. alias log="git log"
  149. alias merge="git merge"
  150. alias pull="git pull"
  151. alias push="git push"
  152. alias stash="git stash"
  153. alias status="git status | less"
  154. alias switch="git switch"
  155. function gdiff { git diff $1 $2 | less; }
  156.  
  157. # trim prompt to pwd
  158. PROMPT_DIRTRIM=1
  159.  
  160. # add dirctories to path
  161. export PATH="/home/slym/.local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
  162. export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile && source ~/.bash_profile
  163. export PATH=$PATH:/home/slym/.scripts
  164.  
  165. # autocorrect for cd
  166. shopt -s cdspell
  167.  
  168. # colors for man pages
  169. export LESS_TERMCAP_mb=$'\E[01;31m'                                            
  170. export LESS_TERMCAP_md=$'\E[01;31m'                                            
  171. export LESS_TERMCAP_me=$'\E[0m'                                                
  172. export LESS_TERMCAP_se=$'\E[0m'                                                
  173. export LESS_TERMCAP_so=$'\E[01;44;33m'                                        
  174. export LESS_TERMCAP_ue=$'\E[0m'                                                
  175. export LESS_TERMCAP_us=$'\E[01;32m'
  176.  
  177. # change directory aliases                                                    
  178. alias home='cd ~'                                                              
  179. alias ~='cd ~'
  180. alias ..='cd ..'
  181. alias ...='cd ../..'
  182. alias ....='cd ../../..'
  183.  
  184. function _update_ps1() {
  185.     PS1=$(powerline-shell $?)
  186. }
  187.  
  188. if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
  189.     PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
  190. #    PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} history -a"
  191. fi
  192.  
  193. # Powerline configuration
  194. if [ -f $HOME/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh ]; then
  195.     $HOME/.local/bin/powerline-daemon -q
  196.     POWERLINE_BASH_CONTINUATION=1
  197.     POWERLINE_BASH_SELECT=1
  198.     source $HOME/.local/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh
  199. fi
  200.  
  201. . "$HOME/.cargo/env"
  202.  
  203. # eval "$(starship init bash)"
  204.  
Advertisement
Add Comment
Please, Sign In to add comment