Advertisement
KukuRuzo

bashrc

Jun 23rd, 2024
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.06 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. PATH="/usr/lib/ccache/bin:$HOME/.local/bin:$HOME/bin:/snap/bin:$PATH"
  4. XDG_DATA_DIRS="$XDG_DATA_DIRS:/var/lib/flatpak/exports/share"
  5. # If not running interactively, don't do anything
  6. case $- in
  7.     *i*) ;;
  8.       *) return;;
  9. esac
  10.  
  11. # don't put duplicate lines or lines starting with space in the history.
  12. # See bash(1) for more options
  13. HISTCONTROL=ignoreboth
  14.  
  15. # append to the history file, don't overwrite it
  16. shopt -s histappend
  17.  
  18. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  19. HISTSIZE=1000
  20. HISTFILESIZE=2000
  21.  
  22. # check the window size after each command and, if necessary,
  23. # update the values of LINES and COLUMNS.
  24. shopt -s checkwinsize
  25.  
  26. # make less more friendly for non-text input files, see lesspipe(1)
  27. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  28.  
  29.  
  30. # set a fancy prompt (non-color, unless we know we "want" color)
  31. case "$TERM" in
  32.     xterm-color|*-256color) color_prompt=yes;;
  33. esac
  34.  
  35. if ! shopt -oq posix; then
  36.   if [ -f /usr/share/bash-completion/bash_completion ]; then
  37.     . /usr/share/bash-completion/bash_completion
  38.   elif [ -f /etc/bash_completion ]; then
  39.     . /etc/bash_completion
  40.   fi
  41. fi
  42. export VISUAL="nano"
  43.  
  44. SYS_ID="$(lsb_release -si)"
  45.  
  46. backup_vars() {
  47.     OLDEDITOR=${EDITOR}
  48.     OLDHOME=${HOME}
  49.     OLDLANG=${LANG}
  50.     OLDPATH=${PATH}
  51.     OLDPS1=${PS1}
  52.     OLDTERM=${TERM}
  53.     echo -e "*Backup variables*
  54. OLDEDITOR=${EDITOR}
  55. OLDHOME=${HOME}
  56. OLDLANG=${LANG}
  57. OLDPATH=${PATH}
  58. OLDPS1=${PS1}
  59. OLDTERM=${TERM}"
  60. }
  61.  
  62. restore_vars() {
  63.     EDITOR=${OLDEDITOR}
  64.     HOME=${OLDHOME}
  65.     LANG=${OLDLANG}
  66.     PATH=${OLDPATH}
  67.     PS1=${OLDPS1}
  68.     TERM=${OLDTERM}
  69.     echo -e "*Restore variables*
  70. EDITOR=${OLDEDITOR}
  71. HOME=${OLDHOME}
  72. LANG=${OLDLANG}
  73. PATH=${OLDPATH}
  74. PS1=${OLDPS1}
  75. TERM=${OLDTERM}"
  76. }
  77.  
  78. prepare_mxe(){
  79. backup_vars
  80. unset `env | \
  81.     grep -vi '^EDITOR=\|^HOME=\|^LANG=\|MXE\|^PATH=' | \
  82.     grep -vi 'PKG_CONFIG\|PROXY\|^PS1=\|^TERM=' | \
  83.     cut -d '=' -f1 | tr '\n' ' '`
  84. export PATH=$PATH:/home/vitaly/github/mxe/usr/bin
  85. }
  86. run_mxe_cmake(){
  87. prepare_mxe
  88. i686-w64-mingw32.shared-cmake $@
  89. restore_vars
  90. }
  91. run_mxe_cmake_64(){
  92. prepare_mxe
  93. x86_64-w64-mingw32.shared-cmake $@
  94. restore_vars
  95. }
  96.  
  97. update_ubuntu_system() {
  98.     sudo apt update && sudo apt dist-upgrade
  99. }
  100.  
  101. update_ubuntu_all() {
  102.     update_ubuntu_system
  103.     sudo update-apt-xapian-index -vf && sudo snap refresh \
  104.     && flatpak update
  105. }
  106.  
  107. clean_ubuntu_system() {
  108.     sudo apt autoremove && sudo apt autoclean
  109. }
  110.  
  111. update_system() {
  112.     trizen -Suy
  113. }
  114.  
  115. clean_system() {
  116.     sudo pacman -Qtdq | sudo pacman -Rns - || echo "Nothing to clean"
  117. }
  118.  
  119. install_custom_pkg() {
  120.     sudo pacman -U $@
  121. }
  122.  
  123. git_commit() {
  124.     if [ ! -z "$1" ]; then
  125.         git commit -am"$@"
  126.         echo "Do you want to push your changes [y/n]"
  127.         read answ
  128.         if [ "${answ}" == "y" ] || [ "${answ}" == "Y" ]; then
  129.             git push
  130.         fi
  131.     else
  132.         echo "Command usage:
  133. gitcommit \"Description\""
  134.     fi
  135. }
  136.  
  137. build_arch_pkg() {
  138.     if [ ! -z "$1" ]; then
  139.         cdir=$(pwd)
  140.         cd "$@"
  141.         makepkg -ifCc
  142.         cd ${cdir}
  143.     fi
  144. }
  145.  
  146. update_psi_plus() {
  147.     build_arch_pkg /home/vitaly/build/pkgs/psi-plus-git
  148. }
  149.  
  150. update_psi() {
  151.     build_arch_pkg /home/vitaly/build/pkgs/psi-git
  152. }
  153.  
  154. update_psi_plus_plugins() {
  155.     build_arch_pkg /home/vitaly/build/pkgs/psi-plus-plugins-git
  156. }
  157.  
  158. update_psi_plugins() {
  159.     build_arch_pkg /home/vitaly/build/pkgs/psi-plugins-git
  160. }
  161.  
  162. update_psi_plus_l10n() {
  163.     build_arch_pkg /home/vitaly/build/pkgs/psi-plus-l10n-git
  164. }
  165.  
  166. update_psi_l10n() {
  167.     build_arch_pkg /home/vitaly/build/pkgs/psi-l10n-git
  168. }
  169.  
  170. update_psi_resources() {
  171.     build_arch_pkg /home/vitaly/build/pkgs/psi-plus-resources-git
  172. }
  173.  
  174. update_psimedia() {
  175.     build_arch_pkg /home/vitaly/build/pkgs/psimedia-git
  176. }
  177.  
  178. update_psi_all() {
  179.     update_psi
  180.     update_psi_plugins
  181.     update_psi_l10n
  182. }
  183.  
  184. m_deploy_qt() {
  185.     deplbin=/home/vitaly/github/mxedeployqt/mxedeployqt
  186.     mxepath=/home/vitaly/github/mxe
  187.     python $deplbin --mxepath=$mxepath "$@"
  188. }
  189.  
  190. config_psi_mxe32() {
  191.     if [ ! -z "$1" ]; then
  192.         pbtype=$1
  193.     else
  194.         pbtype=basic
  195.     fi
  196.     cmargs="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHAT_TYPE=${pbtype} -DENABLE_PLUGINS=ON -DBUILD_PSIMEDIA=ON -DBUILD_DEV_PLUGINS=ON -DDEV_MODE=ON -DPSI_PLUS=ON -DBUNDLED_IRIS_ALL=ON -DUSE_CCACHE=ON -DVERBOSE_PROGRAM_NAME=ON"
  197.     run_mxe_cmake $cmargs "$@"
  198. }
  199.  
  200. config_psi_mxe64() {
  201.     if [ ! -z "$1" ]; then
  202.         pbtype=$1
  203.     else
  204.         pbtype=basic
  205.     fi
  206.     cmargs="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCHAT_TYPE=${pbtype} -DENABLE_PLUGINS=ON -DBUILD_PSIMEDIA=ON -DBUILD_DEV_PLUGINS=ON -DDEV_MODE=ON -DPSI_PLUS=ON -DBUNDLED_IRIS_ALL=ON -DUSE_CCACHE=ON -DVERBOSE_PROGRAM_NAME=ON"
  207.     run_mxe_cmake_64 $cmargs "$@"
  208. }
  209.  
  210. build_psi_mxe32() {
  211.     run_mxe_cmake --build . --target all --target prepare-bin --target prepare-bin-libs --parallel $(grep -c ^processor /proc/cpuinfo)
  212. }
  213.  
  214. build_psi_mxe64() {
  215.     run_mxe_cmake_64 --build . --target all --target prepare-bin --target prepare-bin-libs --parallel $(grep -c ^processor /proc/cpuinfo)
  216. }
  217.  
  218. print_aliases() {
  219. used_aliases='
  220. alias upsys=update_system
  221. #alias upsys=update_ubuntu_system
  222. #alias upsysall=update_ubuntu_all
  223. alias sysclean=clean_system
  224. alias gitcommit=git_commit
  225. alias gitpull="git pull && git submodule init && git submodule update"
  226. alias gup="sudo update-grub"
  227. alias mxeprep=prepare_mxe
  228. alias mcmake=run_mxe_cmake
  229. alias mcmake64=run_mxe_cmake_64
  230. alias ls="ls --color=auto"
  231. alias grep="grep --color=auto"
  232. alias instpkg=install_custom_pkg
  233. alias gitreset="git reset --hard && git clean -xfd"
  234. alias updatepp=update_psi_plus
  235. alias updatep=update_psi
  236. alias updateppp=update_psi_plugins
  237. alias updatepl=update_psi_l10n
  238. #alias updatepr=update_psi_resources
  239. alias updatepall=update_psi_all
  240. alias deployqt=m_deploy_qt
  241. alias cpsi32=config_psi_mxe32
  242. alias cpsi32w="config_psi_mxe32 webkit"
  243. alias bpsi32=build_psi_mxe32
  244. alias cpsi64=config_psi_mxe64
  245. alias cpsi64w="config_psi_mxe64 webkit"
  246. alias bpsi64=build_psi_mxe64
  247. alias rotatelog="sudo journalctl --vacuum-time=2d"
  248. '
  249. echo -e "${used_aliases}"
  250. }
  251.  
  252. alias upsys=update_system
  253. #alias upsys=update_ubuntu_system
  254. #alias upsysall=update_ubuntu_all
  255. alias sysclean=clean_system
  256. alias gitcommit=git_commit
  257. alias gitpull="git pull && git submodule init && git submodule update"
  258. alias gup="sudo update-grub"
  259. alias mxeprep=prepare_mxe
  260. alias mcmake=run_mxe_cmake
  261. alias mcmake64=run_mxe_cmake_64
  262. alias ls="ls --color=auto"
  263. alias grep="grep --color=auto"
  264. alias instpkg=install_custom_pkg
  265. alias gitreset="git reset --hard && git clean -xfd"
  266. alias updatepp=update_psi_plus
  267. alias updatep=update_psi
  268. alias updateppp=update_psi_plugins
  269. alias updatepl=update_psi_l10n
  270. #alias updatepr=update_psi_resources
  271. alias updatepall=update_psi_all
  272. alias deployqt=m_deploy_qt
  273. alias cpsi32=config_psi_mxe32
  274. alias cpsi32w="config_psi_mxe32 webkit"
  275. alias bpsi32=build_psi_mxe32
  276. alias cpsi64=config_psi_mxe64
  277. alias cpsi64w="config_psi_mxe64 webkit"
  278. alias bpsi64=build_psi_mxe64
  279. alias rotatelog="sudo journalctl --vacuum-time=2d"
  280.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement