function git-commit-fixup() {
git commit --fixup ":/$*"
}
# usage: suppose there's a commit "fix: the thing"
git-commit-fixup thing
# now there's a new commit "fixup! fix: the thing" which can be autosquashed git tag -f pre-rebase function git-commit-fixup() {
git commit --fixup ":/$*"
}
alias gcf="git-commit-fixup"
# Looks for the most recent commit that matches its arg
# eg: we have three commits with messages:
# "fix: the thing"
# "feat: 5 percent cooler"
# "test: test coolness"
# then we do some work and git add, then do:
gcf cooler
# now we have 4 commits: "
# "fix: the thing"
# "feat: 5 percent cooler"
# "test: test coolness"
# "fixup! feat: 5 percent cooler"
# And autosquash will combine the fixup commit with the appropriate semantic commit as you say.
Sadly I haven't been using it much as someone introduced a bunch of commit lint git hooks that choke horribly on the "fixup!" part. And you can't pass --no-verify while rebasing. function git-checkout-branch-by-search-string() {
local maybe_branch_name
maybe_branch_name=$(git branch --sort=-committerdate | grep $1 | head -n 1)
if [ -n "$maybe_branch_name" ]; then
git checkout "${maybe_branch_name:2}"
else
echo "Could not find branch matching $1"
fi
}
alias gcos="git-checkout-branch-by-search-string"
Branches often include things like ticket numbers and project keys, so you can do $ gcos 1234
and save some typing. function git-commit-fixup() {
git commit --fixup ":/$*"
}
function git-add-all-then-git-commit-fixup() {
git add .
git commit --fixup ":/$*"
}
Long function names that are then assigned to an alias can make it easier to find them later if you forget rarely used ones. That is you can do: function git-checkout-parent-commit() {
local prev
prev=$(git rev-parse HEAD~1)
git checkout "$prev"
}
function git-checkout-child-commit() {
local forward
forward=$(git-children-of HEAD | tail -1)
git checkout "$forward"
}
function git-children-of() {
for arg in "$@"; do
for commit in $(git rev-parse $arg^0); do
for child in $(git log --format='%H %P' --all | grep -F " $commit" | cut -f1 -d' '); do
echo $child
done
done
done
} export CDPATH=.:~/.marks/
function mark {
ln -sv "$(pwd)" ~/.marks/"$1"
}
I prefix all the "marks" with a symbol (eg "@") then if I do $ cd @
then press tab it will list all the marks, or autocomplete if I type more. switch("hints", "off")
task hello, "say hello world":
echo "hello world"
In bash: $ nim hello
hello world $ code script.nim
#!/usr/bin/env nimcr
echo "hello world"
$ ./script.nim
hello world
edit: #!/usr/bin/env nim e --hints:off
But I think the std/strutils/split counter example isn't strong for two reasons:
1. When you disambiguate in Nim, you use just the module name, not it's full path. So it would still just be `strutils/split`.
2. If we were to introduce such a syntax, we could also introduce an `import foobarbazqux as foo` alias syntax, which is present in many languages (eg JavaScript, Clojure, etc). This would also be useful if we ever had module name collisions, which has never happened to me in Nim, but doesn't seem impossible.