reorganize dotrfiles; fix exa aliasses for mac

This commit is contained in:
Philip Henning 2023-09-13 11:06:14 +02:00
parent b853f45327
commit 78b3209ea4
4 changed files with 119 additions and 109 deletions

View file

@ -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
@ -290,3 +296,4 @@ profiles:
- f_pu
- f_rpki
- f_rmquarantine
- f_commonfunc

103
dotfiles/commonfunc Normal file
View 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 @@%}

View file

@ -20,21 +20,6 @@ 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
@ -61,3 +46,5 @@ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}
export HOMEBREW_CASK_OPTS="--appdir=~/Applications"
{%@@ endif @@%}
source {{@@ env['HOME'] @@}}/.commonfunc

View file

@ -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