mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-28 03:37:06 +02:00
feat: add develop environment for ruby
This commit is contained in:
98
home/base/core/git.nix
Normal file
98
home/base/core/git.nix
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
myvars,
|
||||
...
|
||||
}: {
|
||||
# `programs.git` will generate the config file: ~/.config/git/config
|
||||
# to make git use this config file, `~/.gitconfig` should not exist!
|
||||
#
|
||||
# https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
|
||||
home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
||||
rm -f ${config.home.homeDirectory}/.gitconfig
|
||||
'';
|
||||
|
||||
home.packages = with pkgs; [
|
||||
];
|
||||
|
||||
programs.git = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
|
||||
userName = myvars.userfullname;
|
||||
userEmail = myvars.useremail;
|
||||
|
||||
includes = [
|
||||
{
|
||||
# use diffrent email & name for work
|
||||
path = "~/work/.gitconfig";
|
||||
condition = "gitdir:~/work/";
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = {
|
||||
init.defaultBranch = "main";
|
||||
push.autoSetupRemote = true;
|
||||
pull.rebase = true;
|
||||
|
||||
# replace https with ssh
|
||||
url = {
|
||||
"ssh://git@github.com/ryan4yin" = {
|
||||
insteadOf = "https://github.com/ryan4yin";
|
||||
};
|
||||
# "ssh://git@gitlab.com/" = {
|
||||
# insteadOf = "https://gitlab.com/";
|
||||
# };
|
||||
# "ssh://git@bitbucket.com/" = {
|
||||
# insteadOf = "https://bitbucket.com/";
|
||||
# };
|
||||
};
|
||||
};
|
||||
|
||||
# signing = {
|
||||
# key = "xxx";
|
||||
# signByDefault = true;
|
||||
# };
|
||||
|
||||
# A syntax-highlighting pager in Rust(2019 ~ Now)
|
||||
delta = {
|
||||
enable = true;
|
||||
options = {
|
||||
diff-so-fancy = true;
|
||||
line-numbers = true;
|
||||
true-color = "always";
|
||||
# features => named groups of settings, used to keep related settings organized
|
||||
# features = "";
|
||||
};
|
||||
};
|
||||
|
||||
aliases = {
|
||||
# common aliases
|
||||
br = "branch";
|
||||
co = "checkout";
|
||||
st = "status";
|
||||
ls = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate";
|
||||
ll = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate --numstat";
|
||||
cm = "commit -m"; # commit via `git cm <message>`
|
||||
ca = "commit -am"; # commit all changes via `git ca <message>`
|
||||
dc = "diff --cached";
|
||||
|
||||
amend = "commit --amend -m"; # amend commit message via `git amend <message>`
|
||||
unstage = "reset HEAD --"; # unstage file via `git unstage <file>`
|
||||
merged = "branch --merged"; # list merged(into HEAD) branches via `git merged`
|
||||
unmerged = "branch --no-merged"; # list unmerged(into HEAD) branches via `git unmerged`
|
||||
nonexist = "remote prune origin --dry-run"; # list non-exist(remote) branches via `git nonexist`
|
||||
|
||||
# delete merged branches except master & dev & staging
|
||||
# `!` indicates it's a shell script, not a git subcommand
|
||||
delmerged = ''! git branch --merged | egrep -v "(^\*|main|master|dev|staging)" | xargs git branch -d'';
|
||||
# delete non-exist(remote) branches
|
||||
delnonexist = "remote prune origin";
|
||||
|
||||
# aliases for submodule
|
||||
update = "submodule update --init --recursive";
|
||||
foreach = "submodule foreach";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user