function certchain() { # Usage: certchain # Display PKI chain-of-trust for a given domain # GistID: https://gist.github.com/joshenders/cda916797665de69ebcd if [[ "$#" -ne 1 ]]; then echo "Usage: ${FUNCNAME} " return 1 fi local host_port="$1" if [[ "$1" != *:* ]]; then local host_port="${1}:443" fi openssl s_client -connect "${host_port}" /dev/null | grep -E '\ (s|i):' }
I’m flattered
Ask HN: Best things in your bash_profile/aliases?
261–270 of 288 posts
Re: Ask HN: Best things in your bash_profile/aliases?
#262Here's a function you can use to generate a strong printable password on the fly: function gen_passwd () { openssl rand 150 |\ tr -dc '[:graph:]' |\ cut -c 1-${1:-13} } The default password length is 13 characters but you can pass a different length parameter instead. Explanation: * generate 150 pseudo-random bytes using openssl's rand * discard non-printable characters * cut to desired length Note that it will only…
Re: Ask HN: Best things in your bash_profile/aliases?
#263Re: Ask HN: Best things in your bash_profile/aliases?
#264Re: Ask HN: Best things in your bash_profile/aliases?
#265Not as fancy as other tips here, but I bet this is really time saving in the long run for most developers. My core work is alway around ~10 directories, which are mostly code packages. As soon as I start working on a project/team, I create aliases for directories. They take the form: alias agg="cd /ws/ProjectName/src/PackageName/ && echo -n -e '\033]0;PackageName\007' && tab-color-devil-blue" The first part of course…
In my previous setup, I had a function that displayed a menu when I started bash, listing all my "main" directories. So each time you started a session you just had to press 1-7 to go where you wanted.
Re: Ask HN: Best things in your bash_profile/aliases?
#266Earlier quoted context omitted.
7.3 I think - https://lwn.net/Articles/401002/
Damn! My work machine is cut off from outside networks and restricted to the versions of packages on their repo. Guess I can't use it. :/
Re: Ask HN: Best things in your bash_profile/aliases?
#267My favorite new one that I have been using a lot: 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…
if [ ! -s "${cache_dir}"/"$1" ] ; then ...Re: Ask HN: Best things in your bash_profile/aliases?
#268I use prefix qq for my commands because: 1. It is easy to discover all customizations via autocomplete 2. It is not going to clash with existing functionality # (Sort stuff by size, latest down, in a directory) alias qqsize="ls -lSrh" alias qqdate="ls -lrt" # First 100 of largest files/directories in a folder function qqlargest_files_100(){ du -a ./ | sort -n -r | head -n 100 } # Archivate item qq-tar-gz-it () { tar…
function qq-tar-gz-it () { tar -zcvf ${1}.tar.gz $1; }
Saves a step.
Re: Ask HN: Best things in your bash_profile/aliases?
#269One I have been using for over 20 years, aliasing l to my favorite ls switches: alias l='ls -GFla'
I use these 3
alias ls='ls --color=auto --group-directories-first' # override
alias l='ls -hF'
alias ll='ls -hAlF'
alias lt='ls -clthF'
Also, incredibly useful: alias c='clear'
I type `l` and `c` all the time. Then I get on a different machine and `command not found`.Re: Ask HN: Best things in your bash_profile/aliases?
#270 recent = for-each-ref --count=25 --sort=-committerdate refs/heads/ --format="%(refname:short)"
so `git recent` lists the last 25 branches, and then in .bashrc: alias co='select br in $(git recent); do git co $br; break; done'
alias coo='select br in $(git br -r|grep -v "("|grep -v HEAD|cut -c3-|sed "s/^origin.//"); do git co $br; break; done'
and now `co` gives me a menu of recent local branches to check out, and `coo` does the same for remotes on origin