# Profile ###### tags: `program` `profile` [toc] ## References - [Microsoft](https://docs.microsoft.com/zh-tw/windows/terminal/tutorials/powerline-setup) - [ITHelp](https://ithelp.ithome.com.tw/articles/10230798) - [Terminal Setting](https://docs.microsoft.com/zh-tw/windows/terminal/customize-settings/profile-settings) - [Oh My Posh](https://ohmyposh.dev/docs) ## ~/.bashrc ```bash eval "$(oh-my-posh init bash --config ~/.poshthemes/slimfat.omp.json)" if [ -n "$SSH_TTY" ]; then neofetch; fi ``` [ssh-agent not auto launch](https://stackoverflow.com/questions/18880024/start-ssh-agent-on-login) ```bash= # 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 ```bash # 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 ```vim 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 ```bash # 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 ```bash= # 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 ```powershell $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](https://blog.miniasp.com/post/2021/11/24/PowerShell-prompt-with-Oh-My-Posh-and-Windows-Terminal?hmsr=joyk.com&utm_source=joyk.com&utm_medium=referral) ```powershell # 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 ```powershell $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](https://gist.github.com/doggy8088/d3f3925452e2d7b923d01142f755d2ae) [ArgumentCompleter.ps1](https://gist.github.com/doggy8088/2bf2a46f7e65ae4197b6092df3835f21) [Cmdlet_Functions.ps1](https://gist.github.com/doggy8088/553c4548492b63e4ccbe30d843de85f6) [Font Download](https://github.com/ryanoasis/nerd-fonts/) ### Set-ExecutionPolicy to run the script ```powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser ``` ### Open as Adminstrator with Terminal Tab 1. Install gsudo ```powershell= powershell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex" # or choco install gsudo ``` 2. modify the setting.json ```powershell= #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" }, ... ] ```