For me, it’s just that I don’t have to scroll a config file as long as my arm. ![]()
For me it’s always syu, regardless if I’m on Endeavour or Mint/Zorin/MX/whatever else.
Why did the practice of putting user created shell scripts or programs/applications in $HOME/.local/bin arise instead of the typical $HOME/bin?
I assumed that the directory $HOME/.local was supposed to store the local state of applications/programs.
I suppose it replicates /usr/local/bin but I’m old fashioned and still use $HOME/bin
~/.local/ has grown over time. When I do a ls there, I get directories bin, opt, share, and state.
So it’s not only the local state, but locally shared stuff (fonts, sounds, KDE themes), applications, bigger applications with some baggage and finally, the state of some programs.
Quite impressive growth.
Also, it makes some sense to have the applications in bin in the hidden area, away from your documents, since they are tools and not results of your work. Only the latter should be visible in your home directory if you want it neat and tidy.
To answer OP’s question:
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it. Verify each recalled entry.
shopt -s histappend histverify
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=2000
HISTFILESIZE=5000
# this ignores single-word commands
HISTIGNORE=$'*([\t ])+([-%+,./0-9\:@A-Z_a-z])*([\t ])'
# ensure synchronization between bash memory and history file
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# save history files for each tmux pane in separate files
if [[ $TMUX_PANE ]]; then
HISTFILE=$HOME/.bash_history_tmux_${TMUX_PANE:1}
fi
## Use the up and down arrow keys for finding a command in history
## (you can write some initial letters of the command first).
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# change man display to unhyphenated and ragged-right
export MANOPT="--nh --nj"
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# make less use colors, i. e. in man
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
# Automatically shorten deep paths in the prompt. The \w option in PS1 controls whether to display the path or not.
PROMPT_DIRTRIM=3
# when system is accessed via SSH, hostname with light grey background
if [[ $(pstree -s $$) = *sshd* ]]; then sshbg="\[\033[48;5;7m\]"; fi
# when used as root, change username to orange and '#' to red for prompt
if [ $(id -u) -eq 0 ]; then usercol="\[\033[38;5;3m\]"; hashcol="\[\033[38;5;1m\]"; else usercol="\[\033[38;5;2m\]"; fi
# bash PS1 prompt. $(realpath .) instead of \w avoids symlink paths
PS1="${usercol}\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;4m\]${sshbg}\h\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;6m\]\w\[$(tput sgr0)\]${hashcol}\\$ \[$(tput sgr0)\]"
unset sshbg usercol hashcol
# for non-colored prompt
#else PS1="$\u@\h:\w\$ "
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto --classify --human-readable'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
[[ "$(whoami)" = "root" ]] && return
[[ -z "$FUNCNEST" ]] && export FUNCNEST=100 # limits recursive functions, see 'man bash'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases
[[ -f ~/.bash_functions ]] && . ~/.bash_functions
[[ -f ~/.bash-preexec.sh ]] && . ~/.bash-preexec.sh
#eval "$(atuin init bash --disable-up-arrow)"
are the contents of my ~/.bashrc. Since it’s commented a lot, it should be self-explanatory.
Worth having the corresponding ~/.inputrc here as well:
$if term=linux
set vi-ins-mode-string \1\e[?0c\2
set vi-cmd-mode-string \1\e[?8c\2
$else
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
$endif
TAB: menu-complete
"\e[Z": menu-complete-backward
set editing-mode vi
set show-mode-in-prompt on
$if mode=vi
set keymap vi-command
# these are for vi command mode
Control-l: clear-screen
set keymap vi-insert
# these are for vi insert mode
Control-l: clear-screen
$endif
set menu-complete-display-prefix on
set show-all-if-ambiguous on
set colored-stats on
set colored-completion-prefix on
set completion-ignore-case on
set mark-symlinked-directories on
"\e[A": history-search-backward
"\e[B": history-search-forward
set bell-style none
set echo-control-characters off
I know this topic is for .bashrc but since it is empty, here’s my old .zshrc
I know it’s a mess, i’ll post the new one after cleaning it a bit ![]()
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# ------ Zsh Start ------
export ZSH="$HOME/.oh-my-zsh"
zstyle ':omz:update' mode reminder
# ------ Completion styling ------
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
# ------ Theme ------
ZSH_THEME="powerlevel10k/powerlevel10k"
# ------Load Modules ------
plugins=(git copypath rsync autojump sudo zsh-interactive-cd zsh-autosuggestions you-should-use zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
source <(fzf --zsh)
autoload -U compinit && compinit -u
# ------ History ------
HIST_STAMPS="dd.mm.yyyy"
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups
# ------ Modules configuration ------
# --- BAT ---
#export BAT_THEME=CatppuccinMacchiato
# --- Eza (better ls) ---
alias ls="eza --color=always --long -G -a --group-directories-first --git --git-ignore --no-filesize --icons=always --no-time --no-user --no-permissions"
# --- FZF ---
# - Use fd instead of fzf -
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
# Use fd for listing path candidates.
# - The first argument to the function ($1) is the base path to start traversal
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}
# --- FZF Preview ---
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo $'{}" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "bat -n --color=always --line-range :500 {}" "$@" ;;
esac
}
# --- FZF opts ---
export FZF_DEFAULT_OPTS_FILE="$HOME/.config/fzf/fzf-opts"
# - FZF Hardware/Sendlogs -
hardware() {
cat ~/.scripts/inxilogs/inxi_args.txt | fzf --with-nth 1 | awk '{print $2}' | xargs inxi -c
}
# ------ Aliases ------
alias config='nvim ~/.zshrc'
alias hyprkey='nvim ~/.config/hypr/keybindings.conf'
alias hyprcfg='nvim ~/.config/hypr/userprefs.conf'
alias hyprstart='nvim ~/.config/hypr/startup.conf'
alias nv='nvim'
alias c='clear'
alias bat='bat -n --color=always'
alias rg='rg -S'
alias fman='compgen -c | fzf | xargs batman'
alias py='python3'
alias fastfetch='clear && fastfetch'
#alias fsys='fuzzy-sys'
# ------ Exports ------
export EDITOR='nvim'
export BROWSER='firefox'
# ------ Shell integrations ------
eval "$(fzf --zsh)" #CTRL-T = FZF Select | CTRL-R = FZF History | ALT-C = FZF cd
eval "$(zoxide init --cmd cd zsh)"
eval $(thef*ck --alias)
eval $(thef*ck --alias f*ck) #Today i learned you can't post this word on the forum, had to censor it
# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh.
[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
So read the bash manual and this is what they said about the various options for HISTCONTROL option.
ignorespace = Do not store in bash history commands which start with space
ignoredups = Lines matching the previous history entry are not to be saved.
erasedups = All previous lines matching the current line to be removed from the history list before that line is saved.
So if ignoredups will prevent the same command in bash history from being repeated, why is there a need to have erasedups?
And if ignorespace is used then it is very easy for a hacker to leave no trace for all the commands run, just put a space in front of the commands. No need to enter any commands to disable history. So why use it?
Well, first, i said this was the old one ![]()
At the time i added both ignoredups and erasedups as a way to clean the already existing history, but yeah, once that’s done, having both is useless.
And for ignorespace, honestly, if someone already has enough access to this machine to type commands, my bash history is not how i will find out. But yeah, i guess this is not recommended on all setups.
Forgot about this thread .. and forgot to ever share the following, which I have used when the AUR was down ..
aurmirror() {
git clone -b "$@" --single-branch https://github.com/archlinux/aur.git "$@"
less ./"$@"/PKGBUILD
while true; do
read -rp $'\n'" Do you wish to build and install $@ (y/N)? " yn
case $yn in
[Yy]* ) echo; cd ./"$@" && makepkg -sric; cd ..; break ;;
[Nn]*|* ) echo; break ;;
esac
done
}
Uses the official mirror.
I could make it a little more interesting or safe with checks or a help or something .. but it doesnt have any of that.
Just use aurmirror $package when the AUR is down and you need to build something.
finally have gotten around to reorganizing this. I think this makes it much easier to navigate and find things in my .bashrc file.
I added a function to quickly find the alias when I can’t remember the name of it.
comes in handy when you have programs with several different commands your using in alias
function find_alias() {
alias | grep "$1" | awk -F= '{print $1}'
}
here is a useful function, if you copy to usb thumb drive a lot like I do this makes sure the command isn’t complete until the actual copy has finished on the drive.
function xcopy(){
#copy command for external devices.
local FILE_2_COPY="$1"
local FDESTINATION="$2"
rsync -avuhP "$FILE_2_COPY" "$FDESTINATION" && sync
}
I’ve forever have just used a copy command from history that I already added the && sync to however needing it on other machines making it’s own function made more since
Because that time of the year, my classic prompt but decorated:
export PS1='`if [ $? = 0 ]; then echo "\[\e[0;32m\] 🎄 "; else echo "\[\e[0;31m\] 🎁 "; fi`\[\e[0;31m\]\u\[\e[0;35m\]@\[\e[0;36m\]\h: \[\e[0;35m\]\w \[\e[0;32m\]❄️\[\e[0m\] '

