Last active
June 11, 2020 04:15
-
-
Save euske/d854bb32ef42e1b52006a7b6c6a41bcc to your computer and use it in GitHub Desktop.
Bare minimum bashrc (no external dependency)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- shell-script -*- | |
## | |
## Minimum .bashrc for euske | |
## | |
# Do nothing if not interactive. | |
[[ -z "$PS1" ]] && return | |
# Shell options. | |
IGNOREEOF=10 | |
HISTSIZE=50000 | |
HISTFILESIZE=50000 | |
#TMOUT=600 # auto-logout | |
umask 022 | |
ulimit -c 0 | |
unset MAIL | |
unset command_not_found_handle | |
shopt -u sourcepath # Do not use the PATH for source command. | |
shopt -s histappend # Always append to the history. | |
shopt -s histverify # Always verify the history expansion. | |
shopt -s histreedit # Allow reediting a failed expansion. | |
shopt -s checkwinsize # Automatically set LINES and COLUMNS. | |
shopt -u hostcomplete # Do not attempt to complete hostnames. | |
shopt -s no_empty_cmd_completion # Do not attempt to complete an empty line. | |
# Environment variables. | |
unset LANG | |
export PAGER=less | |
export EDITOR=vi | |
export LESS='-F -R -X -K -i -P ?f%f:(stdin). ?lb%lb?L/%L.. [?eEOF:?pb%pb\%..]' | |
export RSYNC_RSH=ssh | |
export CVS_RSH=ssh | |
# Terminal settings. | |
#eval `SHELL=sh tset -sQI` | |
#stty sane start ^- stop ^- | |
stty start ^- stop ^- | |
# Prompt settings. | |
function prompt_cmd { | |
# Show the exit code of the last command. | |
local s=$? | |
if [[ $s -eq 0 ]]; then return; fi | |
echo "exit $s" | |
} | |
PROMPT_COMMAND=prompt_cmd | |
PS1="\t $HOSTNAME\w[\!]\$ " | |
# Convenient functions. | |
function .. { cd ..; } | |
function ../ { cd ..; } | |
function tmp { cd ~/tmp; } | |
function ls { command ls -Fb "$@"; } | |
function ll { command ls -Fl "$@"; } | |
function la { command ls -Fla "$@"; } | |
function c { command cat "$@"; } | |
function h { command head "$@"; } | |
function t { command tail "$@"; } | |
function T { command tail -f "$@"; } | |
function j { jobs -l; } | |
function rmi { command rm -i "$@"; } | |
function mvi { command mv -i "$@"; } | |
function cpi { command cp -i "$@"; } | |
function g { LC_CTYPE=C command grep -i "$@"; } | |
function r { LC_CTYPE=C command grep -ir "$@"; } | |
function G { LC_CTYPE=C command grep "$@"; } | |
# hd: hex dump. | |
function hd { | |
od -Ax -tx1z -v "$@"; | |
} | |
# xargsn: properly handle filenames with spaces. | |
function xargsn { | |
xargs -d '\n' "$@"; | |
} | |
# l: less for a file, ls for a directory. | |
function l { | |
if [ $# -eq 0 ]; then | |
${PAGER:-less} | |
elif [ -d "$1" ]; then | |
ls -F "$@" | |
else | |
${PAGER:-less} "$@" | |
fi | |
} | |
# f: find files by name (case insensitive) | |
function f { | |
if [ ! "$1" ]; then | |
echo 'usage: f pattern [dir ...]' | |
else | |
n="*$1*"; shift; find . "$@" -iname "$n" | |
fi | |
} | |
# F: find files by name (case sensitive) | |
function F { | |
if [ ! "$1" ]; then | |
echo 'usage: F Pattern [dir ...]' | |
else | |
n="*$1*"; shift; find . "$@" -name "$n" | |
fi | |
} | |
# Aliases. | |
unalias -a | |
alias 644='chmod 644' # cannot be a function (invalid identifier) | |
alias 755='chmod 755' # cannot be a function (invalid identifier) | |
# Completions. | |
complete -d cd | |
complete -c man | |
complete -v unset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment