Skip to content

Instantly share code, notes, and snippets.

@uhop
Created July 3, 2016 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uhop/f11632fa81bff6fa4c25300656dce6e7 to your computer and use it in GitHub Desktop.
Save uhop/f11632fa81bff6fa4c25300656dce6e7 to your computer and use it in GitHub Desktop.
My bash setup
# commands from http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html
#alias chmod='command chmod -c'
alias cpr='command cp -rpv'
alias df='command df -kh'
alias df1='command df -ia'
alias diff='diff -up'
alias dsiz='du -sk * | sort -n --'
alias du='command du -kh'
alias du1='echo *|tr " " "n" |xargs -iFF command du -hs FF|sort'
alias env='command env | sort'
alias h='history'
alias inice='ionice -c3 -n7 nice'
alias j='jobs -l'
alias la='command ls -AlG'
alias lc='command ls -lAcrG'
#alias less='vless'
#alias lessc='ccze -A |`type -P less` -R'
alias lk='command ls -lASrG'
alias llh='ll -h'
alias lll='stat -c %a %N %G %U ${PWD}/*|sort'
alias lr='command ls -lARG'
alias lt='command ls -lAtrG'
alias lu='command ls -lAurG'
alias lx='command ls -lAXBG'
#alias mann='command man -H'
#alias n='/usr/bin/nano3'
alias p='command ps -Acl | uniq -w3'
alias path='echo -e ${PATH//:/\n}'
#alias php='php -d report_memleaks=1 -d report_zend_debug=1 -d log_errors=0 -d ignore_repeated_errors=0 -d ignore_repeated_source=0 -d error_reporting=30719 -d display_startup_errors=1 -d display_errors$
alias pp='command ps -Acl'
alias ps1='command ps -lA'
#alias ps2='command ps -H'
alias resetw='echo $'''33[H33[2J''''
#alias subash='sudo sh -c '''export HOME=/root; cd /root; exec bash -l''''
#alias top='top -c'
#alias tree='command tree -Csuflapi'
#alias updatedb='( ( updatedb 2>/dev/null ) & )'
#alias vim='command vim --noplugin'
alias who='command who -ar -pld'
#alias wtf='watch -n 1 w -hs'
# enable color support of ls and also add handy aliases
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# some more ls aliases
alias ls='command ls -G'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
#alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# My custom commands
# no-globbing mode for bash functions, thanks to http://blog.edwards-research.com/2011/05/preventing-globbing/
noGlobOff() {
CMD="$1"
shift
$CMD "$@"
set +f
}
alias noGlob='set -f; noGlobOff'
# Quick context find
implWhere() {
if [ -z "$1" ]; then
echo 'where "Context" [[Path/]WildcardSpec]'
else
IN=""
WSPEC="${2##*/}"
[ "$WSPEC" != "$2" ] && IN="${2%/*}"
[ -z "$IN" ] && IN="."
[ -z "$WSPEC" ] && WSPEC="*"
find "$IN" -type f -name "$WSPEC" -exec grep -EHn "$1" {} \;
fi
}
alias where='noGlob implWhere'
# ~/.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.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# 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
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
xterm-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
#source $(brew --prefix git)/etc/bash_completion.d/git-prompt.sh
#if [ "$color_prompt" = yes ]; then
# PS1='\[\033[01;34m\]\w\[\033[00m\]\[\033[01;36m\]$(__git_ps1 " (%s)")\[\033[0m\]\$ '
#else
# PS1='\w$(__git_ps1 " (%s)")\$ '
#fi
if [ "$color_prompt" = yes ]; then
PS1='\[\033[01;33m\]\w\[\033[00m\] \$ '
else
PS1='\w \$ '
fi
if [ -f "$(brew --prefix bash-git-prompt)/share/gitprompt.sh" ]; then
#GIT_PROMPT_ONLY_IN_REPO=1
#GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status
#GIT_PROMPT_THEME=Default
#GIT_PROMPT_THEME=Single_line_Solarized
GIT_PROMPT_THEME=Single_line
source "$(brew --prefix bash-git-prompt)/share/gitprompt.sh"
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;\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# set PATH so it includes user's private bin if it exists
if [ -d "/usr/local/bin" ] ; then
PATH="/usr/local/bin:$PATH"
fi
# 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
# NVM for node.js
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
nvm use stable
# 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).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
#export HOMEBREW_GITHUB_API_TOKEN=...
PATH="$PATH:$HOME/Library/Android/sdk/platform-tools:$HOME/Library/Android/sdk/tools"
PATH="/Users/elazutkin/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/Users/elazutkin/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/Users/elazutkin/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/Users/elazutkin/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/Users/elazutkin/perl5"; export PERL_MM_OPT;
@uhop
Copy link
Author

uhop commented Jun 30, 2021

MacOS brew-specific:

  • brew install git git-gui nvm chezmoi ⇐ start with that.
  • brew install bash-completion ⇐ enables all completions for brew-installed software.
  • brew install bash-git-prompt ⇐ a nice git-aware prompt.
  • brew install wget ⇐ like curl.
  • brew install age gpg ⇐ encryption utilities.
  • brew tap homebrew/cask ⇐ enable casks.
  • brew install --cask meld ⇐ a visual diff/merge utility.
  • brew install diff-so-fancy ⇐ a nice diff pager.
  • brew install tealdeer ⇐ a man replacement. Alternatives: tldr, cheat.
  • brew install exa ⇐ better ls.
  • brew install bat ⇐ better cat.
  • brew install fd ⇐ better find.
  • brew install ncdu ⇐ better du. Alternatives: dust.
  • brew install ag ⇐ better ack. Alternatives: ripgrep.
  • brew install tig ⇐ text interface for git.
  • brew install httpie ⇐ better curl.
  • brew install broot ⇐ better tree.
  • brew install prettyping ⇐ better ping.
  • brew install htop ⇐ better top.
  • brew install awscli kubernetes-cli nginx ⇐ useful utilities for web development.
  • brew install parallel ⇐ shell parallelization.
  • brew install fzf ⇐ a command-line fuzzy finder.
  • brew install micro ⇐ an editor. Alternatives: nano.

@uhop
Copy link
Author

uhop commented Nov 29, 2022

I started to use chezmoi to manage my dot files: https://github.com/uhop/dotfiles

@uhop
Copy link
Author

uhop commented May 13, 2023

Ubuntu/Debian-specific:

  • sudo apt install build-essential curl git git-gui gitk micro ⇐ start with that
  • Install Homebrew:
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    • eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
    • brew install chezmoi
  • sudo apt install wget age meld tealdeer exa bat ncdu silversearcher-ag tig httpie prettyping htop parallel fzf
  • sudo apt install nginx awscli kubectl net-tools
  • Continue installing with brew.

@uhop
Copy link
Author

uhop commented May 13, 2023

Fonts on Linux (Ubuntu): see https://askubuntu.com/questions/3697/how-do-i-install-fonts

@uhop
Copy link
Author

uhop commented Jun 23, 2023

Restricted soft on ubuntu to play videos:

  • sudo apt install ubuntu-restricted-extras vlc libdvd-pkg
  • sudo dpkg-reconfigure libdvd-pkg

More on videos:

@uhop
Copy link
Author

uhop commented Mar 17, 2024

To support cut-and-paste in the micro editor:

  • Use the default ("external") for the clipboard option.
  • Install a proper command-line clipboard tool:
    • For Wayland: sudo apt install wl-clipboard
    • For X11: sudo apt install xclip xsel — realistically only one could be installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment