diff options
Diffstat (limited to 'bash')
| -rw-r--r-- | bash/bash_aliases | 67 | ||||
| -rw-r--r-- | bash/bashrc | 149 | ||||
| -rw-r--r-- | bash/inputrc | 10 | ||||
| -rw-r--r-- | bash/profile | 12 |
4 files changed, 238 insertions, 0 deletions
diff --git a/bash/bash_aliases b/bash/bash_aliases new file mode 100644 index 0000000..9131407 --- /dev/null +++ b/bash/bash_aliases @@ -0,0 +1,67 @@ +# Shortcuts +# ====================================================================== +alias aliases='vim ~/.bash_aliases && source ~/.bash_aliases' +alias evrc='vim ~/.vim/vimrc' +alias ebrc='vim ~/.bashrc && source ~/.bashrc' +alias jupyter-lab='jupyter-lab . &> /dev/null &' # Redirect stdout and stderr + + +# Common program's options +# ====================================================================== + +# coretools +alias diff2='diff --color=always -ys' # side by side, tell if file identical +alias diff='diff --color=always' +alias dir='dir --color=auto' +alias grep='grep --color=auto -i' # color case-insensitive +# Sort files by ASCII value (override current locale) +alias ls='LC_ALL=C ls --color=auto --group-directories-first --classify' +alias la='ls -A' +alias ll='ls -l -h' +alias lla='ll -A' + +alias gcc='gcc -g -std=c99 -lm' +alias ed='ed -p "* "' + +alias gitlogpretty='git log --all --graph --decorate --abbrev-commit' + + +# Precautionary +alias rm='rm -I' # Promt before removing more than 3 files +alias mv='mv -i' # Promt before overwrite +alias cp='cp -i' # same + +#alias sqlite3='sqlite3 --safe' # Disables some really cool dot-commands + + +# Other program's options +# ====================================================================== + +#alias feh='feh -g 640x480 -S filename' # opens files sorted by filename +alias feh='feh -g 640x480 --auto-zoom --scale-down --on-last-slide hold' +alias feht='feh -Tthumb_s' +alias fehfx='feh -Tfs --slideshow-delay' +alias fehfrx='feh -Tfs --recursive --slideshow-delay' +alias units='units --verbose' +alias tty-clock='tty-clock -cs' + +# Quick tools +alias pdfreduce='gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook' +alias youtube-dl_info='youtube-dl --get-filename --get-format --get-duration --get-description' +alias youtube-dl_fast='youtube-dl --format "best[height<=720][fps<=?30]" -o '\''%(title)s.%(ext)s'\' +alias mpv_webcam='mpv av://v4l2:/dev/video0' # retrived from the Archwiki +alias mpv_nhk_720p='mpv "https://nhkwlive-ojp.akamaized.net/hls/live/2003459/nhkwlive-ojp-en/index_4M.m3u8"' +alias scan_dpto_europa='hp-scan --mode=color --device=hpaio:/net/OfficeJet_Pro_6970?ip=192.168.0.7' +#alias java8='~/code/openjdk8/jdk8u265-b01/bin/java' +#alias javac8='~/code/openjdk8/jdk8u265-b01/bin/javac' +#alias inf265_jupyterlab='cd /home/mitsuo/docs/courses/2021-1/INF265; \ +# jupyter lab' + + +# Cosmetic +# ====================================================================== +alias :q='cowsay -d "this isn'\''t Vim"' # To scape single quotes in single + # quoted string first finish opened + # string and add the scaped quote + # (\'). +alias :w="cowsay -b \"this isn't Vim\"" diff --git a/bash/bashrc b/bash/bashrc new file mode 100644 index 0000000..0bdac5a --- /dev/null +++ b/bash/bashrc @@ -0,0 +1,149 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. (That's why ~/.profile +# is needed. To source it from login shells? What does login shell mean +# anyway). + +# Tinkerer's guide to a prettier and colorful CLI: +# https://wiki.archlinux.org/title/Color_output_in_console + +# Basic +# ====================================================================== + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# 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 +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# 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 + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# Alias definitions. +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). Requires `bash-completion package +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# Custom prompt: +# - Blue timestamp and italic green pwd +#PS1='\[\033[34m\]|\D{%H:%M:%S}| \[\033[3;32m\][\w]\[\033[00m\]\n\$ ' +# If error `-bash: __git_ps1: command not found`, uncomment the following line +# Ref.: https://stackoverflow.com/a/15398153/7498073 +source ~/.git-prompt.sh +# user@host pwd (git prompt) +PS1='\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ' + + +# Extra +# ====================================================================== + +# Default editor. Affects a lot of programs. +export EDITOR=vim + +# redundant but useful +# XDG = Cross-Desktop Group +# For more info see https://wiki.archlinux.org/index.php/XDG_Base_Directory +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +#export XDG_DATA_DIRS="/usr/local/share:/usr/share" +#export XDG_CONFIG_DIRS="/etc/xdg" + +# less +LESS="-i " # ignore case +LESS+="-S " # don't chop long lines +LESS+="--RAW-CONTROL-CHARS" +export LESS + +# tldr +export TLDR_CONFIG_DIR="$XDG_CONFIG_HOME" + +# gpg +export GPG_TTY=$(tty) + +# tmux +export TERM="xterm-256color" + +# EGA/VGA font (used with ArchLinux in pre-Xorg session) +if [ -z $DESKTOP_SESSION ]; then + setfont LatGrkCyr-8x16 +fi + + + +# Optional +# ====================================================================== + +# Bash completition for pandoc +if [ -f /usr/bin/pandoc ]; then + eval "$(pandoc --bash-completion)" +fi + +# Greeting or salute +if [ -f /usr/games/cowsay ]; then + # TODO: randomly select one of the following greeting commands + #cowsay -f flaming-sheep "oh no" # original + #cowsay $(fortune -e 30% debian-hints 20% linux 20% science \ + #cowsay $(fortune 30% debian-hints 20% linux 20% science \ + # 20% off/linux 10% off/black-humor) + cowsay $(fortune) + #fortune ascii-art +else + echo "Welcome back $LOGNAME" +fi + +# Homebrew (linuxbrew) +if [ -f /usr/bin/brew ]; then + # for elf executables + export PATH="/home/linuxbrew/.linuxbrew/bin:${PATH}" + # for manpages + export MANPATH="/home/linuxbrew/.linuxbrew/share/man:${MANPATH}" + # for info pages + export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH}" +fi + +# Node.js +export NODE_PATH=~/code/nodejs/node-v16.15.1-linux-x64/lib/node_modules + +# Rust +#. "$HOME/.cargo/env" diff --git a/bash/inputrc b/bash/inputrc new file mode 100644 index 0000000..f40f4a2 --- /dev/null +++ b/bash/inputrc @@ -0,0 +1,10 @@ +# Set up "vi input mode" in bash + +set editing-mode vi +$if mode=vi + +set keymap vi-command +Control-l: clear-screen + +set keymap vi-insert +Control-l: clear-screen diff --git a/bash/profile b/bash/profile new file mode 100644 index 0000000..956694c --- /dev/null +++ b/bash/profile @@ -0,0 +1,12 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if bash +if [ "$SHELL" = "/bin/bash" ]; then + . ~/.bashrc +fi |
