Profile

tags: program profile

References

~/.bashrc

eval "$(oh-my-posh init bash --config ~/.poshthemes/slimfat.omp.json)"

if [ -n "$SSH_TTY" ]; then neofetch; fi

ssh-agent not auto launch

# for ssh-agent auto launch and store SSH_ENV="$HOME/.ssh/agent-environment" function start_agent { echo "Initialising new SSH agent..." /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" echo succeeded chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null /usr/bin/ssh-add; } ## Source SSH settings, if applicable if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null #ps ${SSH_AGENT_PID} doesn't work under cywgin ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { start_agent; } else start_agent; fi

Installation

# Installation
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh

# Theme
# https://github.com/JanDeDobbeleer/oh-my-posh/tree/main/themes
mkdir ~/.poshthemes
wget https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/slimfat.omp.json -O ~/.poshthemes/slimfat.omp.json

~/.vimrc

set nu
set ai
set tabstop=4
set expandtab
set hlsearch
set cursorline
set cursorcolumn

syntax on
set bg=dark

colorscheme gruvbox

hi Cursorline ctermbg=240

Installation

# Theme
wget https://raw.githubusercontent.com/morhetz/gruvbox/master/colors/gruvbox.vim -O /usr/share/vim/vim??/col
ors/gruvbox.vim

/etc/inputrc

search history by arrow-up/down

# up/down arrow "\e[A": history-search-backward "\e[B": history-search-forward # page up/down "\e[5~": history-search-backward "\e[6~": history-search-forward

$profile

$themeConf='https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/slimfat.omp.json'
oh-my-posh init pwsh --config $themeConf | Invoke-Expression

Import-Module posh-git
Import-Module Terminal-Icons

Set-PoshPrompt slimfat

. D:\PowershellScript\PROFILE_ArgumentCompleter.ps1
. D:\PowershellScript\PROFILE_PSReadLine.ps1
. D:\PowershellScript\PROFILE_Cmdlets_Functions
. D:\PowershellScript\functions.ps1

. D:\PowershellScript\aliases.ps1

$env:path += ";D:\PowershellScript\Scripts"

# $pwd = [System.IO.Path]::GetDirectoryName($PROFILE)
# ls $pwd\PROFILE_*.ps1 | %{ . $_ }

Setup

Poershell.profile setup

# Oh My Posh
winget install JanDeDobbeleer.OhMyPosh
Install-Module oh-my-posh -Scope CurrentUser -Force

# Terminal Icon
Install-Module -Name Terminal-Icons -Repository PSGallery -Force

# PSReadLine
Install-Module PSReadLine -AllowPrerelease -Force

# posh-git
Install-Module posh-git -Scope CurrentUser

# Font (use Cascadia Nerd Mono)
# Nerd for oh-my-posh
# Casdia Mono v.s. Code ref. https://learn.microsoft.com/en-us/windows/terminal/cascadia-code
## latest
oh-my-posh font install

## old
$version = (ConvertFrom-Json (iwr https://api.github.com/repos/ryanoasis/nerd-fonts/tags).content)[0].name
Invoke-WebRequest -Uri "https://github.com/ryanoasis/nerd-fonts/releases/download/$version/CascadiaCode.zip" -OutFile CascadiaCode.zip
$tmpFolder = New-TemporaryFile | %{ rm $_; mkdir $_ }
Expand-Archive -LiteralPath CascadiaCode.zip -DestinationPath $tmpFolder
Remove-Item -Path .\CascadiaCode.zip

# https://www.powershellgallery.com/packages/PSWinGlue
Install-Module -Name PSWinGlue -Force
Install-Font -Scope User -Path $tmpFolder

Download Profile Scripts

$pattern = [regex]'\$(.+\.ps1)'
$link = @('https://gist.githubusercontent.com/doggy8088/d3f3925452e2d7b923d01142f755d2ae/raw/aabe600ed2adccb43165228b8c8ced6e88ac9fc0/$PROFILE_PSReadLine.ps1','https://gist.githubusercontent.com/doggy8088/2bf2a46f7e65ae4197b6092df3835f21/raw/e5e73da6aabaf51ae49c641f5ca409f38f660443/$PROFILE_ArgumentCompleter.ps1','https://gist.githubusercontent.com/doggy8088/553c4548492b63e4ccbe30d843de85f6/raw/5b8492883519ffbd74557e26d7eaf73dc2692c23/$PROFILE_Cmdlets_Functions.ps1')
foreach( $l in $link ){ curl $l -o $pattern.Match($l).Groups[1].Value }

# https://gist.githubusercontent.com/doggy8088/d3f3925452e2d7b923d01142f755d2ae/raw/aabe600ed2adccb43165228b8c8ced6e88ac9fc0/$PROFILE_PSReadLine.ps1
# https://gist.githubusercontent.com/doggy8088/2bf2a46f7e65ae4197b6092df3835f21/raw/e5e73da6aabaf51ae49c641f5ca409f38f660443/$PROFILE_ArgumentCompleter.ps1
# https://gist.githubusercontent.com/doggy8088/553c4548492b63e4ccbe30d843de85f6/raw/5b8492883519ffbd74557e26d7eaf73dc2692c23/$PROFILE_Cmdlets_Functions.ps1

PSRearLine.ps1
ArgumentCompleter.ps1
Cmdlet_Functions.ps1
Font Download

Set-ExecutionPolicy to run the script

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Open as Adminstrator with Terminal Tab

  1. Install gsudo
powershell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex" # or choco install gsudo
  1. modify the setting.json
#it will like this "list": [ { "guid": "{41dd7a51-f0e1-4420-a2ec-1a7130b7e950}", "name": "Windows PowerShell Elevated", "commandline": "gsudo.exe powershell.exe", //add gsudo "hidden": false, "colorScheme": "Solarized Dark", "icon" : "https://i.imgur.com/Giuj3FT.png" }, ... ]