alias diff='diff2html -s side'
This requires the diff2html cli - https://diff2html.xyz/ - install with `npm install -g diff2html-cli`Ask HN: Best things in your bash_profile/aliases?
191–200 of 288 posts
Re: Ask HN: Best things in your bash_profile/aliases?
#192This one I use daily without thinking about it - it shares my bash history between screens and sessions on a given machine and extends it (grabbed from some corner of the internet): # shares history between tabs with prompt_command HISTSIZE=9000 HISTFILESIZE=$HISTSIZE HISTCONTROL=ignorespace:ignoredups _bash_history_sync() { builtin history -a #1 appends command to histfile HISTFILESIZE=$HISTSIZE #2 sets max size bui…
It's early and I'm lazy... will this always parse the branch upon entering any git directory?
Re: Ask HN: Best things in your bash_profile/aliases?
#193This one I use daily without thinking about it - it shares my bash history between screens and sessions on a given machine and extends it (grabbed from some corner of the internet): # shares history between tabs with prompt_command HISTSIZE=9000 HISTFILESIZE=$HISTSIZE HISTCONTROL=ignorespace:ignoredups _bash_history_sync() { builtin history -a #1 appends command to histfile HISTFILESIZE=$HISTSIZE #2 sets max size bui…
> this gets the git branch to display when I cd into a git repo It's early and I'm lazy... will this always parse the branch upon entering any git directory?
Re: Ask HN: Best things in your bash_profile/aliases?
#194One thing I do is to put this snippet in .bashrc or .profile for i in ${HOME}/.bash.d/*.sh do if [ -r ${i} ] ; then . ${i} fi done And drop some custom scripts in ${HOME}/.bash.d/ like alias.sh, env.sh (my common .bash.d scripts are saved in a git repository)
Whoa, I know someone who does exactly this. Is this a common pattern? Unless you're him!
Re: Ask HN: Best things in your bash_profile/aliases?
#195Re: Ask HN: Best things in your bash_profile/aliases?
#196alias gitl='git log --pretty=format:"%Cred%h %Cgreen %cd %Cblue%<(14,trunc)%an %Creset %s %Cred %d %Creset" --graph --date=short -20'
Re: Ask HN: Best things in your bash_profile/aliases?
#197 function cheat() {
curl cht.sh/$1
}
It queries the cht.sh cheatsheet of various Unix commands. 'cheat tar' prints: # To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .gz archive:
tar -ztvf /path/to/foo.tgz
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
# To extract a .tar in specified Directory:
tar -xvf /path/to/foo.tar -C /path/to/destination/
# To list the content of an .bz2 archive:
tar -jtvf /path/to/foo.tgz
# To create a .gz archive and exclude all jpg,gif,... from the tgz
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
You do have to be online, but there are ways of downloading the directory of cheat sheets to use offline as well.Re: Ask HN: Best things in your bash_profile/aliases?
#198 unameOut="$(uname -a)"
case "${unameOut}" in
*Microsoft*) machine="WSL";;
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
unset unameOut
PROMPT_COMMAND='echo -ne "\033]0;[${machine}] ${USER}@${HOSTNAME}: ${PWD}\007"'Re: Ask HN: Best things in your bash_profile/aliases?
#199I use 'u' to navigate up parent directories: alias u="cd .." alias uu="cd ../.." alias uuu="cd ../../.." alias uuuu="cd ../../../.."
alias ..='cd ../'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'Re: Ask HN: Best things in your bash_profile/aliases?
#200Earlier quoted context omitted.
> this gets the git branch to display when I cd into a git repo It's early and I'm lazy... will this always parse the branch upon entering any git directory?
Edit: ugh, nevermind it _is_ early. I know that answer. Thanks for the cool functions.