I've used these so much: function gc() { grep -rnI "$@" * ;} function gcA() { grep -rnI -A 5 "$@" * ;} function gcB() { grep -rnI -B 5 "$@" * ;} function gcC() { grep -rnI -C 5 "$@" * ;} function gcf() { grep -rnIl "$@" * ;} Just helper functions built on top of grep
And what do they do? It's not obvious. edit: Thank you both!
Ask HN: Best things in your bash_profile/aliases?
81–90 of 288 posts
Re: Ask HN: Best things in your bash_profile/aliases?
#82This one is pretty useful! Open current OSX Finder directory in Terminal: cdf () { target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'` if [ "$target" != "" ] then cd "$target" pwd else echo 'No Finder window found' >&2 fi }
Re: Ask HN: Best things in your bash_profile/aliases?
#83 echo 'Hello dude '
As an iOS dev, this one is super useful: alias cdd='rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Cleared DerivedData/"'Re: Ask HN: Best things in your bash_profile/aliases?
#84So instead of having to type `cd ~/Projects/someproject` you could just type `j some` and it'll end up there.
Re: Ask HN: Best things in your bash_profile/aliases?
#85alias o=xdg-open alias dus='du -sh * | sort -h' alias mkae=make
Re: Ask HN: Best things in your bash_profile/aliases?
#86One useful alias I have not seen mentioned here is this: alias myip='curl -s https://api.ipify.org' Just prints out my current public IP address. I also have a bunch of others mentioned in this thread, and I've abbreviated a bunch of self-explanatory docker-compose commands, e.g. dcdown, dcup, dcrestart, dcpullup, etc
curl ifconfig.me
is also easy to rememberRe: Ask HN: Best things in your bash_profile/aliases?
#87alias YOLO='aurman -Syyu --noedit --noconfirm'
Re: Ask HN: Best things in your bash_profile/aliases?
#88In my bash_profile is a simple echo which makes the shell say hi to me every time I open an instance. Brightens my day a little bit: echo 'Hello dude ' As an iOS dev, this one is super useful: alias cdd='rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Cleared DerivedData/"'
Have you ever done it by mistake?
Re: Ask HN: Best things in your bash_profile/aliases?
#89I've used these so much: function gc() { grep -rnI "$@" * ;} function gcA() { grep -rnI -A 5 "$@" * ;} function gcB() { grep -rnI -B 5 "$@" * ;} function gcC() { grep -rnI -C 5 "$@" * ;} function gcf() { grep -rnIl "$@" * ;} Just helper functions built on top of grep
And what do they do? It's not obvious. edit: Thank you both!
-n enables line numbers
-I (eye) ignores matches on binary files
-l (ell) lists the filenames of matching files only (overrides -n)
-A, -B, and -C specify how many lines of context after, before, or around the match to display.
"$@" adds any additional command line arguments passed to the functions.
* selects all the files and directories in the current directory.
So, without other arguments, the first four functions list matches with line numbers for all files (ignoring binary files) in the current directory and below, with 0 lines context (match only), 5 lines context after, 5 lines context before, and 5 lines context around the match respectively. The final function lists the filenames only and provides no context or line numbers.
Re: Ask HN: Best things in your bash_profile/aliases?
#90In my bash_profile is a simple echo which makes the shell say hi to me every time I open an instance. Brightens my day a little bit: echo 'Hello dude ' As an iOS dev, this one is super useful: alias cdd='rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Cleared DerivedData/"'
cdd seems like a bananas alias for something that does an rm -rf! Have you ever done it by mistake?