From 97650ac058826e43fa96b8b8edde14ab6247a688 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 09:15:37 +0100 Subject: [PATCH 1/8] Import posh-git in PS profile --- windows/profile.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/windows/profile.ps1 b/windows/profile.ps1 index 1a974e1..5f57560 100644 --- a/windows/profile.ps1 +++ b/windows/profile.ps1 @@ -3,3 +3,5 @@ Get-Content -Path "$env:USERPROFILE\dotfiles\windows\aliases.ps1" -Raw | Invoke-Expression Clear-Host + +Import-Module posh-git -- 2.54.0 From 1db9aae5fdffb559d41fdeb4c73430c5532595cc Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 09:23:03 +0100 Subject: [PATCH 2/8] Add gitattributes file --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f291cc0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text eol=lf +*.ps1 text eol=crlf +*.bat text eol=crlf +*.cmd text eol=crlf -- 2.54.0 From f2477d5c16c4ad4357f678c6f1df2d8b2caad6be Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 09:25:34 +0100 Subject: [PATCH 3/8] Normalize line endings --- bin/lockify | 0 bin/scrotify | 0 config/compton.conf | 466 ++++++++++++++++++++-------------------- i3blocks/sharp-batt.rb | 0 i3blocks/sharp-music.rb | 0 i3blocks/sharp-wifi.rb | 0 6 files changed, 233 insertions(+), 233 deletions(-) mode change 100755 => 100644 bin/lockify mode change 100755 => 100644 bin/scrotify mode change 100755 => 100644 i3blocks/sharp-batt.rb mode change 100755 => 100644 i3blocks/sharp-music.rb mode change 100755 => 100644 i3blocks/sharp-wifi.rb diff --git a/bin/lockify b/bin/lockify old mode 100755 new mode 100644 diff --git a/bin/scrotify b/bin/scrotify old mode 100755 new mode 100644 diff --git a/config/compton.conf b/config/compton.conf index d568a09..67d3a79 100644 --- a/config/compton.conf +++ b/config/compton.conf @@ -1,233 +1,233 @@ -# Thank you code_nomad: http://9m.no/ꪯ鵞 - -################################# -# -# Backend -# -################################# - -# Backend to use: "xrender" or "glx". -# GLX backend is typically much faster but depends on a sane driver. -backend = "glx"; - -################################# -# -# GLX backend -# -################################# - -glx-no-stencil = true; - -# GLX backend: Copy unmodified regions from front buffer instead of redrawing them all. -# My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified, -# but a 20% increase when only 1/4 is. -# My tests on nouveau show terrible slowdown. -# Useful with --glx-swap-method, as well. -glx-copy-from-front = false; - -# GLX backend: Use MESA_copy_sub_buffer to do partial screen update. -# My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated. -# May break VSync and is not available on some drivers. -# Overrides --glx-copy-from-front. -# glx-use-copysubbuffermesa = true; - -# GLX backend: Avoid rebinding pixmap on window damage. -# Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe). -# Recommended if it works. -glx-no-rebind-pixmap = true; - - -# GLX backend: GLX buffer swap method we assume. -# Could be undefined (0), copy (1), exchange (2), 3-6, or buffer-age (-1). -# undefined is the slowest and the safest, and the default value. -# copy is fastest, but may fail on some drivers, -# 2-6 are gradually slower but safer (6 is still faster than 0). -# Usually, double buffer means 2, triple buffer means 3. -# buffer-age means auto-detect using GLX_EXT_buffer_age, supported by some drivers. -# Useless with --glx-use-copysubbuffermesa. -# Partially breaks --resize-damage. -# Defaults to undefined. -glx-swap-method = "undefined"; - -################################# -# -# Shadows -# -################################# - -# Enabled client-side shadows on windows. -shadow = false; -# Don't draw shadows on DND windows. -no-dnd-shadow = true; -# Avoid drawing shadows on dock/panel windows. -no-dock-shadow = true; -# Zero the part of the shadow's mask behind the window. Fix some weirdness with ARGB windows. -clear-shadow = true; -# The blur radius for shadows. (default 12) -shadow-radius = 5; -# The left offset for shadows. (default -15) -shadow-offset-x = -5; -# The top offset for shadows. (default -15) -shadow-offset-y = -5; -# The translucency for shadows. (default .75) -shadow-opacity = 0.5; - -# Set if you want different colour shadows -# shadow-red = 0.0; -# shadow-green = 0.0; -# shadow-blue = 0.0; - -# The shadow exclude options are helpful if you have shadows enabled. Due to the way compton draws its shadows, certain applications will have visual glitches -# (most applications are fine, only apps that do weird things with xshapes or argb are affected). -# This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher. -shadow-exclude = [ - "! name~=''", - "name = 'Notification'", - "name = 'Plank'", - "name = 'Docky'", - "name = 'Kupfer'", - "name = 'xfce4-notifyd'", - "name *= 'VLC'", - "name *= 'compton'", - "name *= 'Chromium'", - "name *= 'Chrome'", - "class_g = 'Conky'", - "class_g = 'Kupfer'", - "class_g = 'Synapse'", - "class_g ?= 'Notify-osd'", - "class_g ?= 'Cairo-dock'", - "class_g ?= 'Xfce4-notifyd'", - "class_g ?= 'Xfce4-power-manager'", - "_GTK_FRAME_EXTENTS@:c" -]; -# Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners) -shadow-ignore-shaped = false; - -################################# -# -# Opacity -# -################################# - -menu-opacity = 1; -inactive-opacity = 1; -active-opacity = 1; -frame-opacity = 1; -inactive-opacity-override = false; -alpha-step = 0.06; - -# Dim inactive windows. (0.0 - 1.0) -# inactive-dim = 0.2; -# Do not let dimness adjust based on window opacity. -# inactive-dim-fixed = true; -# Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred. -# blur-background = true; -# Blur background of opaque windows with transparent frames as well. -# blur-background-frame = true; -# Do not let blur radius adjust based on window opacity. -blur-background-fixed = false; -blur-background-exclude = [ - "window_type = 'dock'", - "window_type = 'desktop'" -]; - -################################# -# -# Fading -# -################################# - -# Fade windows during opacity changes. -fading = false; -# The time between steps in a fade in milliseconds. (default 10). -fade-delta = 1; -# Opacity change between steps while fading in. (default 0.028). -fade-in-step = 0.03; -# Opacity change between steps while fading out. (default 0.03). -fade-out-step = 0.03; -# Fade windows in/out when opening/closing -# no-fading-openclose = true; - -# Specify a list of conditions of windows that should not be faded. -fade-exclude = [ ]; - -################################# -# -# Other -# -################################# - -# Try to detect WM windows and mark them as active. -mark-wmwin-focused = true; -# Mark all non-WM but override-redirect windows active (e.g. menus). -mark-ovredir-focused = true; -# Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events. -# Usually more reliable but depends on a EWMH-compliant WM. -use-ewmh-active-win = true; -# Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on. -detect-rounded-corners = true; - -# Detect _NET_WM_OPACITY on client windows, useful for window managers not passing _NET_WM_OPACITY of client windows to frame windows. -# This prevents opacity being ignored for some apps. -# For example without this enabled my xfce4-notifyd is 100% opacity no matter what. -detect-client-opacity = true; - -# Specify refresh rate of the screen. -# If not specified or 0, compton will try detecting this with X RandR extension. -refresh-rate = 0; - -# Set VSync method. VSync methods currently available: -# none: No VSync -# drm: VSync with DRM_IOCTL_WAIT_VBLANK. May only work on some drivers. -# opengl: Try to VSync with SGI_video_sync OpenGL extension. Only work on some drivers. -# opengl-oml: Try to VSync with OML_sync_control OpenGL extension. Only work on some drivers. -# opengl-swc: Try to VSync with SGI_swap_control OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn’t have the effect of --sw-opti unlike other methods. Experimental. -# opengl-mswc: Try to VSync with MESA_swap_control OpenGL extension. Basically the same as opengl-swc above, except the extension we use. -# (Note some VSync methods may not be enabled at compile time.) -vsync = "opengl-swc"; - -# Enable DBE painting mode, intended to use with VSync to (hopefully) eliminate tearing. -# Reported to have no effect, though. -dbe = false; -# Painting on X Composite overlay window. Recommended. -paint-on-overlay = true; - -# Limit compton to repaint at most once every 1 / refresh_rate second to boost performance. -# This should not be used with --vsync drm/opengl/opengl-oml as they essentially does --sw-opti's job already, -# unless you wish to specify a lower refresh rate than the actual value. -sw-opti = true; - -# Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games. -# Known to cause flickering when redirecting/unredirecting windows. -# paint-on-overlay may make the flickering less obvious. -unredir-if-possible = true; - -# Specify a list of conditions of windows that should always be considered focused. -focus-exclude = [ ]; - -# Use WM_TRANSIENT_FOR to group windows, and consider windows in the same group focused at the same time. -detect-transient = true; -# Use WM_CLIENT_LEADER to group windows, and consider windows in the same group focused at the same time. -# WM_TRANSIENT_FOR has higher priority if --detect-transient is enabled, too. -detect-client-leader = true; - -################################# -# -# Window type settings -# -################################# - -wintypes: -{ - tooltip = - { - # fade: Fade the particular type of windows. - fade = true; - # shadow: Give those windows shadow - shadow = false; - # opacity: Default opacity for the type of windows. - opacity = 0.85; - # focus: Whether to always consider windows of this type focused. - focus = true; - }; -}; +# Thank you code_nomad: http://9m.no/ꪯ鵞 + +################################# +# +# Backend +# +################################# + +# Backend to use: "xrender" or "glx". +# GLX backend is typically much faster but depends on a sane driver. +backend = "glx"; + +################################# +# +# GLX backend +# +################################# + +glx-no-stencil = true; + +# GLX backend: Copy unmodified regions from front buffer instead of redrawing them all. +# My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified, +# but a 20% increase when only 1/4 is. +# My tests on nouveau show terrible slowdown. +# Useful with --glx-swap-method, as well. +glx-copy-from-front = false; + +# GLX backend: Use MESA_copy_sub_buffer to do partial screen update. +# My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated. +# May break VSync and is not available on some drivers. +# Overrides --glx-copy-from-front. +# glx-use-copysubbuffermesa = true; + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe). +# Recommended if it works. +glx-no-rebind-pixmap = true; + + +# GLX backend: GLX buffer swap method we assume. +# Could be undefined (0), copy (1), exchange (2), 3-6, or buffer-age (-1). +# undefined is the slowest and the safest, and the default value. +# copy is fastest, but may fail on some drivers, +# 2-6 are gradually slower but safer (6 is still faster than 0). +# Usually, double buffer means 2, triple buffer means 3. +# buffer-age means auto-detect using GLX_EXT_buffer_age, supported by some drivers. +# Useless with --glx-use-copysubbuffermesa. +# Partially breaks --resize-damage. +# Defaults to undefined. +glx-swap-method = "undefined"; + +################################# +# +# Shadows +# +################################# + +# Enabled client-side shadows on windows. +shadow = false; +# Don't draw shadows on DND windows. +no-dnd-shadow = true; +# Avoid drawing shadows on dock/panel windows. +no-dock-shadow = true; +# Zero the part of the shadow's mask behind the window. Fix some weirdness with ARGB windows. +clear-shadow = true; +# The blur radius for shadows. (default 12) +shadow-radius = 5; +# The left offset for shadows. (default -15) +shadow-offset-x = -5; +# The top offset for shadows. (default -15) +shadow-offset-y = -5; +# The translucency for shadows. (default .75) +shadow-opacity = 0.5; + +# Set if you want different colour shadows +# shadow-red = 0.0; +# shadow-green = 0.0; +# shadow-blue = 0.0; + +# The shadow exclude options are helpful if you have shadows enabled. Due to the way compton draws its shadows, certain applications will have visual glitches +# (most applications are fine, only apps that do weird things with xshapes or argb are affected). +# This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher. +shadow-exclude = [ + "! name~=''", + "name = 'Notification'", + "name = 'Plank'", + "name = 'Docky'", + "name = 'Kupfer'", + "name = 'xfce4-notifyd'", + "name *= 'VLC'", + "name *= 'compton'", + "name *= 'Chromium'", + "name *= 'Chrome'", + "class_g = 'Conky'", + "class_g = 'Kupfer'", + "class_g = 'Synapse'", + "class_g ?= 'Notify-osd'", + "class_g ?= 'Cairo-dock'", + "class_g ?= 'Xfce4-notifyd'", + "class_g ?= 'Xfce4-power-manager'", + "_GTK_FRAME_EXTENTS@:c" +]; +# Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners) +shadow-ignore-shaped = false; + +################################# +# +# Opacity +# +################################# + +menu-opacity = 1; +inactive-opacity = 1; +active-opacity = 1; +frame-opacity = 1; +inactive-opacity-override = false; +alpha-step = 0.06; + +# Dim inactive windows. (0.0 - 1.0) +# inactive-dim = 0.2; +# Do not let dimness adjust based on window opacity. +# inactive-dim-fixed = true; +# Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred. +# blur-background = true; +# Blur background of opaque windows with transparent frames as well. +# blur-background-frame = true; +# Do not let blur radius adjust based on window opacity. +blur-background-fixed = false; +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'" +]; + +################################# +# +# Fading +# +################################# + +# Fade windows during opacity changes. +fading = false; +# The time between steps in a fade in milliseconds. (default 10). +fade-delta = 1; +# Opacity change between steps while fading in. (default 0.028). +fade-in-step = 0.03; +# Opacity change between steps while fading out. (default 0.03). +fade-out-step = 0.03; +# Fade windows in/out when opening/closing +# no-fading-openclose = true; + +# Specify a list of conditions of windows that should not be faded. +fade-exclude = [ ]; + +################################# +# +# Other +# +################################# + +# Try to detect WM windows and mark them as active. +mark-wmwin-focused = true; +# Mark all non-WM but override-redirect windows active (e.g. menus). +mark-ovredir-focused = true; +# Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events. +# Usually more reliable but depends on a EWMH-compliant WM. +use-ewmh-active-win = true; +# Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on. +detect-rounded-corners = true; + +# Detect _NET_WM_OPACITY on client windows, useful for window managers not passing _NET_WM_OPACITY of client windows to frame windows. +# This prevents opacity being ignored for some apps. +# For example without this enabled my xfce4-notifyd is 100% opacity no matter what. +detect-client-opacity = true; + +# Specify refresh rate of the screen. +# If not specified or 0, compton will try detecting this with X RandR extension. +refresh-rate = 0; + +# Set VSync method. VSync methods currently available: +# none: No VSync +# drm: VSync with DRM_IOCTL_WAIT_VBLANK. May only work on some drivers. +# opengl: Try to VSync with SGI_video_sync OpenGL extension. Only work on some drivers. +# opengl-oml: Try to VSync with OML_sync_control OpenGL extension. Only work on some drivers. +# opengl-swc: Try to VSync with SGI_swap_control OpenGL extension. Only work on some drivers. Works only with GLX backend. Known to be most effective on many drivers. Does not actually control paint timing, only buffer swap is affected, so it doesn’t have the effect of --sw-opti unlike other methods. Experimental. +# opengl-mswc: Try to VSync with MESA_swap_control OpenGL extension. Basically the same as opengl-swc above, except the extension we use. +# (Note some VSync methods may not be enabled at compile time.) +vsync = "opengl-swc"; + +# Enable DBE painting mode, intended to use with VSync to (hopefully) eliminate tearing. +# Reported to have no effect, though. +dbe = false; +# Painting on X Composite overlay window. Recommended. +paint-on-overlay = true; + +# Limit compton to repaint at most once every 1 / refresh_rate second to boost performance. +# This should not be used with --vsync drm/opengl/opengl-oml as they essentially does --sw-opti's job already, +# unless you wish to specify a lower refresh rate than the actual value. +sw-opti = true; + +# Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games. +# Known to cause flickering when redirecting/unredirecting windows. +# paint-on-overlay may make the flickering less obvious. +unredir-if-possible = true; + +# Specify a list of conditions of windows that should always be considered focused. +focus-exclude = [ ]; + +# Use WM_TRANSIENT_FOR to group windows, and consider windows in the same group focused at the same time. +detect-transient = true; +# Use WM_CLIENT_LEADER to group windows, and consider windows in the same group focused at the same time. +# WM_TRANSIENT_FOR has higher priority if --detect-transient is enabled, too. +detect-client-leader = true; + +################################# +# +# Window type settings +# +################################# + +wintypes: +{ + tooltip = + { + # fade: Fade the particular type of windows. + fade = true; + # shadow: Give those windows shadow + shadow = false; + # opacity: Default opacity for the type of windows. + opacity = 0.85; + # focus: Whether to always consider windows of this type focused. + focus = true; + }; +}; diff --git a/i3blocks/sharp-batt.rb b/i3blocks/sharp-batt.rb old mode 100755 new mode 100644 diff --git a/i3blocks/sharp-music.rb b/i3blocks/sharp-music.rb old mode 100755 new mode 100644 diff --git a/i3blocks/sharp-wifi.rb b/i3blocks/sharp-wifi.rb old mode 100755 new mode 100644 -- 2.54.0 From 057a55f561aea858b1dec530e5fd9dbe67315d95 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 09:40:46 +0100 Subject: [PATCH 4/8] Improve powershell scripts --- windows/aliases.ps1 | 4 ++ windows/profile.ps1 | 43 ++++++++------- windows/ssh-agent-utils.ps1 | 102 ++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 19 deletions(-) create mode 100644 windows/ssh-agent-utils.ps1 diff --git a/windows/aliases.ps1 b/windows/aliases.ps1 index 443180d..a78c489 100644 --- a/windows/aliases.ps1 +++ b/windows/aliases.ps1 @@ -3,3 +3,7 @@ } New-Alias Cake .\build.ps1 + +New-Alias ssh "$env:PROGRAMFILES\Git\usr\bin\ssh.exe" +New-Alias ssh-agent "$env:PROGRAMFILES\Git\usr\bin\ssh-agent.exe" +New-Alias ssh-add "$env:PROGRAMFILES\Git\usr\bin\ssh-add.exe" diff --git a/windows/profile.ps1 b/windows/profile.ps1 index 195d3f1..1528485 100644 --- a/windows/profile.ps1 +++ b/windows/profile.ps1 @@ -1,62 +1,67 @@ # Available colors -# DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow |DarkGray +# DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow |DarkGray # Blue | Green | Cyan | Red | Magenta | Yellow | White | Gray | Black -[console]::BackgroundColor = "DarkGray" +$background = 'Black' + +[console]::BackgroundColor = $background # Main Colors $host.UI.RawUI.ForegroundColor = 'White' -$host.UI.RawUI.BackgroundColor = 'DarkGray' +$host.UI.RawUI.BackgroundColor = $background # Error, warning and debug colors $host.PrivateData.ErrorForegroundColor = 'Red' -$host.PrivateData.ErrorBackgroundColor = 'DarkGray' +$host.PrivateData.ErrorBackgroundColor = $background $host.PrivateData.WarningForegroundColor = 'Yellow' -$host.PrivateData.WarningBackgroundColor = 'DarkGray' +$host.PrivateData.WarningBackgroundColor = $background $host.PrivateData.DebugForegroundColor = 'Gray' -$host.PrivateData.DebugBackgroundColor = 'DarkGray' +$host.PrivateData.DebugBackgroundColor = $background $host.PrivateData.VerboseForegroundColor = 'Gray' -$host.PrivateData.VerboseBackgroundColor = 'DarkGray' +$host.PrivateData.VerboseBackgroundColor = $background $host.PrivateData.ProgressForegroundColor = 'Gray' -$host.PrivateData.ProgressBackgroundColor = 'DarkGray' +$host.PrivateData.ProgressBackgroundColor = $background # Syntax coloring and highlighting Set-PSReadlineOption -TokenKind Comment -ForegroundColor Gray -Set-PSReadlineOption -TokenKind Comment -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Comment -BackgroundColor $background Set-PSReadlineOption -TokenKind Keyword -ForegroundColor DarkGreen -Set-PSReadlineOption -TokenKind Keyword -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Keyword -BackgroundColor $background Set-PSReadlineOption -TokenKind String -ForegroundColor Gray -Set-PSReadlineOption -TokenKind String -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind String -BackgroundColor $background Set-PSReadlineOption -TokenKind Operator -ForegroundColor White -Set-PSReadlineOption -TokenKind Operator -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Operator -BackgroundColor $background Set-PSReadlineOption -TokenKind Variable -ForegroundColor Green -Set-PSReadlineOption -TokenKind Variable -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Variable -BackgroundColor $background Set-PSReadlineOption -TokenKind Command -ForegroundColor White -Set-PSReadlineOption -TokenKind Command -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Command -BackgroundColor $background Set-PSReadlineOption -TokenKind Parameter -ForegroundColor White -Set-PSReadlineOption -TokenKind Parameter -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Parameter -BackgroundColor $background Set-PSReadlineOption -TokenKind Type -ForegroundColor Cyan -Set-PSReadlineOption -TokenKind Type -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Type -BackgroundColor $background Set-PSReadlineOption -TokenKind Number -ForegroundColor Magenta -Set-PSReadlineOption -TokenKind Number -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Number -BackgroundColor $background Set-PSReadlineOption -TokenKind Member -ForegroundColor Cyan -Set-PSReadlineOption -TokenKind Member -BackgroundColor DarkGray +Set-PSReadlineOption -TokenKind Member -BackgroundColor $background + +Clear-Host Get-Content -Path "$env:USERPROFILE\dotfiles\windows\aliases.ps1" -Raw | Invoke-Expression -Clear-Host +Unblock-File -Path ~/dotfiles/windows/ssh-agent-utils.ps1 +. (Resolve-Path ~/dotfiles/windows/ssh-agent-utils.ps1) Import-Module posh-git diff --git a/windows/ssh-agent-utils.ps1 b/windows/ssh-agent-utils.ps1 new file mode 100644 index 0000000..0ccf27c --- /dev/null +++ b/windows/ssh-agent-utils.ps1 @@ -0,0 +1,102 @@ +# SSH Agent Functions +# Mark Embling (http://www.markembling.info/) +# +# How to use: +# - Place this file into %USERPROFILE%\Documents\WindowsPowershell (or location of choice) +# - Import into your profile.ps1: +# e.g. ". (Resolve-Path ~/Documents/WindowsPowershell/ssh-agent-utils.ps1)" [without quotes] +# - Enjoy +# +# Note: ensure you have ssh and ssh-agent available on your path, from Git's Unix tools or Cygwin. + +# Retrieve the current SSH agent PId (or zero). Can be used to determine if there +# is an agent already starting. +function Get-SshAgent() { + $agentPid = [Environment]::GetEnvironmentVariable("SSH_AGENT_PID", "User") + if ([int]$agentPid -eq 0) { + $agentPid = [Environment]::GetEnvironmentVariable("SSH_AGENT_PID", "Process") + } + + if ([int]$agentPid -eq 0) { + 0 + } else { + # Make sure the process is actually running + $process = Get-Process -Id $agentPid -ErrorAction SilentlyContinue + + if(($process -eq $null) -or ($process.ProcessName -ne "ssh-agent")) { + # It is not running (this is an error). Remove env vars and return 0 for no agent. + [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "Process") + [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "User") + [Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", $null, "Process") + [Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", $null, "User") + 0 + } else { + # It is running. Return the PID. + $agentPid + } + } +} + +# Start the SSH agent. +function Start-SshAgent() { + # Start the agent and gather its feedback info + [string]$output = ssh-agent + + $lines = $output.Split(";") + $agentPid = 0 + + foreach ($line in $lines) { + if (([string]$line).Trim() -match "(.+)=(.*)") { + # Set environment variables for user and current process. + [Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process") + [Environment]::SetEnvironmentVariable($matches[1], $matches[2], "User") + + if ($matches[1] -eq "SSH_AGENT_PID") { + $agentPid = $matches[2] + } + } + } + + # Show the agent's PID as expected. + Write-Host "SSH agent PID:", $agentPid +} + +# Stop a running SSH agent +function Stop-SshAgent() { + [int]$agentPid = Get-SshAgent + if ([int]$agentPid -gt 0) { + # Stop agent process + $proc = Get-Process -Id $agentPid + if ($proc -ne $null) { + Stop-Process $agentPid + } + + # Remove all enviroment variables + [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "Process") + [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "User") + [Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", $null, "Process") + [Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", $null, "User") + } +} + +# Add a key to the SSH agent +function Add-SshKey() { + if ($args.Count -eq 0) { + # Add the default key (~/id_rsa) + ssh-add + } else { + foreach ($value in $args) { + ssh-add $value + } + } +} + +# Start the agent if not already running; provide feedback +$agent = Get-SshAgent +if ($agent -eq 0) { + Write-Host "Starting SSH agent..." + Start-SshAgent # Start agent + Add-SshKey # Add my default key +} else { + Write-Host "SSH agent is running (PID $agent)" +} \ No newline at end of file -- 2.54.0 From 777c62d52d8666bddc2c28b08d598fe80c87f4d3 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 11:34:26 +0100 Subject: [PATCH 5/8] Upate zshrc to work well on WSL --- zshrc | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/zshrc b/zshrc index ecb38f2..51598b8 100644 --- a/zshrc +++ b/zshrc @@ -1,6 +1,12 @@ typeset -U path -path=($HOME/bin $HOME/.local/bin $path) +path=($HOME/bin $HOME/.local/bin /usr/lib/go-1.8/bin $path) + +if [ "$(hostname)" = 'PC490' ]; +then + echo '[WSL] Disabling setting priotiy on background processes' + unsetopt BG_NICE +fi export ZSH_TMUX_AUTOSTART=false export ZSH_TMUX_AUTOSTART_ONCE=true @@ -32,7 +38,11 @@ zplug "plugins/tmuxinator", from:oh-my-zsh zplug "zsh-users/zsh-syntax-highlighting", defer:2 zplug "mafredri/zsh-async" -zplug "sindresorhus/pure", use:pure.zsh, from:github, as:theme + +if [ "$(hostname)" != 'PC490' ]; +then + zplug "sindresorhus/pure", use:pure.zsh, from:github, as:theme +fi zplug "simonwhitaker/gibo", use:/, hook-build:"ln -fs gibo-completion.zsh _gibo" @@ -77,8 +87,11 @@ if [ $? -eq 0 ]; then export $(gnome-keyring-daemon --start) fi -eval "$(thefuck --alias)" -eval "$(hub alias -s)" +if [ "$(hostname)" != 'PC490' ]; +then + eval "$(thefuck --alias)" + eval "$(hub alias -s)" +fi eval "$(rbenv init -)" if [[ -d "$HOME/.pyenv/" ]]; then @@ -88,6 +101,13 @@ if [[ -d "$HOME/.pyenv/" ]]; then eval "$(pyenv virtualenv-init -)" fi +if [ "$(hostname)" = 'PC490' ]; +then + autoload -Uz promptinit + promptinit + prompt adam1 +fi + alias emacs="TERM=xterm-256color emacs -nw" # Ugly workaround to get SSH working properly in all terminals -- 2.54.0 From 7df75d58b8f4c34d7efb2d66c9098e38a59920a2 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 11:44:24 +0100 Subject: [PATCH 6/8] Load ssh-agent on WSL --- zshrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zshrc b/zshrc index 51598b8..fe2bf01 100644 --- a/zshrc +++ b/zshrc @@ -86,6 +86,15 @@ pgrep gnome-keyring >& /dev/null if [ $? -eq 0 ]; then export $(gnome-keyring-daemon --start) fi +if [ "$(hostname)" = 'PC490' ]; then + if [ -z "$(pgrep ssh-agent)" ]; then + rm -rf /tmp/ssh-* + eval $(ssh-agent -s) > /dev/null + else + export SSH_AGENT_PID=$(pgrep ssh-agent) + export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name 'agent.*') + fi +fi if [ "$(hostname)" != 'PC490' ]; then -- 2.54.0 From 9a1a5c9525370d51d4c96356a865b815069fd14c Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 12:21:48 +0100 Subject: [PATCH 7/8] Add ssh keys on WSL --- zshrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zshrc b/zshrc index fe2bf01..fdee2eb 100644 --- a/zshrc +++ b/zshrc @@ -94,6 +94,9 @@ if [ "$(hostname)" = 'PC490' ]; then export SSH_AGENT_PID=$(pgrep ssh-agent) export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name 'agent.*') fi + if [ "$(ssh-add -l)" == "The agent has no identities." ]; then + ssh-add + fi fi if [ "$(hostname)" != 'PC490' ]; -- 2.54.0 From 5426222d26109d54980b3fef5f1dbe719f17a592 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Mon, 13 Nov 2017 15:18:59 +0100 Subject: [PATCH 8/8] Update cowfortune and fix ssh-add typo --- zshrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zshrc b/zshrc index fdee2eb..4e8646c 100644 --- a/zshrc +++ b/zshrc @@ -94,7 +94,7 @@ if [ "$(hostname)" = 'PC490' ]; then export SSH_AGENT_PID=$(pgrep ssh-agent) export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name 'agent.*') fi - if [ "$(ssh-add -l)" == "The agent has no identities." ]; then + if [ "$(ssh-add -l)" = "The agent has no identities." ]; then ssh-add fi fi @@ -130,7 +130,11 @@ alias mux="tmuxinator" alias sketchup="WINEARCH=win64 WINEPREFIX=~/.sketchup wine start /unix ~/.sketchup/drive_c/Program\ Files/SketchUp/SketchUp\ 2017/SketchUp.exe" cowfortune() { - fortune $@ | cowsay -W 70 + cowargs=('-b' '-d' '-g' '-p' '-s' '-t' '-w' '-y' '') + cowextra=${cowargs[$(($RANDOM % ${#cowargs[@]}))]} + files=($(cowsay -l | tail -n +2)) + cowfile=${files[$((RANDOM % ${#files[@]}))]} + fortune $@ | cowsay -W 70 -f ${cowfile} ${cowextra} } thinkfortune () { -- 2.54.0