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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
7zip     22.01   main   2022-11-25 20:29:25
adb 33.0.3 main 2022-09-29 18:06:51
dark 3.11.2 main 2022-12-08 17:56:35
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
lazygit 0.36.0 extras 2022-12-09 11:08:51
llvm 15.0.6 main 2022-12-13 14:47:18
neovim 0.8.1 main 2022-12-09 10:39:39
python 3.11.1 main 2022-12-08 17:57:36
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

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
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 di2 {git difftool head~10 @Args}
function co {git checkout @Args}
function me {git merge --no-ff @Args}
function pi {git cherry-pick @Args}
function pull {git pull origin develop ; echo "pull develop"}
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 pull4 {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 pu {git push origin @Args}

function kc {kubectl @Args}

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

function change-to-develop {co develop}

set-alias cod change-to-develop
set-alias vi nvim

######### 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\my\app\ColorTool\ColorTool.exe solarized_light.itermcolors



Invoke-Expression (&starship init powershell)


Set-PSReadLineKeyHandler -Key Ctrl+b `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build current project" `
-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 build 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

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}' "$@"