From a3628fc49db4d88ff3e4067268650710d1da3f6f Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Fri, 12 Feb 2021 03:59:34 +0000 Subject: initial openbsd support --- linux/bash.html | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 linux/bash.html (limited to 'linux/bash.html') diff --git a/linux/bash.html b/linux/bash.html new file mode 100644 index 0000000..f49d27e --- /dev/null +++ b/linux/bash.html @@ -0,0 +1,165 @@ + + + + + 2.5.2. Bash + + + Core OS Index + +

2.5.2. Bash

+ +

Just to be sure, setup bash as default login;

+ +

+        $ chsh
+        
+ +

Description of configuration files;

+ +
+
~/.bash_profile
+
Minimal file that just load .profile and then .bashrc, + in this order.
+ +
~/.profile
+
Not specifically related to bash, such as + environment variables (PATH). Only for login shells (sh) + or graphical applications.
+ +
~/.bashrc
+
Related to interactive command line, such as bash + alias, editor.
+
+ +

2.5.2.1. Profile

+ +

Example of ~/.profile;

+ +
+	export GPG_AGENT_INFO  # the env file does not contain the export statement
+	export SSH_AUTH_SOCK   # enable gpg-agent for ssh
+
+	export GPGKEY=XXXXXXXX
+
+	# ssh-agent to ask only ounce for password
+	SSH_ENV="$HOME/.ssh/environment"
+	function start_agent {
+	    echo "Initialising new SSH agent..."
+	    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
+	    echo succeeded
+	    chmod 600 "${SSH_ENV}"
+	    . "${SSH_ENV}" > /dev/null
+	    /usr/bin/ssh-add;
+	}
+
+	# Source SSH settings, if applicable
+	if [ -f "${SSH_ENV}" ]; then
+	    . "${SSH_ENV}" > /dev/null
+	    #ps ${SSH_AGENT_PID} doesn't work under cywgin
+	    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
+		start_agent;
+	    }
+	else
+	    start_agent;
+	fi
+
+	# Weston
+	if test -z "${XDG_RUNTIME_DIR}"; then
+	    export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir
+	    if ! test -d "${XDG_RUNTIME_DIR}"; then
+		mkdir "${XDG_RUNTIME_DIR}"
+		chmod 0700 "${XDG_RUNTIME_DIR}"
+	    fi
+fi        
+ +

2.5.2.2. Bash RC

+ +

Example of ~/.bashrc;

+ +
+        # If not running interactively, don't do anything
+        case $- in
+                *i*) ;;
+                *) return;;
+        esac
+
+
+        # check the window size after each command and, if necessary,
+        # update the values of LINES and COLUMNS.
+        shopt -s checkwinsize
+
+
+        # 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
+
+        alias tmux="tmux -2"
+
+        alias rm='rm -i'
+        #alias cp='cp -i'
+        alias mv='mv -i'
+        # Prevents accidentally clobbering files.
+        alias mkdir='mkdir -p'
+
+        alias h='history'
+        alias j='jobs -l'
+        alias which='type -a'
+        alias ..='cd ..'
+
+        # Generate a password
+        genpasswd () {
+            local l=$1
+            [ "$l" == "" ] && l=20
+            tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
+        }
+
+        # Git graph log
+        glog () {
+            git log --graph --abbrev-commit --decorate --date=relative --all
+        }
+
+        if [[ -z "$TMUX" ]] ;then
+            ID="`tmux ls | grep -vm1 attached | cut -d: -f1`" # get the id of a deattached session
+            if [[ -z "$ID" ]] ;then # if not available create a new one
+                tmux new-session
+            else
+                tmux attach-session -t "$ID" # if available attach to it
+            fi
+        fi
+        
+ +

2.5.2.3. Bash profile

+ +

Example of ~/.bash_profile;

+ +
+                #!/bin/bash
+                if [ -f ~/.profile ]; then
+                   source ~/.profile
+                fi
+
+                if [ -f ~/.bashrc ]; then
+                   source ~/.bashrc
+                fi
+        
+ + + Core OS Index +

+ This is part of the Tribu System Documentation. + Copyright (C) 2020 + Tribu Team. + See the file Gnu Free Documentation License + for copying conditions.

+ + + + -- cgit 1.4.1-2-gfad0