From 15af55e802d47654200986d60360bdd914d4d0fb Mon Sep 17 00:00:00 2001 From: Eriks Karls Date: Wed, 9 Nov 2022 11:50:51 +0200 Subject: [PATCH 1/2] Cleanup and restructure --- .bash_profile | 2 +- .bashrc | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.bash_profile b/.bash_profile index 5545f00..b937886 100644 --- a/.bash_profile +++ b/.bash_profile @@ -2,4 +2,4 @@ # ~/.bash_profile # -[[ -f ~/.bashrc ]] && . ~/.bashrc +[[ -r ~/.bashrc ]] && . ~/.bashrc diff --git a/.bashrc b/.bashrc index 569e6e8..9fbad9f 100644 --- a/.bashrc +++ b/.bashrc @@ -4,7 +4,6 @@ [[ $- != *i* ]] && return -[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion # Bash won't get SIGWINCH if another process is in the foreground. # Enable checkwinsize so that bash will check the terminal size when # it regains control. #65623 @@ -12,8 +11,6 @@ shopt -s checkwinsize shopt -s expand_aliases -# export QT_SELECT=4 - # Enable history appending instead of overwriting. #139609 shopt -s histappend HISTCONTROL=ignoreboth @@ -32,6 +29,15 @@ esac use_color=true +# Enable colors for ls, etc. Prefer ~/.dir_colors #64489 +if type -P dircolors >/dev/null ; then + if [[ -f ~/.dir_colors ]] ; then + eval $(dircolors -b ~/.dir_colors) + elif [[ -f /etc/DIR_COLORS ]] ; then + eval $(dircolors -b /etc/DIR_COLORS) + fi +fi + # Set colorful PS1 only on colorful terminals. # dircolors --print-database uses its own built-in database # instead of using /etc/DIR_COLORS. Try to use the external file @@ -96,14 +102,6 @@ if ${use_color} ; then Reset='\[\033[0m\]' Bold='\[\033[1m\]' Invert='\[\033[7m\]' - # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 - if type -P dircolors >/dev/null ; then - if [[ -f ~/.dir_colors ]] ; then - eval $(dircolors -b ~/.dir_colors) - elif [[ -f /etc/DIR_COLORS ]] ; then - eval $(dircolors -b /etc/DIR_COLORS) - fi - fi TimeColour=$LghtYlw HostColour="\[$(get_hostname_colour)\]" if [[ ${EUID} == 0 ]]; then @@ -114,19 +112,16 @@ if ${use_color} ; then CDirColour=$DarkGrn PS1="$TimeColour[\t] $Bold$UserColour\u${HostColour}@\h $Reset$CDirColour\$PWD$Reset $Bold\n$UserColour\\$ ${Reset}" else - if [[ ${EUID} == 0 ]] ; then - # show root@ when we don't have colors - PS1='\u@\h \W \$ ' - else - PS1='\u@\h \w \$ ' - fi + PS1='\u@\h \W \$ ' fi unset use_color safe_term match_lhs sh xhost +local:root > /dev/null 2>&1 +# export QT_SELECT=4 export PATH=$PATH:~/.local/bin:~/bin export EDITOR=vim -[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases \ No newline at end of file +[[ -r ~/.bash_aliases ]] && . ~/.bash_aliases +[[ -r /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion From d398f007c9bdbed4d0f97ec129f90a297c9e4e73 Mon Sep 17 00:00:00 2001 From: Eriks Karls Date: Wed, 9 Nov 2022 11:51:11 +0200 Subject: [PATCH 2/2] Created system cache clearing alias --- .bash_aliases | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.bash_aliases b/.bash_aliases index a137ebf..d6db176 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -78,3 +78,13 @@ colors() { done } +drop_cache() { + free -hw + sync + sudo bash -c "echo 1 > /proc/sys/vm/drop_caches" + if [[ $1 ]]; then + sudo swapoff -a + sudo swapon -a + fi + free -hw +}