summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-05-11 13:49:01 -0500
committerToby Vincent <tobyv13@gmail.com>2021-05-11 13:49:01 -0500
commit472a90047abbaeec80f4c332304017769ab31699 (patch)
treed42ff6141c47647bbc0c795bd321f6601502a2fc
parentb9de0b04f56d7f54ced14231db0599d5adc2bef6 (diff)
refactor: moved posix stuff to shell sourced from zsh
-rw-r--r--shell/aliases.sh10
-rw-r--r--shell/gpg.sh44
-rw-r--r--shell/profile.sh6
-rw-r--r--shell/wsl.sh30
-rw-r--r--zsh/aliases.zsh12
-rw-r--r--zsh/wsl.zsh79
-rw-r--r--zshrc21
7 files changed, 101 insertions, 101 deletions
diff --git a/shell/aliases.sh b/shell/aliases.sh
new file mode 100644
index 0000000..6505a39
--- /dev/null
+++ b/shell/aliases.sh
@@ -0,0 +1,10 @@
+# Aliases
+alias update="sudo apt update && apt list --upgradable"
+alias upgrade="sudo apt upgrade -y"
+alias ipa="ip -s -c -h a"
+alias untar="tar -zxvf "
+alias py=python3
+alias python=python3
+alias pip=pip3
+alias dsh="dce sh"
+alias dps="docker ps"
diff --git a/shell/gpg.sh b/shell/gpg.sh
new file mode 100644
index 0000000..ea87d05
--- /dev/null
+++ b/shell/gpg.sh
@@ -0,0 +1,44 @@
+# https://github.com/benpye/wsl-ssh-pageant
+# https://github.com/drduh/YubiKey-Guide#remote-host-configuration
+# https://dev.to/dzerycz/series/11353
+
+# SSH Socket
+# Removing Linux SSH socket and replacing it by link to wsl2-ssh-pageant socket
+export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
+ss -a | grep -q $SSH_AUTH_SOCK
+if [ $? -ne 0 ]; then
+ rm -f $SSH_AUTH_SOCK
+ (setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$DOTFILES/ssh/wsl2-ssh-pageant.exe" &>/dev/null &)
+fi
+
+
+# GPG Socket
+# Removing Linux GPG Agent socket and replacing it by link to wsl2-ssh-pageant GPG socket
+export GPG_AGENT_SOCK=$HOME/.gnupg/S.gpg-agent
+
+export GPG_SOCKETS=("${GPG_AGENT_SOCK}" "${GPG_AGENT_SOCK}.extra" "${GPG_AGENT_SOCK}.ssh")
+
+for socket in "${GPG_SOCKETS[@]}"; do
+ ss -a | grep -q $socket
+ if [ $? -ne 0 ]; then
+ rm -rf $socket
+ (setsid nohup socat UNIX-LISTEN:$socket,fork EXEC:"$DOTFILES/ssh/wsl2-ssh-pageant.exe --gpg $(basename $socket)" &>/dev/null &)
+ fi
+done
+
+
+alias gpgrst=gpg-reset
+# Reload
+function gpg-reset() {
+ gpg-connect-agent.exe KILLAGENT /bye &>/dev/null
+
+ for socket in "${GPG_SOCKETS[@]}"; do
+ [ -e $socket ] && rm $socket
+ done
+ pkill -f 'socat.*wsl2-ssh-pageant.exe'
+ gpg-connect-agent.exe /bye &>/dev/null
+
+ for socket in "${GPG_SOCKETS[@]}"; do
+ (setsid nohup socat UNIX-LISTEN:$socket,fork EXEC:"$DOTFILES/ssh/wsl2-ssh-pageant.exe --gpg $(basename $socket)" &>/dev/null &)
+ done
+}
diff --git a/shell/profile.sh b/shell/profile.sh
new file mode 100644
index 0000000..bde5867
--- /dev/null
+++ b/shell/profile.sh
@@ -0,0 +1,6 @@
+# Path
+PATH=$PATH:$HOME/.local/bin:$HOME/.dotnet/tools:$HOME/.cargo/bin
+
+# Exports
+export DOTFILES="${HOME}/dotfiles"
+export FZF_BASE="${HOME}/dotfiles/fzf" \ No newline at end of file
diff --git a/shell/wsl.sh b/shell/wsl.sh
new file mode 100644
index 0000000..4a876df
--- /dev/null
+++ b/shell/wsl.sh
@@ -0,0 +1,30 @@
+export EDITOR=code
+
+alias cb=clip.exe
+alias wsl=wsl.exe
+alias ykman="/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe"
+
+function wt() { powershell.exe -NoProfile -c "wt $@" }
+
+function winget() {
+ cmd="winget.exe $1"
+ shift # past cmd
+
+ while [[ $# -gt 0 ]]
+ do
+ key="$1"
+ case $key in
+ -*) # key value pair
+ cmd+=" $key '$2'"
+ shift # past argument
+ shift # past value
+ ;;
+ *) # positional argument
+ cmd+=" '$1'" # add it to the list
+ shift # past argument
+ ;;
+ esac
+ done
+
+ powershell.exe -NoProfile -c "$cmd"
+} \ No newline at end of file
diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh
index 4f15ba3..145f23a 100644
--- a/zsh/aliases.zsh
+++ b/zsh/aliases.zsh
@@ -1,11 +1 @@
-# Aliases
-alias zshrc="${=EDITOR} ~/.zshrc"
-alias update="sudo apt update && apt list --upgradable"
-alias upgrade="sudo apt upgrade -y"
-alias ipa="ip -s -c -h a"
-alias untar="tar -zxvf "
-alias py=python3
-alias python=python3
-alias pip=pip3
-alias dsh="dce sh"
-alias dps="docker ps" \ No newline at end of file
+source "${DOTFILES:="${HOME}/dotfiles"}/shell/aliases.sh" \ No newline at end of file
diff --git a/zsh/wsl.zsh b/zsh/wsl.zsh
index 4ef0400..37bb447 100644
--- a/zsh/wsl.zsh
+++ b/zsh/wsl.zsh
@@ -1,34 +1,7 @@
-path=( $path $HOME/.local/bin $HOME/.dotnet/tools )
-hash -d w=/mnt/c/Users/$USER
-
-alias cb=clip.exe
-alias wsl=wsl.exe
-alias ykman="/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe"
-
-function wt() { powershell.exe -NoProfile -c "wt $@" }
+source "${DOTFILES:-"${HOME}/dotfiles"}/shell/wsl.sh"
+source "${DOTFILES:-"${HOME}/dotfiles"}/shell/gpg.sh"
-function winget() {
- cmd="winget.exe $1"
- shift # past cmd
-
- while [[ $# -gt 0 ]]
- do
- key="$1"
- case $key in
- -*) # key value pair
- cmd+=" $key '$2'"
- shift # past argument
- shift # past value
- ;;
- *) # positional argument
- cmd+=" '$1'" # add it to the list
- shift # past argument
- ;;
- esac
- done
-
- powershell.exe -NoProfile -c "$cmd"
-}
+hash -d w=/mnt/c/Users/$USER
function r-copy() {
if ((REGION_ACTIVE)) then
@@ -47,49 +20,3 @@ function r-cut() {
fi
(( ${+aliases[cb]} )) && printf "$CUTBUFFER" | cb
}
-
-# https://github.com/benpye/wsl-ssh-pageant
-# https://github.com/drduh/YubiKey-Guide#remote-host-configuration
-# https://dev.to/dzerycz/series/11353
-
-export GPG_TTY=$(tty)
-
-# SSH Socket
-# Removing Linux SSH socket and replacing it by link to wsl2-ssh-pageant socket
-export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
-ss -a | grep -q $SSH_AUTH_SOCK
-if [ $? -ne 0 ]; then
- rm -f $SSH_AUTH_SOCK
- (setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe" &>/dev/null &)
-fi
-# GPG Socket
-# Removing Linux GPG Agent socket and replacing it by link to wsl2-ssh-pageant GPG socket
-export GPG_AGENT_SOCK=$HOME/.gnupg/S.gpg-agent
-ss -a | grep -q $GPG_AGENT_SOCK
-if [ $? -ne 0 ]; then
- rm -rf $GPG_AGENT_SOCK
- (setsid nohup socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent" &>/dev/null &)
-fi
-
-# GPG Socket
-# Removing Linux GPG Agent extra socket and replacing it by link to wsl2-ssh-pageant GPG socket
-export GPG_EXTRA_SOCK=$HOME/.gnupg/S.gpg-agent.extra
-ss -a | grep -q $GPG_EXTRA_SOCK
-if [ $? -ne 0 ]; then
- rm -rf $GPG_EXTRA_SOCK
- (setsid nohup socat UNIX-LISTEN:$GPG_EXTRA_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent.extra" &>/dev/null &)
-fi
-
-alias gpgrst=gpg-reset
-# Reload
-function gpg-reset() {
- gpg-connect-agent.exe KILLAGENT /bye &>/dev/null
- [ -e $GPG_AGENT_SOCK ] && rm $GPG_AGENT_SOCK
- [ -e $GPG_EXTRA_SOCK ] && rm $GPG_EXTRA_SOCK
- [ -e $SSH_AUTH_SOCK ] && rm $SSH_AUTH_SOCK
- pkill -f 'socat.*wsl2-ssh-pageant.exe'
- gpg-connect-agent.exe /bye &>/dev/null
- (setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe" &>/dev/null &)
- (setsid nohup socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent" &>/dev/null &)
- (setsid nohup socat UNIX-LISTEN:$GPG_EXTRA_SOCK,fork EXEC:"$ZSH_BASE/ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent.extra" &>/dev/null &)
-} \ No newline at end of file
diff --git a/zshrc b/zshrc
index 9d9ad4a..26eabd1 100644
--- a/zshrc
+++ b/zshrc
@@ -1,22 +1,15 @@
-# Path
-path=( $path $HOME/.local/bin $HOME/.dotnet/tools )
-
-# Exports
-export ZSH_BASE="${HOME}/dotfiles"
-export FZF_BASE="${HOME}/dotfiles/fzf"
+source "${DOTFILES:="${HOME}/dotfiles"}/shell/profile.sh"
# Directory hashtable
hash -d .=${HOME}/dotfiles
-hash -d s=${HOME}/Sync
-hash -d d=${HOME}/docker
-source $ZSH_BASE/antigen/antigen.zsh
-source $ZSH_BASE/zsh/setopt.zsh
-source $ZSH_BASE/zsh/prompt.zsh
-source $ZSH_BASE/zsh/aliases.zsh
-source $ZSH_BASE/zsh/keybindings.zsh
-[ -n "${WSL_DISTRO_NAME+1}" ] && source $ZSH_BASE/zsh/wsl.zsh
+source $DOTFILES/antigen/antigen.zsh
+source $DOTFILES/zsh/setopt.zsh
+source $DOTFILES/zsh/prompt.zsh
+source $DOTFILES/zsh/aliases.zsh
+source $DOTFILES/zsh/keybindings.zsh
+[ -n "${WSL_DISTRO_NAME+1}" ] && source $DOTFILES/zsh/wsl.zsh
antigen use oh-my-zsh
antigen bundle git