Shome shell junk. Thish'sh for myshelf, becaushe I can't remember shi~, and thish, shomeday, may shave me a couple of hoursh...
Someday I'll write a Makefile for doing all this cumbersome work, but for now...
zsh
, though good oldbash
with.bash_profile
will do.- The
coreutils
package installed on macOS (brew install coreutils
). - This repository cloned as
.sh-files
to~
:
$ cd ~ && git clone https://github.com/arcdelta/.sh-files.git
You can either copy-paste the code below into your .zshrc
:
# Sh-files injection
export SHFILES="$HOME/.sh-files"
source "$SHFILES/loader.sh"
include $SHFILES/rc \*
or echo
it there directly from shell:
$ echo '# Sh-files injection
export SHFILES="$HOME/.sh-files"
source "$SHFILES/loader.sh"
include $SHFILES/rc \*' >> ~/.zshrc
Note. If you're not sure what one or another alias stands for, you can simply use which <aliases>
.
$ which gcm gai
gai: aliased to git add --interactive
gcm: aliased to git commit -m
For convenient usage it's advised to place them inside /usr/local/bin
, $HOME/bin
or $HOME/.local/bin
. There's no consensus on this topic, but I'm personally leaning towards the last option. Anyway, don't forget to add the directory of your choice to the PATH
environment variable (if it's not there already).
Let's say you decided to go with the $HOME/.local/bin
option. Check if $HOME/.local/bin
is already in the PATH
:
$ echo $PATH | grep $HOME/.local/bin
If a string with $HOME/.local/bin
in it is returned, then you're good to go and can either create a symlink to a binary, or manually put it into $HOME/.local/bin
.
If nothing is returned, you can add
$HOME/.local/bin
into your.zshrc
like that:$ printf '\n# PATH\nexport PATH="$HOME/.local/bin:$PATH"\n' >> ~/.zshrcor use the default editor (if it's not set, it'll fallback to
vi
):$ "${EDITOR:-vi}" ~/.zshrcor, if you're a wuss, just use vscode:
$ code ~/.zshrc
Then, hold yourself firmly in the .sh-files
directory:
$ pwd
/Users/vm/.sh-files
Create a symlink:
$ ln -s `pwd`/bin/cm $HOME/.local/bin/fake-the-date
Make it executable, then source the config or reopen terminal:
$ chmod +x $HOME/.local/bin/fake-the-date
$ source ~/.zshrc
Test it:
$ fake-the-date
cm: You should specify the commit message and (optionally) the date
Usage: cm [message] [[date]]
Examples:
$ cm 'Plant a tree' '2 days ago'
$ cm 'Create yet another framework' '1 hour ago'
$ cm 'Raise a kid' '2019-11-11 12:35:18'