Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

171–180 of 288 posts

Re: Ask HN: Best things in your bash_profile/aliases?

#171
post #5

My most commonly used thing in my profile is this combination git tag, push, and npm publish using the current version in my package.json file: np() { PACKAGE_VERSION=$(node -p -e "require('./package.json').version") SHORTVER="v$PACKAGE_VERSION" LONGVER="Version $PACKAGE_VERSION" echo $LONGVER git tag -a "$SHORTVER" -m "$LONGVER" && git push --tags && npm publish }

    node -p "require('./package.json').version"
no need for -e, or also just:

    jq -r .version package.json

Re: Ask HN: Best things in your bash_profile/aliases?

#172
post #146

This is tiny, but I've gotten a surprising amount of mileage out of aliasing 'fx' to firefox --new-instance --profile $(mktemp -d) which pops open a new instance of Firefox with a completely clean, temporary profile. Super useful for testing sites or add-ons without influencing (or being influenced by) by my normal browsing profile.

What would the Google Chrome equivalent look like?

chromium --user-data-dir $(mktemp -d)

Re: Ask HN: Best things in your bash_profile/aliases?

#173

The one I use most often is undoubtedly `g` for `git`. Then I have many aliases inside Git for all kinds of regularly done things, quite a few lifted from Mercurial and then extended; some just shorter names (ci = commit, glog = log --graph) and some more advanced like these three: fixup = "!f() { TARGET=\"$(git rev-parse \"$1\")\"; shift; git commit --fixup=\"$TARGET\" \"$@\" && git -c core.editor=true rebase --inte…

Very nice! Thanks you for sharing this! It really seems very useful to have timestamps for every line of output. I have tried to approximate this in the past, by setting my bash prompt to be: export PS1='\[\e[00;37m\]$?\[\e[0m\]\[\033[1;32m\]\[\033[1;32m\][\t]\[\033[1;41m\]\u\[\033[1;41m\]@\[\033[1;41m\]\h:\[\033[0m\] \[\033[1;32m\]\w\[\033[0m\] \$ ' ... which shows the previous command exit code, the current time (w…

I contemplated that for a while a few years back, but decided against it for several reasons:

① I didn’t like an overly-long prompt. On my own machine I already exclude username and hostname, so it’s just `~/Work$ `. (Sometimes PWD gets a bit long, but generally not too much.)

② It was fairly rare that I actually cared about such a timestamp in any way—if I did, it was normally about time taken, and so I could pipe the program through `time` (this was before I discovered `ts` when figuring “someone must have made a program to do this” a couple of weeks ago when preparing to optimise a build process at work), or execute `date; …; date`.

③ Such a timestamp is only written when the prompt is output, rather than when the program is executed (there may be a sane way to have it work otherwise—I didn’t investigate in any way thoroughly—but my initial thoughts suggested any hacky attempt to move the cursor after the fact would interact badly with commands that cause the command line to span multiple lines). This made it useless for well over 90% of the cases when I might have benefited from it (retroactive timing of the duration of a command, rather than at what o’clock I… probably did something).

I return to the desire for a very mildly intelligent terminal that notes when characters were written to screen when not in raw mode, for optional viewing.

Re: Ask HN: Best things in your bash_profile/aliases?

#174
post #20

I have a whole repository also including several dotfiles that I maintain for already several years [1]. Following are some snippets from the dotfiles/.alias and dotfiles/.functions files from that repository that probably are the most interesting and which I am using on a regular basis: # easier navigation alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ~="cd ~" # Ge…

I'm on a phone right now so can't paste the function easily but check out my dotfiles repo which has keybinding of those ...... aliases for any level.

https://github.com/jleclanche/dotfiles

Re: Ask HN: Best things in your bash_profile/aliases?

#177

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
Post reply on HN