-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.nu
More file actions
103 lines (84 loc) · 2.7 KB
/
config.nu
File metadata and controls
103 lines (84 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# See https://www.nushell.sh/book/configuration.html
#
# This file is loaded after env.nu and before login.nu
#
# You can open this file in your default editor using:
# config nu
$env.config.show_banner = false
$env.config.buffer_editor = 'code'
$env.path ++= ['/usr/local/bin', '/opt/homebrew/bin']
# asdf config
# https://asdf-vm.com/guide/getting-started.html#_2-configure-asdf
$env.ASDF_NODEJS_AUTO_ENABLE_COREPACK = 'true'
$env.ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY = 'latest_available';
$env.ASDF_DATA_DIR = '~/.asdf' | path expand
$env.path ++= [$"($env.ASDF_DATA_DIR)/shims"]
source ~/.asdf/completions/nushell.nu
$env.PROMPT_COMMAND_RIGHT = ""
$env.PROMPT_COMMAND = {|| (echo $env.PWD | split row "/" | last) }
$env.PROMPT_INDICATOR = ' % '
$env.computer_type = 'home' # 'work' | 'home'
let workspace_path = '~/workspace' | path expand
let worktrees_path = $workspace_path | path join 'worktrees';
let dotfiles_path = $workspace_path | path join 'dotfiles';
# https://matthiasportzel.com/brewfile/
def bbic [] {
brew update
brew bundle install --cleanup --file=($dotfiles_path | path join $"brewfile.($env.computer_type).rb")
brew upgrade
}
def new_ts_project [] {
asdf set nodejs 24.11.1
yarn init -2
"nodeLinker: node-modules\n" | save --force .yarnrc.yml
yarn
yarn add -D typescript @tsconfig/node24 prettier @types/node@24
echo `{
"semi": true,
"trailingComma": "all",
"singleQuote": true
}
` | save --force .prettierrc
echo `{
"$schema": "https://www.schemastore.org/tsconfig",
"extends": "@tsconfig/node24",
"compilerOptions": {
"noEmit": true,
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
}
}
` | save --force tsconfig.json
echo `.yarn` | save --force .prettierignore
open ./package.json
| upsert scripts.format 'prettier --write --ignore-unknown .'
| save --force ./package.json
yarn format
}
def backup-nu-config [] {
open $nu.config-path | save --force `~/OneDrive - Microsoft/config.nu`;
}
def main-git-branch [] {
git branch -r
| lines
| where ($it | str trim | str starts-with 'origin/HEAD')
| first
| parse '{_}/{_} -> {_}/{main_branch}'
| first
| get main_branch
}
def start-feature [feature_name: string, --dry (-d)] {
let repo_name: string = pwd | path basename;
mut branch_name = $feature_name;
let folder = ($worktrees_path | path join $"($feature_name)--($repo_name)");
if $env.computer_type == 'work' {
$branch_name = $"users/maburson/($branch_name)";
}
let command = $"git worktree add -b ($branch_name) ($folder) (main-git-branch)"
print $command;
if $dry == false {
nu -e $command
code $folder
}
}