From: Edward Delaporte Date: Mon, 15 Mar 2021 16:43:56 +0000 (-0500) Subject: Merging cross platform changes. X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/commitdiff_plain/e3b2c2dc5ef49fa1a29fd237c931972cf7b067ef?hp=9f286e3ea659a95d0f179628b5f5c346afc029fe Merging cross platform changes. --- diff --git a/Microsoft.PowerShell_profile.ps1 b/Microsoft.PowerShell_profile.ps1 index 7acc0d2..31b22ad 100644 --- a/Microsoft.PowerShell_profile.ps1 +++ b/Microsoft.PowerShell_profile.ps1 @@ -8,24 +8,40 @@ #} # $env:PSModulePath = $env:PSModulePath.Replace("\\ad.uillinois.edu\techsvc\home\$($ENV:USERNAME)\Documents\PowerShell\Modules;",'') +# No longer needed in PowerShell 7 if($IsWindows -eq "") { - # Bootstrap for older PowerShell - $IsWindows = ($env:OS -eq "Windows_NT") + # Bootstrap for older PowerShell + Write-Host "***Bootstrapped Is Windows for older PowerShell***" + $IsWindows = ($env:OS -eq "Windows_NT") +} + +$env:src = "~" +if($IsWindows){ + Write-Host "***Is Windows***" + $env:src = "c:\src" +} + +if($IsWindows){ + # Some Paths that are annoying to find/restore if the installer fails + $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all + $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice. + $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice. + $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in. } -#if($IsWindows){ -# # Some Paths that are annoying to find/restore if the installer fails -# $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all -# $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice. -# $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice. -# $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in. -#} $env:Journal = "~\Journal\2021" # allows cd $env:journal +$env:minion = "$env:src\minion" # Import some home grown PowerShell modules, if they are installed. -$modPaths = Get-Childitem -Path "c:\src\dotfiles\psmodules" -$modPaths += Get-Childitem -Path "c:\src\minion\psmodule" +# +$modPaths = Get-Childitem -Path "$env:src\dotfiles\psmodules" +$modPaths += Get-Childitem -Path "$env:minion\psmodule" + +# Windows Only Modules +if($IsWindows){ + $modPaths += Get-Childitem -Path "$env:src\dotfiles\win_psmodules" +} if($modPaths.length -eq 0){ Write-Host "No modules found." } @@ -34,19 +50,22 @@ $modPaths | ForEach-Object { Import-Module $fileName Write-Host ">> Loaded $fileName" } -#} -# $env:PSModulePath = $env:PSModulePath + ";c:\src\dotfiles\psmodules" + # Linux-like up/down in shell Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward -Set-PSReadlineOption -HistorySavePath c:\temp\PSHistory.log +Set-PSReadlineOption -HistorySavePath $env:src\PSHistory.log # Minion alias commands - 'today' -. C:\src\minion\profiles\alias.ps1 +# . C:\src\minion\profiles\alias.ps1 +. $env:minion\profiles\alias.ps1 # Add Minion go executable to path. -. C:\src\minion\profiles\path.ps1 +. $env:minion\profiles\path.ps1 +# Add Minion to path +Write-Host "+ Added minion command to path." +$ENV:PATH+=";$env:minion\go" # Flag to ensure my profile kicked in. # Unix dies hard. New-Alias which get-command @@ -60,5 +79,5 @@ Write-Host "+ Type 'pg' to enable PoshGit" if((Get-Location).Path -eq $HOME){ - cd c:\src + cd $env:src } diff --git a/README.md b/README.md index 6e3458a..3d376e6 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ # dotfiles -My ~~Linux~~ dot files. These are shared so that I can easily share a link to a tip or trick. +EdTheDev's Linux and Windows dot files. These are shared so that I can easily share a link to a tip or trick. -## Setup +## Bare Minimum -`bootstrap.ps1` - Script I use to setup on Windows. Mostly relies on Chocolatey, of course. -`bootstrap.sh` - Script I use to setup on Linux. Makes many decisions, as some of my Linux hosts are for targeted purposes. ++ `install.sh` - Script I use to install packages on Linux, most typically a Raspberry Pi. ++ `setup.sh` - Script I use to get to bare minimum (by my definition) setup on Linux - typically a Raspberry Pi. ++ `bootstrap.ps1` - Script I use to setup on Windows. Mostly relies on the `Chocolatey` package manager for Windows, of course. ## Installations -See `\install` for scripts to install various handy utilities. Most of these rely on `Apt` on Linux, or `Chocolatey` on Windows. +See the `\install` folder for scripts to install various handy utilities. Most of these rely on `Apt` on Linux, or `Chocolatey` on Windows. ## Setups -See `setup` for configurations. +See the `\setup` folder for configurations. These are, obviously, just my preferred configurations. -In general, these work by setting up symlinks on Linux, and on Windows by copying a stub file that sources the versioned file. +In general, these work by setting up symlinks on Linux, and on Windows by copying a stub file that sources the versioned file. +Most of these are cross platform `.ps1` files that run under PowerShell. diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100755 index e202b32..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,74 +0,0 @@ -# Reminder to future self: -# Step 1: ssh-keygen on remote host. -# Step 0: Remove any existing .vim, .vimrc and .zsrhrc on remote host. -# Step 2: Add ssh pubkey to GitHub as deploy key. -# Step 3: clone the repo. -# Step 4: Run this bootstrap script. - -# You can scp just this file to the destination host, -# and then run it. - -## Setup Git and Vim -if [ ! -d ~/dotfiles ]; then - sudo apt-get install git install vim - # TODO: Consider vim-nox to resolve 'needs python' error from some of my vundle plugins. - git config --global user.email "edward@delaporte.us" - git config --global user.name "Edward Delaporte" - git config --global core.editor /usr/bin/vim - cd ~; git clone git@github.com:edthedev/dotfiles.git -fi -if [ ! -f ~/.vimrc ]; then - ln -s ~/dotfiles/vimrc ~/.vimrc -fi - - -## Setup PowerShell -if [ ! -f ~/.config/powershell/Microsoft.PowerShell_profile.ps1 ]; then - sudo apt-get install powershell - chsh --shell /usr/bin/pwsh - mkdir -p /home/delaport/.config/powershell/ - ln -s ~/dotfiles/Microsoft.PowerShell_profile.ps1 ~/.config/powershell/Microsoft.PowerShell_profile.ps1 -fi - -## Create SSH Keys -if [ ! -f ~/.ssh/id_rsa ]; then - ssh-keygen -fi - -## Setup Remote Access -# if [ ! -f ~/id_rsa.pub ]; then -# cp ~/dotfiles/id_rsa.pub ~/id_rsa.pub -# chmod go+r ~/id_rsa.pub -# fi - -## Setup ZShell Profile -# if [ ! -f ~/.zshrc ]; then -# ln -s ~/dotfiles/zshrc ~/.zshrc -# fi -# if [ ! -f ~/dotfiles/antigen/README.md ]; then -# cd ~/dotfiles;git submodule update --init -# fi - -## Setup Screen -if [ ! -f ~/.screenrc ]; then - sudo apt-get install screen - ln -s ~/dotfiles/screenrc ~/.screenrc -fi - -## Setup Vundle for Vim -if [ ! -d ~/.vim/bundle ]; then - echo "*** Setup Vundle for Vim***" - git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim - - sudo apt-get install vim-gtk3 # For python support - sudo update-alternatives --set editor /usr/bin/vim.gtk3 - sudo update-alternatives --set vim /usr/bin/vim.gtk3 - sudo update-alternatives --set vi /usr/bin/vim.gtk3 - - vim +BundleInstall +qall - -fi - -# Vim-Plu -curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim diff --git a/bootstrap_pi.sh b/bootstrap_pi.sh deleted file mode 100755 index 145fbce..0000000 --- a/bootstrap_pi.sh +++ /dev/null @@ -1,79 +0,0 @@ -# Reminder to future self: -# Step 0: git clone https://github.com/edthedev/dotfiles -# Step 1: Run this bootstrap script. - -echo "Git, vi are already installed." - -mkdir -p ~/.installed - -if [ ! -d ~/dotfiles ]; then - echo "************** Setup Git and Vim" - sudo apt-get install git vim-nox - cd ~; git clone git@github.com:edthedev/dotfiles.git -fi - -# sudo apt-get install vim-nox - -if [ ! -f ~/.vimrc ]; then - echo "************** Configure Git and link Vimrc" - git config --global user.email "edward@delaporte.us" - git config --global user.name "Edward Delaporte" - git config --global core.editor /usr/bin/vim - ln -s ~/dotfiles/vimrc ~/.vimrc -fi - -if [ ! -f ~/.installed/i3 ]; then - echo "************** Install i3 Window Manager" - sudo apt-get install i3 - touch ~/.installed/i3 -fi - -## Setup PowerShell -if [ ! -f ~/.config/powershell/Microsoft.PowerShell_profile.ps1 ]; then - echo "************** Install PowerShell and setup profile" - sudo apt-get install powershell - chsh --shell /usr/bin/pwsh - mkdir -p ~/.config/powershell/ - ln -s ~/dotfiles/Microsoft.PowerShell_profile.ps1 ~/.config/powershell/Microsoft.PowerShell_profile.ps1 -fi - -## Create SSH Keys -if [ ! -f ~/.ssh/id_rsa ]; then - echo "************** Generate an SSH key" - ssh-keygen -fi - -## Setup Remote Access -# if [ ! -f ~/id_rsa.pub ]; then -# cp ~/dotfiles/id_rsa.pub ~/id_rsa.pub -# chmod go+r ~/id_rsa.pub -# fi - -## Setup Screen -if [ ! -f ~/.screenrc ]; then - echo "************** Install Screen" - sudo apt-get install screen - ln -s ~/dotfiles/screenrc ~/.screenrc -fi - -## Setup Vundle for Vim -if [ ! -d ~/.vim/bundle ]; then - echo "************** Setup Vundle for Vim" - git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim - vim +BundleInstall +qall -fi - -if [ ! -d ~/.installed/code ]; then - echo "************** Install Visual Studio Code" - # sudo apt install snapd - # sudo snap install --classic code - wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O - | sudo apt-key add - - curl -L https://raw.githubusercontent.com/headmelted/codebuilds/master/docs/installers/apt.sh | sudo bash - touch ~/.installed/code -fi - -echo "https://github.com/settings/keys" -echo "vim .git/config -- add: url = git@github.com:edthedev/dotfiles.git" -cat ~/.ssh/id_rsa.pub - -ls -al ~/.installed diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..97e94a8 --- /dev/null +++ b/install.sh @@ -0,0 +1,30 @@ +# Reminder to future self: +# Step 0: git clone https://github.com/edthedev/dotfiles +# Step 1: Run this bootstrap script. + +mkdir -p ~/.installed + +if [ ! -d ~/dotfiles ]; then + echo "************** Install Git" + sudo apt-get install -y git +fi + +if [ ! -f ~/.vimrc ]; then + echo "************** Install Vim" + sudo apt-get install -y vim-nox +fi + +if [ ! -f ~/.config/powershell/Microsoft.PowerShell_profile.ps1 ]; then + echo "************** Install PowerShell" + sudo apt-get install -y powershell +fi + +if [ ! -f ~/.screenrc ]; then + echo "************** Install Screen" + sudo apt-get install -y screen +fi + +echo "Installed:" +ls -al ~/.installed +echo "Setup Options:" +ls -al ~/setup diff --git a/install/code.sh b/install/code.sh new file mode 100644 index 0000000..93a0e58 --- /dev/null +++ b/install/code.sh @@ -0,0 +1,8 @@ +if [ ! -d ~/.installed/code ]; then + echo "************** Install Visual Studio Code" + # sudo apt install snapd + # sudo snap install --classic code + wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O - | sudo apt-key add - + curl -L https://raw.githubusercontent.com/headmelted/codebuilds/master/docs/installers/apt.sh | sudo bash + touch ~/.installed/code +fi diff --git a/install/admin/favorite-ps-modules.ps1 b/install/favorite-ps-modules.ps1 similarity index 75% rename from install/admin/favorite-ps-modules.ps1 rename to install/favorite-ps-modules.ps1 index ea7faa1..214fc33 100644 --- a/install/admin/favorite-ps-modules.ps1 +++ b/install/favorite-ps-modules.ps1 @@ -3,5 +3,4 @@ Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted # Install nice Git stuff. -Install-Module -Name posh-git -o \ No newline at end of file +Install-Module -Name posh-git \ No newline at end of file diff --git a/install/geek-life_pi.sh b/install/geek-life_pi.sh new file mode 100755 index 0000000..f1b80e2 --- /dev/null +++ b/install/geek-life_pi.sh @@ -0,0 +1,5 @@ + +if [ ! -f /usr/bin/geek-life ]; then + wget https://github.com/ajaxray/geek-life/releases/download/v0.1.1/geek-life_linux-arm64 -O /usr/bin/geek-life + chmod uo+x /usr/bin/geek-life +fi diff --git a/install/i3.sh b/install/i3.sh new file mode 100644 index 0000000..84df46c --- /dev/null +++ b/install/i3.sh @@ -0,0 +1,5 @@ +if [ ! -f ~/.installed/i3 ]; then + echo "************** Install i3 Window Manager" + sudo apt-get install i3 + touch ~/.installed/i3 +fi diff --git a/install/install-powershell-6-pi.sh b/install/install-powershell-6-pi.sh deleted file mode 100755 index 1a2e2a4..0000000 --- a/install/install-powershell-6-pi.sh +++ /dev/null @@ -1,19 +0,0 @@ -echo "Install PowerShell 6.2.0" - -if [ ! -d /opt/powershell ]; then - -cd /tmp -wget https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/powershell-6.2.0-linux-arm32.tar.gz -mkdir /opt/powershell -tar -xvf ./powershell-6.2.0-linux-arm32.tar.gz -C /opt/powershell - -echo "PowerShell is now at /opt/powershell/pswsh" -echo "Remember to update your path." - -fi - -ln -s /opt/powershell/pwsh /usr/bin/pwsh -ls /usr/bin/pwsh -alis -chmod 755 -R /opt/powershell/pwsh -rm /opt/powershell/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY - diff --git a/install/powershell.sh b/install/powershell.sh new file mode 100755 index 0000000..038e76a --- /dev/null +++ b/install/powershell.sh @@ -0,0 +1,4 @@ +if [ ! -f ~/.config/powershell/Microsoft.PowerShell_profile.ps1 ]; then + echo "************** Install PowerShell" + sudo apt-get install powershell +fi \ No newline at end of file diff --git a/install/powershell7_pi.sh b/install/powershell7_pi.sh new file mode 100755 index 0000000..a16016a --- /dev/null +++ b/install/powershell7_pi.sh @@ -0,0 +1,34 @@ + +## https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1#raspbian + + +################################### +# Prerequisites + +# Update package lists +sudo apt-get update + +# Install libunwind8 and libssl1.0 +# Regex is used to ensure that we do not install libssl1.0-dev, as it is a variant that is not required +sudo apt-get install '^libssl1.0.[0-9]$' libunwind8 -y + +################################### +# Download and extract PowerShell + +# Grab the latest tar.gz +if [ ! -f /tmp/powershell.tar.gz ]; then + wget https://github.com/PowerShell/PowerShell/releases/download/v7.1.2/powershell-7.1.2-linux-arm32.tar.gz -O /tmp/powershell.tar.gz +fi + +# Make folder to put powershell +mkdir -p /opt +mkdir -p /opt/powershell + +# Unpack the tar.gz file +tar -xvf /tmp/powershell.tar.gz -C /opt/powershell/ + +# Link the shell to the usual place to find it. +ln -s /opt/powershell/pwsh /usr/bin/pwsh +echo "/usr/bin/pwsh" >> /etc/shells + +echo "PowerShell should now be installed. See ./setup/powershell.sh for how to chagne shells." diff --git a/install/install-vscode-journal.sh b/install/vscode-journal.sh old mode 100755 new mode 100644 similarity index 100% rename from install/install-vscode-journal.sh rename to install/vscode-journal.sh diff --git a/install/wtfutil_pi.sh b/install/wtfutil_pi.sh new file mode 100755 index 0000000..1647b77 --- /dev/null +++ b/install/wtfutil_pi.sh @@ -0,0 +1,7 @@ + +if [ ! -f /usr/bin/wtfutil ]; then + cd /tmp + wget https://github.com/wtfutil/wtf/releases/download/v0.35.0/wtf_0.35.0_linux_armv6.tar.gz + tar -xzf /wtf_0.35.0_linux_armv6.tar.gz + mv ./wtfutil /usr/bin/wtfutil +fi diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..ff7b64c --- /dev/null +++ b/setup.sh @@ -0,0 +1,35 @@ +if [ ! -d ~/dotfiles ]; then + echo "************** Cloning Dotfiles Directory" + cd ~; git clone git@github.com:edthedev/dotfiles.git +fi + +if [ ! -f ~/.ssh/id_rsa ]; then + echo "************** Generate an SSH key" + ssh-keygen +fi + +if [ ! -f ~/.screenrc ]; then + echo "************** Setup Screen" + ln -s ~/dotfiles/screenrc ~/.screenrc +fi + +if [ ! -f ~/.vimrc ]; then + echo "************** Link Vimrc" + ln -s ~/dotfiles/vimrc ~/.vimrc +fi + +if [ -f ~/.vimrc ]; then + echo "************** Configure Git to use Vim" + git config --global core.editor /usr/bin/vim +fi + +if [ -f ~/.gitconfig ]; then + echo "************** Configure Git user" + git config --global user.email "edward@delaporte.us" + git config --global user.name "Edward Delaporte" +fi + +echo "************** Reminder to setup GitHub key" +echo "https://github.com/settings/keys" +echo "vim .git/config -- add: url = git@github.com:edthedev/dotfiles.git" +cat ~/.ssh/id_rsa.pub diff --git a/setup/minion.sh b/setup/minion.sh new file mode 100755 index 0000000..637a0aa --- /dev/null +++ b/setup/minion.sh @@ -0,0 +1,4 @@ +if [ ! -d ~/minion ]; then + cd ~ + git clone git@github.com:/edthedev/minion.git +fi diff --git a/setup/powershell.ps1 b/setup/powershell.ps1 old mode 100644 new mode 100755 index 6986211..6dffb0f --- a/setup/powershell.ps1 +++ b/setup/powershell.ps1 @@ -1,8 +1,3 @@ Write-Host "Require remote scripts to be signed." Set-ExecutionPolicy RemoteSigned - -Write-Host "Show file extensions for known types" -Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Set-ItemProperty . HideFileExt "0" -Set-Location C:\ - +Install-Module posh-git diff --git a/setup/powershell.sh b/setup/powershell.sh new file mode 100755 index 0000000..6b87324 --- /dev/null +++ b/setup/powershell.sh @@ -0,0 +1,8 @@ +if [ ! -f ~/.config/powershell/Microsoft.PowerShell_profile.ps1 ]; then + echo "************** Link PowerShell profile" + chsh --shell /usr/bin/pwsh + mkdir -p ~/.config/powershell/ + ln -s ~/dotfiles/Microsoft.PowerShell_profile.ps1 ~/.config/powershell/Microsoft.PowerShell_profile.ps1 +fi + +chsh --shell /usr/bin/pwsh diff --git a/setup/show-hidden-files.ps1 b/setup/show-hidden-files.ps1 new file mode 100644 index 0000000..785d25c --- /dev/null +++ b/setup/show-hidden-files.ps1 @@ -0,0 +1,5 @@ + +Write-Host "Show file extensions for known types" +Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced +Set-ItemProperty . HideFileExt "0" +Set-Location C:\ \ No newline at end of file diff --git a/setup/vim.ps1 b/setup/vim.ps1 old mode 100644 new mode 100755 diff --git a/setup/vundle.sh b/setup/vundle.sh new file mode 100644 index 0000000..ccdfe91 --- /dev/null +++ b/setup/vundle.sh @@ -0,0 +1,6 @@ +## Setup Vundle for Vim +if [ ! -d ~/.vim/bundle ]; then + echo "************** Setup Vundle for Vim" + git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim + vim +BundleInstall +qall +fi diff --git a/psmodules/Teams2Markdown.psd1 b/win_psmodules/Teams2Markdown.psd1 similarity index 100% rename from psmodules/Teams2Markdown.psd1 rename to win_psmodules/Teams2Markdown.psd1 diff --git a/psmodules/Teams2Markdown.psm1 b/win_psmodules/Teams2Markdown.psm1 similarity index 100% rename from psmodules/Teams2Markdown.psm1 rename to win_psmodules/Teams2Markdown.psm1