summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2022-08-31 02:27:30 -0500
committerMitsuo Tokumori <[email protected]>2022-08-31 02:27:30 -0500
commit3856b779adc2d94870d09c301cae0b2c1a9d0f5e (patch)
tree248be2eb323829174d661f72ace6d87724747b68
parent95bcfba116ed18d943cd156295e741b6091196ca (diff)
downloaddotfiles-3856b779adc2d94870d09c301cae0b2c1a9d0f5e.tar.gz
dotfiles-3856b779adc2d94870d09c301cae0b2c1a9d0f5e.tar.bz2
dotfiles-3856b779adc2d94870d09c301cae0b2c1a9d0f5e.zip
Reorganize .bashrc and .profile
-rw-r--r--bashrc137
-rw-r--r--profile33
2 files changed, 57 insertions, 113 deletions
diff --git a/bashrc b/bashrc
index 4498d4c..df80a86 100644
--- a/bashrc
+++ b/bashrc
@@ -1,6 +1,12 @@
-# ~/.bashrc: executed by bash(1) for non-login shells.
-# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
-# for examples
+# ~/.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
@@ -30,83 +36,17 @@ shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
-# set variable identifying the chroot you work in (used in the prompt below)
-if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
-fi
-
-# set a fancy prompt (non-color, unless we know we "want" color)
-case "$TERM" in
- xterm-color|*-256color) color_prompt=yes;;
-esac
-
-# uncomment for a colored prompt, if the terminal has the capability; turned
-# off by default to not distract the user: the focus in a terminal window
-# should be on the output of commands, not on the prompt
-#force_color_prompt=yes
-
-if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
-fi
-
-# Keep the git-bash prompt if available (check if $TITLEPREFIX is set)
-# git-bash promp is helpful when browsing a git-repository
-#PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$'
-if [[ "$color_prompt" = yes && ! -v $TITLEPREFIX ]]; then
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\hh\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
- # Blue timestamp and italic green pwd
- PS1='\[\033[34m\]|\D{%H:%M:%S}| \[\033[3;32m\][\w]\[\033[00m\]\n\$ '
-#else
-# # plain and simple
-# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
-fi
-#unset color_prompt force_color_prompt
-
-# If this is an xterm set the title to user@host:dir
-case "$TERM" in
-xterm*|rxvt*)
- PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\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'
- alias dir='dir --color=auto'
- #alias vdir='vdir --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'
-# some more ls aliases
-#alias ll='ls -l -h'
-#alias lla='ll -A'
-#alias la='ls -A'
-#alias l='ls -CF'
-
# 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.
-
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).
+# 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
@@ -115,28 +55,64 @@ if ! shopt -oq posix; then
fi
fi
+# set PATH so it includes user's private bin if it exists
+if [ -d "$HOME/bin" ] ; then
+ PATH="$HOME/bin:$PATH"
+fi
-# My shit
-# =======
+if [ -d "$HOME/.local/bin" ] ; then
+ PATH="$HOME/.local/bin:$PATH"
+fi
# Custom prompt:
-# Blue timestamp and italic green pwd
+# - 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$ '
-# Environmental variables:
-# less(1) config (ignore case in searchs and display raw control characters)
-export LESS="-i --RAW-CONTROL-CHARS";
-# Needed for tldr(1)
+
+# 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"
-# Needed for gpg(1)?
+
+# gpg
export GPG=TTY=$(tty)
-# Needed for tmux
+
+# tmux
export TERM="xterm-256color"
+# fcitx
+GTK_IM_MODULE=fcitx
+QT_IM_MODULE=fcitx
+XMODIFIERS=@im=fcitx
+
+
+# Optional
+# ======================================================================
+
# Bash completition for pandoc
if [ -f /usr/bin/pandoc ]; then
eval "$(pandoc --bash-completion)"
@@ -151,10 +127,11 @@ if [ -f /usr/games/cowsay ]; then
# 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}"
diff --git a/profile b/profile
index 8990d54..956694c 100644
--- a/profile
+++ b/profile
@@ -1,8 +1,6 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
-# see /usr/share/doc/bash/examples/startup-files for examples.
-# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
@@ -12,34 +10,3 @@
if [ "$SHELL" = "/bin/bash" ]; then
. ~/.bashrc
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
-
-
-
-# Variables
-# ======================================================================
-
-# redundant but useful
-# (XDG = Cross-Desktop Group,
-# more info at 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"
-
-export EDITOR=vim
-
-
-# Fun
-# ======================================================================
-
-echo "Welcome back $LOGNAME"