Skip to content

Instantly share code, notes, and snippets.

@arbal
Created February 1, 2021 22:45
Show Gist options
  • Save arbal/96cd4a675da9173d4889907aa71fbdcf to your computer and use it in GitHub Desktop.
Save arbal/96cd4a675da9173d4889907aa71fbdcf to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# histdump.sh
#
HOME=${HOME:-'/root'}
arg1=${1:-}
[[ $arg1 = "bash" ]] && skip_zsh="true"
[[ $arg1 = "zsh" ]] && skip_bash="true"
bash_history="${HOME}/.bash_history"
zsh_history="${HOME}/.zsh_history"
if [[ -z ${skip_bash:-} && -f "$bash_history" ]]; then
# echo "##### cat $bash_history #########################################################################"
cat "$bash_history"
fi
if [[ -z ${skip_zsh:-} && -f "$zsh_history" ]]; then
# shellcheck disable=SC2028
# echo "##### awk -F\; 'NF!=1{printf(\"\n%s\",\$NF)}NF==1{printf(\"n %s \",\$1)}' \"$zsh_history\" #####"
awk -F\; 'NF!=1{printf("\n%s",$NF)}NF==1{printf("n %s ",$1)}' "$zsh_history"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment