My environment setting

Starship (~/.config/starship.toml)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
add_newline = false

[line_break]
disabled = true

[directory]
truncate_to_repo = false
truncation_length = 5

[character]
success_symbol = "[➜](bold green)"

[git_branch]
symbol = "🌱 "
style = "bold yellow"

Scoop installed apps (~\scoop\shims)

scoop.cmd list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
7zip       22.01   main   2022-11-25 20:29:25
adb 33.0.3 main 2022-09-29 18:06:51
bat 0.22.1 main 2023-03-01 10:33:20
bottom 0.8.0 main 2023-02-28 16:17:37
dark 3.11.2 main 2022-12-08 17:56:35
dust 0.8.4 main 2023-03-01 10:37:36
fd 8.5.3 main 2022-12-09 10:57:01
fzf 0.33.0 main 2022-09-28 10:35:52
gcc 11.2.0 main 2022-12-13 15:18:08
gitui 0.22.1 main 2022-11-25 20:29:43
go 1.24.2 main 2025-04-30 14:32:28
lazygit 0.36.0 extras 2022-12-09 11:08:51
llvm 15.0.6 main 2022-12-13 14:47:18
mpv 0.36.0 extras 2023-09-27 10:21:02
neovim 0.8.1 main 2022-12-09 10:39:39
python 3.12.1 main 2024-01-10 12:17:06
ripgrep 13.0.0 main 2022-12-09 10:59:32
scrcpy 1.24 main 2022-09-29 18:06:57
starship 1.10.3 main 2022-10-14 11:11:06
streamlink 6.2.0-1 extras 2023-09-27 10:22:18

Powershll $PROFILE

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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function st {git status .}
function br {git branch @Args}
function di {git difftool @Args}
function ad {git add @Args}
function ci {git commit @Args}
function log {git log --name-only @Args}
function log2 {git log --name-only --grep @Args}
function log3 {git log --graph --pretty=oneline --abbrev-commit --name-only}
function cbl {git log $(git branch --show-current) --name-only}
function sml {git log $(git branch --show-current) --name-only --author=forrest @Args}
function di2 {git difftool head~10 @Args}
function dif {di --name-status @Args}
function difd {dif 3B-develop @Args}
function co {git checkout @Args}
function me {git merge --no-ff @Args}
function pi {git cherry-pick @Args}
function pld {git pull origin develop ; echo "pull develop"}
function re {git restore --staged @Args}
function dis {git difftool --staged @Args}
## function push {git push origin develop ; echo "push develop"}
## function pull2 {git pull origin master ; echo "pull master"}
## function push2 {git push origin master ; echo "push master"}
## function pull3 {git pull origin sit ; echo "pull sit"}
## function push3 {git push origin sit ; echo "push sit"}
function plu {git pull origin uat ; echo "pull uat"}
## function push4 {git push origin uat ; echo "push uat"}
## function pull5 {git pull origin prod ; echo "pull prod"}
## function push5 {git push origin prod ; echo "push prod"}

function ph {git push origin (git branch --show-current)}
function pl {git pull origin (git branch --show-current)}

function did {di 3B-develop @Args}

function kc {kubectl @Args}
function ll {ls @Args | sort LastWriteTime -Descending}

function cb {gradle clean build}

function ed {C:\Users\user\Desktop\Forrest\Tool\EditPlus\editplus.exe @Args}

function gk {git update-index --skip-worktree @Args}

function change-to-develop {co 3B-develop}
function change-to-uat {co 3A-uat}
function change-to-uat3B {co 3B-uat}

function difu {dif 3A-uat}

set-alias cod change-to-develop
set-alias cou change-to-uat
set-alias coub change-to-uat3B
set-alias vi nvim
set-alias b bat

function com {co master}

######### zoxide
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell | Out-String)
})


######### PSFzf
# Import-Module PSFzf

# Override PSReadLine's history search
# Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' `
# -PSReadlineChordReverseHistory 'Ctrl+r'

# Override default tab completion
# Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }

# $env:FZF_DEFAULT_OPTS="--height=40% --layout=reverse --info=inline --border --margin=1 --padding=1"

####### color theme
# C:\Users\user\Desktop\Forrest\app\ColorTool\ColorTool.exe solarized_light.itermcolors



Invoke-Expression (&starship init powershell)


Set-PSReadLineKeyHandler -Key Ctrl+k `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build current project" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("gradle clean build -xtest")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Set-PSReadLineKeyHandler -Key Ctrl+t `
-BriefDescription RunningTestCase `
-LongDescription "Run unit test on current project" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("gradle test")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Set-PSReadLineKeyHandler -Key Ctrl+b `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build current project without clean" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("gradle build -xtest")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Set-PSReadLineKeyHandler -Key Ctrl+p `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build and publish current project" `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("gradle clean build -xtest publishtomavenlocal")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Set-PSReadLineKeyHandler -Key Ctrl+d `
-ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("exit")
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}


function mem_used {
$CompObject = Get-WmiObject -Class WIN32_OperatingSystem
$Memory = ((($CompObject.TotalVisibleMemorySize - $CompObject.FreePhysicalMemory)*100)/ $CompObject.TotalVisibleMemorySize)

Write-Host "Memory usage in Percentage:" $Memory

# Top 10 process Memory Usage (MB)
$processMemoryUsage = Get-WmiObject WIN32_PROCESS | Sort-Object -Property ws -Descending | Select-Object -first 10 processname, @{Name="Mem Usage(MB)";Expression={[math]::round($_.ws / 1mb)}}
$processMemoryUsage
}

function battery {
WMIC PATH Win32_Battery Get EstimatedChargeRemaining
}


####### fzf
function fe { fzf | %{ ed $_ } }


####### shortcut
set-alias lg lazygit
set-alias gt gitui


#function connect_vpn {cmd /c "C:\Users\user\Desktop\Forrest\app\SoftEther VPN Client\vpncmd.exe" /CLIENT localhost /CMD AccountConnect "Varmeego VPN"}
#function disconnect_vpn {cmd /c "C:\Users\user\Desktop\Forrest\app\SoftEther VPN Client\vpncmd.exe" /CLIENT localhost /CMD AccountDisconnect "Varmeego VPN"}

Scripts

synchronize argocd (sy)

1
2
3
4
5
6
7
8
9
10
11
12
13
SERVICE_SHORT_FORM=$1
ARGOCD_TOKEN=$(curl -s https://argocd.apps.xxxp2-dev.local/api/v1/session -k -d '{"username":"my","password":"x1xrhqbwdg"}' | jq -r .token)

echo $ARGOCD_TOKEN

case $SERVICE_SHORT_FORM in
l)
SERVICE=login-service ;;
o)
SERVICE=operation-service ;;
esac

curl -XPOST https://argocd.apps.xxxp2-dev.local/api/v1/applications/$SERVICE/sync -H "Authorization: Bearer $ARGOCD_TOKEN" -k|jq .status.sync

set image (si)

1
2
3
4
5
6
7
8
9
10
11
SERVICE_SHORT_FORM=$1
DIGEST=$2

case $SERVICE_SHORT_FORM in
l)
SERVICE=login-service ;;
o)
SERVICE=operation-service ;;
esac

kubectl set image deployment/$SERVICE $SERVICE=repo.xxxp2-dev.local:5000/$SERVICE@sha256:$2

build Jenkins (bu)

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
SERVICE_SHORT_FORM=$1

case $SERVICE_SHORT_FORM in
c)
SERVICE=common-library ;;
l)
SERVICE=login-service ;;
o)
SERVICE=operation-service ;;
esac

case $2 in
d) ENV=develop ;;
s) ENV=sit ;;
u) ENV=uat ;;
p) ENV=prod ;;
esac

#echo "build $SERVICE env: " $ENV
#curl -k -X POST -FSubmit=Build -u my:11e3706cf992e438dff8212e261a99e645 https://ci.xxxp2-dev.local/job/$SERVICE/buildWithParameters?environment=$ENV

echo "build $SERVICE env: " $ENV
if [[ -z "$ENV" ]]
then
curl -k -X POST -FSubmit=Build -u my:11e3706cf992e438dff8212e261a99e645 https://ci.xxxp2-dev.local/job/$SERVICE/build
else
curl -k -X POST -FSubmit=Build -u my:11e3706cf992e438dff8212e261a99e645 https://ci.xxxp2-dev.local/job/$SERVICE/buildWithParameters?environment=$ENV
fi

build process in Jenkins (bp)

1
2
3
4
5
6
7
8
9
10
11
12
13
SERVICE_SHORT_FORM=$1

case $SERVICE_SHORT_FORM in
c)
SERVICE=common-library ;;
l)
SERVICE=login-service ;;
v)
esac


curl -s -k -X POST -FSubmit=Build -u my:11e3706cf992e438dff8212e261a99e645 https://ci.xxxp2-dev.local/job/$SERVICE/lastBuild/api/xml?tree=building,timestamp,estimatedDuration|xq
#curl -s -k -X POST -FSubmit=Build -u my:11e3706cf992e438dff8212e261a99e645 https://ci.xxxp2-dev.local/job/common-api/lastBuild/api/json|jq .artifacts

show logs for k8s pod (po)

1
2
3
4
kubectl get pods  | fzf --info=inline --layout=reverse --header-lines=1 \
--bind 'enter:execute:kubectl logs -f {1}' \
--preview-window up:follow \
--preview 'kubectl logs --follow --tail=100 {1}' "$@"