From 94e429f914be777770cf8094d728008a5efcf6ff Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Mon, 22 Aug 2016 21:41:57 +0100 Subject: added all core files --- core/bash.html | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 core/bash.html (limited to 'core/bash.html') diff --git a/core/bash.html b/core/bash.html new file mode 100644 index 0000000..ab1350d --- /dev/null +++ b/core/bash.html @@ -0,0 +1,153 @@ + + + + + 4. Bash + + + Systools Index + +

4. Bash

+ +

First create skeleton directory to place the default user + files to be copied to its home directory by + useradd command.

+ +
+        $ sudo mkdir /etc/skel
+        
+ +

Just to be sure, setup bash as default;

+ +

+        $ 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.
+
+ +

4.1. Profile

+ +

Example of ~/.profile;

+ +
+        $ sudo vim /etc/skel/.profile
+        
+ +
+        PATH=~/.composer/vendor/bin:${PATH}
+
+        export GPG_AGENT_INFO  # the env file does not contain the export statement
+        export SSH_AUTH_SOCK   # enable gpg-agent for ssh
+        
+ +

4.2. Bash RC

+ +

Example of bashrc;

+ +
+        $ sudo vim /etc/skel/.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
+        
+ +

4.3. Bash profile

+ +
+        $ sudo vim /etc/skel/.bash_profile
+        
+ +
+                #!/bin/bash
+                if [ -f ~/.profile ]; then
+                   source ~/.profile
+                fi
+
+                if [ -f ~/.bashrc ]; then
+                   source ~/.bashrc
+                fi
+        
+ + + Systools Index +

+ This is part of the SysDoc Manual. + Copyright (C) 2016 + Silvino Silva. + See the file Gnu Free Documentation License + for copying conditions.

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