Shell Configs: Difference between revisions

From Leo's Notes
This page was last edited on 4 February 2021, at 21:13.
Created page with "Below is my current bash profile (.bashrc). == Leo's .bashrc == # .bashrc # # Solaris? Bail out using /bin/sh and skip all the # bash fancinesses which applies mostly to l..."
 
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
Below is my current bash profile (.bashrc).
Linux power users typically symlink their shell environment settings into a set of 'dotfiles' which can then be version controlled. You can easily find other's dotfiles by searching 'dotfiles' on github.


== Leo's .bashrc ==
I have been using a slightly different approach where my shell configuration (including vim configs and plugins, SSH authorized_keys, etc.) are copied directly to the home directory.  This is a matter of personal taste as I really don't like seeing symlinks littered across my home directory, though the downside to this method is that changes can't be made directly on the home directory as it isn't the source of truth anymore.  


My shell configs can be viewed at https://git.steamr.com/leo/shell-configs. As part of the configs, there is a bootstrap shell script which I run directly via wget to setup or update the account I'm working on.


# .bashrc
The bootstrap command to load the configs is:
 
{{highlight|lang=terminal|code=
#
$ curl https://git.steamr.com/leo/shell-configs/raw/master/bootstrap.sh {{!}} sh && exec bash
# Solaris? Bail out using /bin/sh and skip all the
}}
# bash fancinesses which applies mostly to linux.
#
if [ "`uname`" = "SunOS" ] ; then
    exec sh
fi
 
#
# The 'free' command doesn't exist in FreeBSD. Will
# run sysctl and show memory information instead.
#
if [ "`uname`" = "FreeBSD" ] ; then
    alias free="sysctl hw.physmem"
fi
 
#
# Alias vi to vim only if vim exists
#
command -v vim >/dev/null 2>&1
if [ $? -eq 0 ] ; then
    alias vi=vim
fi
 
#
# Aliases to ls and grep with nice options as default
#
alias ls="ls --color -F -h"
alias grep="grep --color=always --line-buffered"
 
 
 
== Details ==
 
=== ls ===
The command:
ls --color=always -F -h
 
Flags:
--color[=auto]
Ensures that the output is colorized only to stdout. We do not want colors to go through pipes. The 'auto' value is implied as it is the default option.
-F
Prints a forward slash on directories.
-h
Prints sizes in human readable form
 
=== grep ===
The command:
grep --color=always --line-buffered
 
Flags:
--color=always
Ensures output is colored even if not going to stdout. Makes it nice when piping to <code>more</code> or <code>less</code>.
--line-buffered
As I usually deal with lines of texts, this makes piping multiple greps together work properly.  
 


A basic mode can be used to only configure applications but not shell or SSH keys (useful for shared environments):


{{Highlight
| code = $ curl https://leo.leung.xyz/bash {{!}} sh -s basic
| lang = terminal
}}




{{Navbox Linux}}
[[Category:Linux]]
[[Category:Linux]]
[[Category:LinuxUtilities]]

Latest revision as of 21:13, 4 February 2021

Linux power users typically symlink their shell environment settings into a set of 'dotfiles' which can then be version controlled. You can easily find other's dotfiles by searching 'dotfiles' on github.

I have been using a slightly different approach where my shell configuration (including vim configs and plugins, SSH authorized_keys, etc.) are copied directly to the home directory. This is a matter of personal taste as I really don't like seeing symlinks littered across my home directory, though the downside to this method is that changes can't be made directly on the home directory as it isn't the source of truth anymore.

My shell configs can be viewed at https://git.steamr.com/leo/shell-configs. As part of the configs, there is a bootstrap shell script which I run directly via wget to setup or update the account I'm working on.

The bootstrap command to load the configs is:

$ curl https://git.steamr.com/leo/shell-configs/raw/master/bootstrap.sh | sh && exec bash

A basic mode can be used to only configure applications but not shell or SSH keys (useful for shared environments):

$ curl https://leo.leung.xyz/bash | sh -s basic