mirror of
https://github.com/shokinn/.files.git
synced 2025-01-18 21:22:25 +00:00
reorganize dotrfiles; fix exa aliasses for mac
This commit is contained in:
parent
b853f45327
commit
78b3209ea4
|
@ -128,6 +128,9 @@ dotfiles:
|
|||
f_rmquarantine:
|
||||
dst: ~/.bin/rmquarantine
|
||||
src: bin/rmquarantine
|
||||
f_commonfunc:
|
||||
dst: ~/.commonfunc
|
||||
src: commonfunc
|
||||
profiles:
|
||||
AINCRAD:
|
||||
dotfiles:
|
||||
|
@ -248,6 +251,7 @@ profiles:
|
|||
- f_wsladdhypervroute
|
||||
- f_wslenablehypervforwarding
|
||||
- f_wslshowhypervforwarding
|
||||
- f_commonfunc
|
||||
workspace:
|
||||
dotfiles:
|
||||
- d_fonts
|
||||
|
@ -258,6 +262,7 @@ profiles:
|
|||
- f_powerlevel10krc
|
||||
- d_colors
|
||||
- f_zprofile
|
||||
- f_commonfunc
|
||||
sbx0nucmac01.home.pphg.tech:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
|
@ -272,6 +277,7 @@ profiles:
|
|||
- f_c3mpv
|
||||
- f_c3check
|
||||
- f_zprofile
|
||||
- f_commonfunc
|
||||
WVDEWOBMC001307:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
|
@ -289,4 +295,5 @@ profiles:
|
|||
- f_dotdrop.sh
|
||||
- f_pu
|
||||
- f_rpki
|
||||
- f_rmquarantine
|
||||
- f_rmquarantine
|
||||
- f_commonfunc
|
103
dotfiles/commonfunc
Normal file
103
dotfiles/commonfunc
Normal file
|
@ -0,0 +1,103 @@
|
|||
#! /bin/sed 2,5!d;s/^#.//
|
||||
# This script must be sourced from within a shell
|
||||
# and not executed. For instance with:
|
||||
#
|
||||
# . ~/.commonfunc
|
||||
|
||||
#
|
||||
# {{@@ header() @@}}
|
||||
#
|
||||
|
||||
# exa - set aliasses for exa to use it as ls replacement
|
||||
if [[ $(command -v exa) ]]; then
|
||||
exafunc() {
|
||||
exa -l -F -g -h --extended --git --group-directories-first --icons ${@:-}
|
||||
}
|
||||
lfunc() {
|
||||
exafunc -T -L ${1:-1}
|
||||
}
|
||||
lafunc() {
|
||||
exafunc -a -T -L ${1:-1}
|
||||
}
|
||||
alias l='lfunc'
|
||||
alias la='lafunc'
|
||||
alias ll="lfunc 2"
|
||||
alias lla='lafunc 2'
|
||||
fi
|
||||
|
||||
# wttr - show the weather forecast in Terminal
|
||||
wttr() {
|
||||
if [ -z "${1}" ]; then
|
||||
curl http://wttr.in
|
||||
elif [[ "${1}" == "help" ]]; then
|
||||
cat << EOF
|
||||
usage: wttr (City|3-letter airport code|'~Special+Location')
|
||||
City:
|
||||
Just write down the name of the city.
|
||||
e.G.:
|
||||
wttr London
|
||||
3-letter airport code:
|
||||
Use 3-letter airport codes in order to get the weather information at a certain airport.
|
||||
e.G.:
|
||||
wttr muc #for Munich Internation Airpot, Germany
|
||||
Special Location:
|
||||
Let's say you'd like to get the weather for a geographical location other than a town or city -
|
||||
maybe an attraction in a city, a mountain name, or some special location.
|
||||
Add the character '~' before the name to look up that special location name before the weather is then retrieved.
|
||||
e.G.:
|
||||
wttr '~Eiffel+Tower'
|
||||
wttr '~Kilimanjaro'
|
||||
EOF
|
||||
else
|
||||
curl http://wttr.in/${1}
|
||||
fi
|
||||
}
|
||||
|
||||
{%@@ if profile == 'WVDEWOBMC001307' @@%}
|
||||
macnst (){
|
||||
netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
|
||||
}
|
||||
|
||||
function setProxyEnv(){
|
||||
local HIGHLIGHT='\033[36;1m'
|
||||
local RESET='\033[0;0m'
|
||||
|
||||
local PROXY='127.0.0.1:9000'
|
||||
local PROXY_CFG_HTTP="${PROXY}"
|
||||
local PROXY_CFG_HTTPS="${PROXY}"
|
||||
local NO_PROXY_CFG="127.0.0.1,localhost,vw.vwg"
|
||||
|
||||
export NO_PROXY="${NO_PROXY_CFG}"
|
||||
export no_proxy="${NO_PROXY_CFG}"
|
||||
export HTTP_PROXY="${PROXY_CFG_HTTP}"
|
||||
export HTTPS_PROXY="${PROXY_CFG_HTTPS}"
|
||||
export http_proxy="${PROXY_CFG_HTTP}"
|
||||
export https_proxy="${PROXY_CFG_HTTPS}"
|
||||
export GIT_SSH_COMMAND='ssh -o ProxyCommand="/opt/homebrew/bin/corkscrew localhost 9000 %h %p"'
|
||||
|
||||
echo -e "\n✈️ exported zscaler proxy: ${HIGHLIGHT}http://${PROXY}${RESET}"
|
||||
}
|
||||
|
||||
function unsetProxyEnv(){
|
||||
unset NO_PROXY
|
||||
unset HTTP_PROXY
|
||||
unset HTTPS_PROXY
|
||||
unset no_proxy
|
||||
unset http_proxy
|
||||
unset https_proxy
|
||||
unset GIT_SSH_COMMAND
|
||||
|
||||
echo -e "\n🔄 removed zscaler proxy cofiguration"
|
||||
}
|
||||
|
||||
function setVpnGitRemote(){
|
||||
local ORIGIN=vpn #e.g.
|
||||
local HIGHLIGHT='\033[36;1m'
|
||||
local RESET='\033[0;0m'
|
||||
|
||||
local repo="ssh://git@vpn.github.com:443/${$(git config remote.origin.url)#*git@github.com:}"
|
||||
git remote add ${ORIGIN} "${repo}" 2> /dev/null
|
||||
|
||||
echo -e "🔗 git remote (${HIGHLIGHT}${ORIGIN}${RESET}): ${HIGHLIGHT}${repo}${RESET}\n"
|
||||
}
|
||||
{%@@ endif @@%}
|
|
@ -20,29 +20,14 @@ export ANSIBLE_NOCOWS=1
|
|||
# Include $(go env GOPATH) to PATH
|
||||
[[ $(command -v go) ]] && [[ -d "$(go env GOPATH)/bin" ]] && export PATH="$(go env GOPATH)/bin:${PATH}"
|
||||
|
||||
# exa
|
||||
if [[ $(command -v exa) ]]; then
|
||||
lfunc() {
|
||||
exal -T -L ${1:-1}
|
||||
}
|
||||
lafunc() {
|
||||
exal -a -T -L ${1:-1}
|
||||
}
|
||||
alias exal="exa -l -F -g -h --extended --git --group-directories-first --icons"
|
||||
alias l='lfunc'
|
||||
alias la='lafunc'
|
||||
alias ll="lfunc 2"
|
||||
alias lla='lafunc 2'
|
||||
fi
|
||||
|
||||
{%@@ if profile == 'AINCRAD-wsl' or profile == 'AINCRAD' or profile == 'YOETUNHEIMR-wsl' or profile == 'yoetunheimr' or profile == 'ymir' @@%}
|
||||
# Connect to windows ssh pageant
|
||||
# https://github.com/BlackReloaded/wsl2-ssh-pageant
|
||||
export SSH_AUTH_SOCK={{@@ env['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:{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe >/dev/null 2>&1 &)
|
||||
rm -f $SSH_AUTH_SOCK
|
||||
(setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe >/dev/null 2>&1 &)
|
||||
fi
|
||||
|
||||
# Connect to windows gpg agent
|
||||
|
@ -50,8 +35,8 @@ fi
|
|||
export GPG_AGENT_SOCK={{@@ env['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:"{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent" >/dev/null 2>&1 &)
|
||||
rm -rf $GPG_AGENT_SOCK
|
||||
(setsid nohup socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"{{@@ env['HOME'] @@}}/.ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent" >/dev/null 2>&1 &)
|
||||
fi
|
||||
|
||||
# X410 (Windows X11 Server)
|
||||
|
@ -60,4 +45,6 @@ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}
|
|||
{%@@ if profile == 'WVDEWOBMC001307' @@%}
|
||||
export HOMEBREW_CASK_OPTS="--appdir=~/Applications"
|
||||
|
||||
{%@@ endif @@%}
|
||||
{%@@ endif @@%}
|
||||
|
||||
source {{@@ env['HOME'] @@}}/.commonfunc
|
||||
|
|
|
@ -158,21 +158,6 @@ source ${ZSH}/oh-my-zsh.sh
|
|||
|
||||
alias ssh-no-check="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||
|
||||
# exa
|
||||
if [[ $(command -v exa) ]]; then
|
||||
lfunc() {
|
||||
exal -T -L ${1:-1}
|
||||
}
|
||||
lafunc() {
|
||||
exal -a -T -L ${1:-1}
|
||||
}
|
||||
alias exal="exa -l -F -g -h --extended --git --group-directories-first --icons"
|
||||
alias l='lfunc'
|
||||
alias la='lafunc'
|
||||
alias ll="lfunc 2"
|
||||
alias lla='lafunc 2'
|
||||
fi
|
||||
|
||||
# Initialize pyenv
|
||||
[[ $(command -v pyenv) ]] && export PYENV_ROOT="$HOME/.pyenv"
|
||||
[[ $(command -v pyenv) ]] && command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
|
@ -196,79 +181,7 @@ export PATH="${brew_path}:${PATH}"
|
|||
{%@@ endif @@%}
|
||||
|
||||
# Functions (or more complex aliases)
|
||||
wttr() {
|
||||
if [ -z "${1}" ]; then
|
||||
curl http://wttr.in
|
||||
elif [[ "${1}" == "help" ]]; then
|
||||
cat << EOF
|
||||
usage: wttr (City|3-letter airport code|'~Special+Location')
|
||||
City:
|
||||
Just write down the name of the city.
|
||||
e.G.:
|
||||
wttr London
|
||||
3-letter airport code:
|
||||
Use 3-letter airport codes in order to get the weather information at a certain airport.
|
||||
e.G.:
|
||||
wttr muc #for Munich Internation Airpot, Germany
|
||||
Special Location:
|
||||
Let's say you'd like to get the weather for a geographical location other than a town or city -
|
||||
maybe an attraction in a city, a mountain name, or some special location.
|
||||
Add the character '~' before the name to look up that special location name before the weather is then retrieved.
|
||||
e.G.:
|
||||
wttr '~Eiffel+Tower'
|
||||
wttr '~Kilimanjaro'
|
||||
EOF
|
||||
else
|
||||
curl http://wttr.in/${1}
|
||||
fi
|
||||
}
|
||||
|
||||
{%@@ if profile == 'WVDEWOBMC001307' @@%}
|
||||
macnst (){
|
||||
netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
|
||||
}
|
||||
|
||||
function setProxyEnv(){
|
||||
local HIGHLIGHT='\033[36;1m'
|
||||
local RESET='\033[0;0m'
|
||||
|
||||
local PROXY='127.0.0.1:9000'
|
||||
local PROXY_CFG_HTTP="${PROXY}"
|
||||
local PROXY_CFG_HTTPS="${PROXY}"
|
||||
local NO_PROXY_CFG="127.0.0.1,localhost,vw.vwg"
|
||||
|
||||
export NO_PROXY="${NO_PROXY_CFG}"
|
||||
export no_proxy="${NO_PROXY_CFG}"
|
||||
export HTTP_PROXY="${PROXY_CFG_HTTP}"
|
||||
export HTTPS_PROXY="${PROXY_CFG_HTTPS}"
|
||||
export http_proxy="${PROXY_CFG_HTTP}"
|
||||
export https_proxy="${PROXY_CFG_HTTPS}"
|
||||
|
||||
echo -e "\n✈️ exported zscaler proxy: ${HIGHLIGHT}http://${PROXY}${RESET}"
|
||||
}
|
||||
|
||||
function unsetProxyEnv(){
|
||||
unset NO_PROXY
|
||||
unset HTTP_PROXY
|
||||
unset HTTPS_PROXY
|
||||
unset no_proxy
|
||||
unset http_proxy
|
||||
unset https_proxy
|
||||
|
||||
echo -e "\n🔄 removed zscaler proxy cofiguration"
|
||||
}
|
||||
|
||||
function setVpnGitRemote(){
|
||||
local ORIGIN=vpn #e.g.
|
||||
local HIGHLIGHT='\033[36;1m'
|
||||
local RESET='\033[0;0m'
|
||||
|
||||
local repo="ssh://git@vpn.github.com:443/${$(git config remote.origin.url)#*git@github.com:}"
|
||||
git remote add ${ORIGIN} "${repo}" 2> /dev/null
|
||||
|
||||
echo -e "🔗 git remote (${HIGHLIGHT}${ORIGIN}${RESET}): ${HIGHLIGHT}${repo}${RESET}\n"
|
||||
}
|
||||
{%@@ endif @@%}
|
||||
source {{@@ env['HOME'] @@}}/.commonfunc
|
||||
|
||||
{%@@ if profile == 'ymir' @@%}
|
||||
autoload -Uz compinit
|
||||
|
|
Loading…
Reference in a new issue