Added modiciation from a parallel project
This commit is contained in:
parent
e14d5f3566
commit
278be5a6c6
|
@ -118,6 +118,14 @@
|
||||||
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
|
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
|
||||||
"type": "os"
|
"type": "os"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"foreground": "#d3d7cf",
|
||||||
|
"background": "black",
|
||||||
|
"powerline_symbol": "",
|
||||||
|
"style": "powerline",
|
||||||
|
"template": "{{ if gt .Env.SHLVL_pqb \"1\" }}{{ .Env.SHLVL_pqb }}{{ end }}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"foreground": "#d3d7cf",
|
"foreground": "#d3d7cf",
|
||||||
|
@ -301,7 +309,7 @@
|
||||||
"style": "powerline",
|
"style": "powerline",
|
||||||
"properties": {
|
"properties": {
|
||||||
"shell": "bash",
|
"shell": "bash",
|
||||||
"command": "type -t chezmoi 2>&1 >/dev/null && printf \"%s\" $(chezmoi status 2>/dev/null | wc -l) , $(chezmoi git -- status --short | wc -l)"
|
"command": "type -t chezmoi 2>&1 >/dev/null && printf \"%s\" $(chezmoi status --exclude scripts 2>/dev/null | wc -l) , $(chezmoi git -- status --short | wc -l)"
|
||||||
},
|
},
|
||||||
"template": "{{ if ne .Output \"0,0\" }}≢{{ .Output }}{{ end }}"
|
"template": "{{ if ne .Output \"0,0\" }}≢{{ .Output }}{{ end }}"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# ~/.profile: executed by the command interpreter for login shells.
|
||||||
|
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
||||||
|
# exists.
|
||||||
|
# see /usr/share/doc/bash/examples/startup-files for examples.
|
||||||
|
# the files are located in the bash-doc package.
|
||||||
|
|
||||||
|
# the default umask is set in /etc/profile; for setting the umask
|
||||||
|
# for ssh logins, install and configure the libpam-umask package.
|
||||||
|
#umask 022
|
||||||
|
|
||||||
|
# if running bash
|
||||||
|
if [ -n "$BASH_VERSION" ]; then
|
||||||
|
# include .bashrc if it exists
|
||||||
|
if [ -f "$HOME/.bashrc" ]; then
|
||||||
|
. "$HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/bin" ] ; then
|
||||||
|
PATH="$HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
if [ -d "$HOME/.local/bin" ] ; then
|
||||||
|
PATH="$HOME/.local/bin:$PATH"
|
||||||
|
fi
|
|
@ -1,13 +1,53 @@
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
SFP='.sz' # Script Family Prefix
|
SFP='.sz' # Script Family Prefix
|
||||||
[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc"
|
[ -z ${DBG_SHRC} ] || echo "Entered ${SFP}.shrc"
|
||||||
|
export SHRC_D=~/${SFP}.shrc.d
|
||||||
|
unset SHLVL_${SFP##*.}
|
||||||
|
|
||||||
case $- in
|
IS_INTERACTIVE=${IS_INTERACTIVE:-$-}
|
||||||
|
# himBHs - Interactive
|
||||||
|
# hBc - called with `bash -c`
|
||||||
|
# Legend:
|
||||||
|
# h Locate and remember (hash) commands as they are looked up for
|
||||||
|
# execution. This option is enabled by default.
|
||||||
|
# i Interactive shell.
|
||||||
|
# m Job control is enabled (see Job Control). All processes run in a
|
||||||
|
# separate process group. When a background job completes, the
|
||||||
|
# shell prints a line containing its exit status.
|
||||||
|
# c Commands were supplied from via `bash -c` command line switch.
|
||||||
|
# B The shell will perform brace expansion (see Brace Expansion).
|
||||||
|
# This option is on by default.
|
||||||
|
# H Enable ‘!’ style history substitution (see History Interaction).
|
||||||
|
# This option is on by default for interactive shells.
|
||||||
|
# s Read commands from the standard input.
|
||||||
|
export SHRC_D=~/${SFP}.shrc.d
|
||||||
|
case $IS_INTERACTIVE in
|
||||||
|
|
||||||
|
FORCE) ;;
|
||||||
|
IS_INTERACTIVE=${IS_INTERACTIVE:-$-}
|
||||||
|
# himBHs - Interactive
|
||||||
|
unset IS_INTERACTIVE
|
||||||
|
# hBc - called with `bash -c`
|
||||||
|
# h Locate and remember (hash) commands as they are looked up for
|
||||||
|
# execution. This option is enabled by default.
|
||||||
|
# i Interactive shell.
|
||||||
|
# m Job control is enabled (see Job Control). All processes run in a
|
||||||
|
# separate process group. When a background job completes, the
|
||||||
|
# shell prints a line containing its exit status.
|
||||||
|
# c Commands were supplied from via `bash -c` command line switch.
|
||||||
|
# B The shell will perform brace expansion (see Brace Expansion).
|
||||||
|
# This option is on by default.
|
||||||
|
# H Enable ‘!’ style history substitution (see History Interaction).
|
||||||
|
# This option is on by default for interactive shells.
|
||||||
|
# s Read commands from the standard input.
|
||||||
|
|
||||||
|
case $IS_INTERACTIVE in
|
||||||
*i*) echo "Welcome $USER to $(hostname)";;
|
*i*) echo "Welcome $USER to $(hostname)";;
|
||||||
|
FORCE) ;;
|
||||||
*) return;;
|
*) return;;
|
||||||
esac
|
esac
|
||||||
|
unset IS_INTERACTIVE
|
||||||
|
|
||||||
export SHRC_D=~/${SFP}.shrc.d
|
|
||||||
if [ -d ${SHRC_D} ]; then
|
if [ -d ${SHRC_D} ]; then
|
||||||
script_source=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
|
script_source=("$(find ${SHRC_D} -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
|
||||||
script_source+=("$(find ${SHRC_D} -maxdepth 0 -type d)")
|
script_source+=("$(find ${SHRC_D} -maxdepth 0 -type d)")
|
||||||
|
|
|
@ -1,15 +1,34 @@
|
||||||
|
ANSI_Print() { printf "\E[${ANSI_Code}m%s\E[0m" "$@"; }
|
||||||
|
ANSI_Red() { ANSI_Code=31 ANSI_Print "$@"; }
|
||||||
|
ANSI_Green() { ANSI_Code=32 ANSI_Print "$@"; }
|
||||||
|
ANSI_Yellow() { ANSI_Code=33 ANSI_Print "$@"; }
|
||||||
|
ANSI_Blue() { ANSI_Code=34 ANSI_Print "$@"; }
|
||||||
|
ANSI_Indiego() { ANSI_Code=35 ANSI_Print "$@"; }
|
||||||
|
ANSI_Cyan() { ANSI_Code=36 ANSI_Print "$@"; }
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
(>&2 printf '\E[34mWARNING:\E[0m %s\n' "$@" )
|
(>&2 printf '%s %s\n' $(ANSI_Yellow 'WARNING:') "$(echo "$@")" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The way to call this is:
|
||||||
|
# eval $(error 1 "message") || exit $?
|
||||||
|
# where 1 is the return/exit code and "message" is the message to be
|
||||||
|
# displayed
|
||||||
error() {
|
error() {
|
||||||
(>&2 printf '\E[31mERROR:\E[0m %s\n' "$@" )
|
printf "(>&2 \
|
||||||
|
printf '%%s %%b' '$(ANSI_Red 'ERROR:')' '$(printf "%b " "${@:2}")') \
|
||||||
|
&& echo '' && return ${1} 2>/dev/null || exit ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
require_sudo() {
|
||||||
|
if [[ $EUID -ne 0 && -z $(printf "%s\n" $(id --groups --name) | grep '^sudo$') ]]; then
|
||||||
|
eval $(error 1 "This script should be run by a sudo memeber or as the root user")
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
require_root() {
|
require_root() {
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
error "This script should only be run using sudo or as the root user"
|
eval $(error 1 "This script should only be run using sudo or as the root user")
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +41,13 @@ recommend_root() {
|
||||||
|
|
||||||
function setacl() {
|
function setacl() {
|
||||||
if [[ $# -lt 4 ]]; then
|
if [[ $# -lt 4 ]]; then
|
||||||
error "setacl missing arguments, called with '$1' ${@:2}"
|
eval $(error 1 \
|
||||||
printf "%s\n" "Usage:" "\tsetacl <Options> <Ownership> <Permissions> <Path> [<Additional Paths>...]"
|
"setacl missing arguments, called with '$1' ${@:2}" \
|
||||||
|
$(printf "%s\n" \
|
||||||
|
"Usage:" \
|
||||||
|
"\tsetacl <Options> <Ownership> <Permissions> <Path> [<Additional Paths>...]" \
|
||||||
|
)
|
||||||
|
)
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local Options=${1}
|
local Options=${1}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
function shlvl() {
|
||||||
|
local SHLVL_VAR="SHLVL_${SFP##*.}"
|
||||||
|
local SHELLS=$( \
|
||||||
|
cat /etc/shells \
|
||||||
|
| tail +2 \
|
||||||
|
| sed 's/.*\///' \
|
||||||
|
| sort -u \
|
||||||
|
| grep -v tmux \
|
||||||
|
| paste -sd '|' \
|
||||||
|
)
|
||||||
|
local SHLVL_VAL=$(eval "printf '%s' \"\$$SHLVL_VAR\"")
|
||||||
|
if [[ -z "$SHLVL_VAL" ]]; then
|
||||||
|
SHLVL_VAL=$(( $( \
|
||||||
|
pstree -s $$ \
|
||||||
|
| head -1 \
|
||||||
|
| sed -r 's/-\+-/---/g; s/-[^-]+---oh-my-posh---.*/-/; s/---/\n/g;' \
|
||||||
|
| grep -Ec "^($SHELLS)$"
|
||||||
|
) - ${1:-1} ))
|
||||||
|
eval "export $SHLVL_VAR=$SHLVL_VAL"
|
||||||
|
fi
|
||||||
|
echo $SHLVL_VAL
|
||||||
|
}
|
||||||
|
shlvl > /dev/null
|
|
@ -8,34 +8,7 @@ MY_VI="$(type -fP my_vi || printf "%s -p" $(type -fP nvim) || type -fP vi) "
|
||||||
[[ -n $(which-command "${EDITOR}") ]] \
|
[[ -n $(which-command "${EDITOR}") ]] \
|
||||||
&& alias my_editor="${EDITOR} "
|
&& alias my_editor="${EDITOR} "
|
||||||
|
|
||||||
export DOOMROOT="$HOME/.config/_my.emacs/doom"
|
|
||||||
[[ -x $DOOMROOT/emacs.d/bin/doom ]] && function doom() {
|
|
||||||
export EMACSDIR="$DOOMROOT/emacs.d"
|
|
||||||
export DOOMDIR="$DOOMROOT/config"
|
|
||||||
"$EMACSDIR/bin/doom" "${@}"
|
|
||||||
|
|
||||||
unset EMACSDIR DOOMDIR
|
|
||||||
} && function doomemacs() {
|
|
||||||
emacs --with-profile=doom ${@}
|
|
||||||
} || unset DOOMROOT
|
|
||||||
|
|
||||||
if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \
|
|
||||||
&& -n "$(which-command emacsclient)" \
|
|
||||||
&& -n "$(which-command emacs)" \
|
|
||||||
&& -n "$(which-command edit-with-spacemacs)" \
|
|
||||||
]]; then
|
|
||||||
alias my_editor='edit-with-spacemacs'
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -n $(which-command my_editor) ]] \
|
[[ -n $(which-command my_editor) ]] \
|
||||||
&& alias ed="my_editor" \
|
&& alias ed="my_editor" \
|
||||||
&& alias edit="my_editor" \
|
&& alias edit="my_editor" \
|
||||||
&& alias editor="my_editor"
|
&& alias editor="my_editor"
|
||||||
|
|
||||||
alias nvim="${MY_VI} "
|
|
||||||
alias vim="${MY_VI} "
|
|
||||||
alias vi="${MY_VI} "
|
|
||||||
|
|
||||||
alias ed="my_editor"
|
|
||||||
alias edit="my_editor"
|
|
||||||
alias editor="my_editor"
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#alias sudo="/usr/bin/sudo "
|
#alias sudo="/usr/bin/sudo "
|
||||||
|
alias _sudo="env sudo "
|
||||||
function sudo() {
|
function sudo() {
|
||||||
local cli="$(command -v "${1}")"
|
local cli="$(command -v "${1}")"
|
||||||
[[ -x "$cli" ]] || cli="${1}"
|
[[ -x "$cli" ]] || cli="${1}"
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Set PATH, MANPATH, etc., for Homebrew.
|
||||||
|
[[ -x /home/linuxbrew/.linuxbrew/bin/brew ]] && \
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
function gcp_project() {
|
function gcp-project() {
|
||||||
gcloud config get-value core/project 2> /dev/null
|
gcloud config get-value core/project 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_get_project_id() {
|
function gcp-get-project-id() {
|
||||||
gcloud projects list \
|
gcloud projects list \
|
||||||
--filter="$1" \
|
--filter="$1" \
|
||||||
--format="value(project_id)" \
|
--format="value(project_id)" \
|
||||||
2> /dev/null
|
2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_get_project_number() {
|
function gcp-get-project-number() {
|
||||||
gcloud projects list \
|
gcloud projects list \
|
||||||
--filter="project_id:$1" \
|
--filter="project_id:$1" \
|
||||||
--format='value(project_number)' \
|
--format='value(project_number)' \
|
||||||
2> /dev/null
|
2> /dev/null
|
||||||
}
|
}
|
||||||
function gcp_get_regions() {
|
function gcp-get-regions() {
|
||||||
gcloud compute regions list --format="value(name)"
|
gcloud compute regions list --format="value(name)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcp_get_region_quotas() {
|
function gcp-get-region-quotas() {
|
||||||
region_arr_list=( $(gcloud compute regions list --format="value(name)") )
|
region_arr_list=( $(gcloud compute regions list --format="value(name)") )
|
||||||
|
|
||||||
for region in ${region_arr_list[@]}; do
|
for region in ${region_arr_list[@]}; do
|
||||||
|
@ -31,34 +31,79 @@ function gcp_get_region_quotas() {
|
||||||
#done
|
#done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: gcp_get_stack dragonheart 10 22
|
GCP_SUBNETS_FORMAT='--format="table(
|
||||||
|
name,
|
||||||
|
region,
|
||||||
|
network,
|
||||||
|
ipCidrRange,
|
||||||
|
stack_type
|
||||||
|
)"'
|
||||||
|
|
||||||
|
GCP_DISKS_FORMAT='--format="table(
|
||||||
|
status,
|
||||||
|
name,
|
||||||
|
location():label=ZONE,
|
||||||
|
sizeGb,
|
||||||
|
type.basename()
|
||||||
|
)"'
|
||||||
|
|
||||||
|
GCP_INSTANCES_FORMAT='--format="table(
|
||||||
|
status,
|
||||||
|
name,
|
||||||
|
zone,
|
||||||
|
machineType:label=TYPE,
|
||||||
|
scheduling.preemptible:label=PREE,
|
||||||
|
deletionProtection:label=DelPr,
|
||||||
|
INTERNAL_IP:label=IN_IP,
|
||||||
|
EXTERNAL_IP:label=EX_IP
|
||||||
|
)"'
|
||||||
|
|
||||||
|
# Usage: gcp-get-stack dragonheart 10 22
|
||||||
# Watch the 'dragonheart' stack,
|
# Watch the 'dragonheart' stack,
|
||||||
# refresh every 10 seconds,
|
# refresh every 10 seconds,
|
||||||
# set tmux pane to 22 lines high (on every refresh)
|
# set tmux pane to 22 lines high (on every refresh)
|
||||||
function gcp_get_stack() {
|
function gcp-get-stack() {
|
||||||
local N="${1:-$(basename $PWD)}"
|
local N="${1:-$(basename $PWD)}"
|
||||||
local _cmd=""
|
local _cmd=""
|
||||||
local _tmux=''
|
local _tmux=''
|
||||||
[ $# -ge 3 ] && [[ -n "$(which-command tmux)" ]] && printf "%s" "$3" > "/tmp/tmux-$1" && _cmd=$(printf "%s" 'tmux resize-pane -t "$TMUX_PANE" -y $(cat "/tmp/tmux-' "$1" '") ; ') && eval $_cmd
|
[ $# -ge 3 ] && [[ -n "$(which-command tmux)" ]] \
|
||||||
|
&& printf "%s" "$3" > "/tmp/tmux-$1" \
|
||||||
|
&& _cmd=$( \
|
||||||
|
printf "%s " \
|
||||||
|
'tmux resize-pane' \
|
||||||
|
'-t "$TMUX_PANE"' \
|
||||||
|
'-y $(cat "/tmp/tmux-' "$1" '") ; ' \
|
||||||
|
) \
|
||||||
|
&& eval $_cmd
|
||||||
_cmd="{ $(printf "%s " \
|
_cmd="{ $(printf "%s " \
|
||||||
"N='$N'; " \
|
"N='$N'; " \
|
||||||
"${_cmd}" \
|
"${_cmd}" \
|
||||||
"echo 'Listing $N stack:'; " \
|
"echo 'Listing $N stack:'; " \
|
||||||
'{ gcloud compute networks list --filter="name:$N" 2>&1 | ' "sed --unbuffered s/^/Networks.:\ /g ; } " \
|
'{ gcloud compute networks' \
|
||||||
'&& { gcloud compute networks subnets list --filter="name:$N" 2>&1 | ' "sed --unbuffered s/^/Subnets..:\ /g ; } " \
|
'list --filter="name:$N"' \
|
||||||
'&& { gcloud compute disks list --filter="name:$N" 2>&1 | ' "sed --unbuffered s/^/Disks....:\ /g ; } " \
|
'2>&1 | sed --unbuffered s/^/Networks.:\ /g ; } ' \
|
||||||
'&& { gcloud compute instances list --filter="name:$N" 2>&1 | ' "sed --unbuffered s/^/Instances:\ /g ; } " \
|
'&& { gcloud compute networks subnets' \
|
||||||
'&& { gcloud compute routers list --filter="name:$N" 2>&1 | ' "sed --unbuffered s/^/Routers..:\ /g ; } " \
|
'list --filter="name:$N"' ${GCP_SUBNETS_FORMAT} \
|
||||||
'&& { gcloud compute network-firewall-policies get-effective-firewalls --network="$N-network"' \
|
'2>&1 | sed --unbuffered s/^/Subnets..:\ /g ; } ' \
|
||||||
" 2>&1 | sed --unbuffered s/^/Firewall:\ /g ; } " \
|
'&& { gcloud compute disks' ${GCP_DISKS_FORMAT} \
|
||||||
|
'list --filter="name:$N"' \
|
||||||
|
'2>&1 | sed --unbuffered s/^/Disks....:\ /g ; } ' \
|
||||||
|
'&& { gcloud compute instances' ${GCP_INSTANCES_FORMAT} \
|
||||||
|
'list --filter="name:$N"' \
|
||||||
|
'2>&1 | sed --unbuffered s/^/Instances:\ /g ; } ' \
|
||||||
|
'&& { gcloud compute routers' \
|
||||||
|
'list --filter="name:$N"' \
|
||||||
|
'2>&1 | sed --unbuffered s/^/Routers..:\ /g ; } ' \
|
||||||
|
'&& { gcloud compute network-firewall-policies' \
|
||||||
|
'get-effective-firewalls --network="$N-network"' \
|
||||||
|
'2>&1 | sed --unbuffered s/^/Firewall:\ /g ; } ' \
|
||||||
) ;}"
|
) ;}"
|
||||||
[ $# -ge 2 ] && _cmd="watch -n${2} '${_cmd}'"
|
[ $# -ge 2 ] && _cmd="watch -n${2} '${_cmd}'"
|
||||||
[[ -n ${SZ_DEBUG} ]] && printf "Executing: \n\t$_cmd\n\n"
|
[[ -n ${SZ_DEBUG} ]] && printf "Executing: \n\t$_cmd\n\n"
|
||||||
eval $_cmd
|
eval $_cmd
|
||||||
}
|
}
|
||||||
# printf '\n\n'; gcp_get_stack 'dragonheart' 5
|
# printf '\n\n'; gcp-get-stack 'dragonheart' 5
|
||||||
|
|
||||||
function gcp_region() {
|
function gcp-region() {
|
||||||
gcloud config get-value compute/region 2> /dev/null
|
gcloud config get-value compute/region 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[[ -n $(which-command alacritty-colorscheme) ]] \
|
||||||
|
&& alias alc="alacritty-colorscheme " \
|
||||||
|
&& alias alcls="alc list " \
|
||||||
|
&& alias alcset="alc apply " \
|
||||||
|
&& alias alcs="alc status " \
|
||||||
|
&& alias alct="alc toggle "
|
|
@ -1,3 +1,8 @@
|
||||||
|
if [[ -z "$(which-command chezmoi)" && -x "$HOME/bin/chezmoi" ]]; then
|
||||||
|
function chezmoi() {
|
||||||
|
"$HOME/bin/chezmoi" "${@}"
|
||||||
|
}
|
||||||
|
fi
|
||||||
if [[ -n "$(which-command chezmoi)" ]]; then
|
if [[ -n "$(which-command chezmoi)" ]]; then
|
||||||
export CHEZMOIROOT="$(chezmoi source-path)"
|
export CHEZMOIROOT="$(chezmoi source-path)"
|
||||||
export CZ="$CHEZMOIROOT"
|
export CZ="$CHEZMOIROOT"
|
||||||
|
@ -5,25 +10,65 @@ if [[ -n "$(which-command chezmoi)" ]]; then
|
||||||
|
|
||||||
alias czcd="cd $CZ"
|
alias czcd="cd $CZ"
|
||||||
alias czxcd="cd $CZ_X"
|
alias czxcd="cd $CZ_X"
|
||||||
|
alias czx-edit="edit $CZ_X/.chezmoiexternal.*"
|
||||||
|
|
||||||
function cz() { chezmoi "${@}"; }
|
function cz() { chezmoi "${@}"; }
|
||||||
function czx() {
|
function czx() {
|
||||||
chezmoi --source $CZ_X --config $HOME/.config/chezmoi.externals/config.toml "${@}"
|
chezmoi --source $CZ_X --config $HOME/.config/chezmoi.externals/config.toml "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
alias czs="cz status "
|
alias czs="cz status --exclude scripts "
|
||||||
function czg() {
|
|
||||||
cz git -- "${@}"
|
CZG_ROOT="$(cz git -- rev-parse --show-toplevel)"
|
||||||
}
|
alias czg="git --work-tree=$CZG_ROOT --git-dir=$CZG_ROOT/.git "
|
||||||
#alias czg="cz git -- "
|
unset CZG_ROOT
|
||||||
alias czgs="cz git -- status "
|
|
||||||
|
alias czgs="czg status "
|
||||||
|
alias czgca="czg add --all && czg commit "
|
||||||
alias cza="cz apply && exec $SHELL"
|
alias cza="cz apply && exec $SHELL"
|
||||||
alias czu="cz upgrade && cz update && exec $SHELL "
|
alias czu="cz upgrade && cz update && exec $SHELL "
|
||||||
alias czxu="cz upgrade && cz update && czx apply && exec $SHELL "
|
alias czxu="cz upgrade && cz update && czx apply && exec $SHELL "
|
||||||
|
alias czxa="czx apply && exec $SHELL "
|
||||||
|
|
||||||
|
function cz-refresh() {
|
||||||
|
local _tmp
|
||||||
|
_tmp=$(chezmoi status --exclude scripts)
|
||||||
|
if [[ -n "$_tmp" ]]; then
|
||||||
|
echo "Adding modified files..."
|
||||||
|
cz re-add
|
||||||
|
else
|
||||||
|
echo "No modified files found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
_tmp=$(chezmoi unmanaged | grep "^${SFP/\./\\.}\.shrc\.d/" | while read u; do
|
||||||
|
printf "'$HOME/$u' "
|
||||||
|
done)
|
||||||
|
[[ -n "$(echo $_tmp | xargs)" ]] \
|
||||||
|
&& echo "Adding new files..." \
|
||||||
|
&& eval "chezmoi add --prompt $_tmp"
|
||||||
|
}
|
||||||
|
|
||||||
alias cz-refresh="czs | cut -d\ -f2 | grep '^\.sz\.shrc\.d' | xargs cz forget --force; cz add ~/.sz.shrc.d --recursive; cz status; cz git status"
|
|
||||||
alias cz-commit="cz git -- commit -a "
|
alias cz-commit="cz git -- commit -a "
|
||||||
|
|
||||||
|
function cz-get-data() {
|
||||||
|
chezmoi data --format json | jq -r ".${@:-${SFP#*.}}"
|
||||||
|
}
|
||||||
|
function cz-import-data() {
|
||||||
|
# Use this with eval: eval $(cz-import-data)
|
||||||
|
local tmp_SFP=${SFP^^}
|
||||||
|
tmp_SFP=${tmp_SFP#*.}
|
||||||
|
local UPPERCASE='|ascii_upcase'
|
||||||
|
local PREFIX="CZ_${tmp_SFP}_DATA_"
|
||||||
|
[[ "$1" == "promptString" ]] && unset UPPERCASE PREFIX
|
||||||
|
local RESULTS=$(cz-get-data | jq -r "to_entries[] | \"$PREFIX\(.key${UPPERCASE})=\\\"\(.value)\\\"\"")
|
||||||
|
if [[ "$1" == "promptString" ]] ; then
|
||||||
|
printf "$RESULTS" | tr '\n' ',' | sed 's/"//g; s/^\(.*\),$/"\1/g;'
|
||||||
|
#printf "$RESULTS" | tr '\n' ',' | sed 's/="/=/g; s/^\(.*\),$/"\1/g; s/,/,"/g;'
|
||||||
|
else
|
||||||
|
echo "$RESULTS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function cz-remove-missing() {
|
function cz-remove-missing() {
|
||||||
pushd ~ > /dev/null
|
pushd ~ > /dev/null
|
||||||
changes=$(cz status | sed -n 's/^DA[ \t]\+//p')
|
changes=$(cz status | sed -n 's/^DA[ \t]\+//p')
|
||||||
|
@ -33,16 +78,6 @@ if [[ -n "$(which-command chezmoi)" ]]; then
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function cz-add-changes() {
|
|
||||||
pushd ~ > /dev/null
|
|
||||||
changes=$(cz status | sed -n 's/^MM[ \t]\+//p')
|
|
||||||
for c in $changes; do
|
|
||||||
echo Adding $c
|
|
||||||
cz add $c
|
|
||||||
done
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function cz-set-ssh-github() {
|
function cz-set-ssh-github() {
|
||||||
cz git -- remote set-url origin "$( \
|
cz git -- remote set-url origin "$( \
|
||||||
cz git -- remote get-url origin \
|
cz git -- remote get-url origin \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
if [[ -n "$(which-command oh-my-posh)" ]]; then
|
if [[ -n "$(which-command oh-my-posh)" ]]; then
|
||||||
OHMYPOSH_CONFIG=''
|
OHMYPOSH_CONFIG=''
|
||||||
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="--config ~/.poshtheme.omp.json"
|
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
|
||||||
eval "$(oh-my-posh init bash $OHMYPOSH_CONFIG)"
|
eval "$(oh-my-posh init bash --config $OHMYPOSH_CONFIG)"
|
||||||
unset OHMYPOSH_CONFIG
|
unset OHMYPOSH_CONFIG
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[[ -n "$BASH_COMPLETION_EXIST" && -n $(which-command alacritty-colorscheme) ]] \
|
||||||
|
&& complete -W "$(alacritty-colorscheme list)" alacritty-colorscheme alc alcset alct
|
|
@ -4,10 +4,6 @@
|
||||||
| add-alias-to-bash-completion-code chezmoi cz czx \
|
| add-alias-to-bash-completion-code chezmoi cz czx \
|
||||||
| add-alias-to-bash-completion-code chezmoi czx \
|
| add-alias-to-bash-completion-code chezmoi czx \
|
||||||
) \
|
) \
|
||||||
echo done.
|
&& complete -F _complete_alias czs \
|
||||||
# && if [[ $(type -t compopt) = "builtin" ]]; then
|
&& complete -F _complete_alias czg \
|
||||||
# complete -o default -F __git_complete czg
|
&& complete -F _complete_alias czgs
|
||||||
# else
|
|
||||||
# complete -o default -o nospace -F __git_complete czg
|
|
||||||
# fi
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
if [[ -r /usr/share/bash-completion/bash_completion ]]; then
|
if [[ -r /usr/share/bash-completion/bash_completion ]]; then
|
||||||
BASH_COMPLETION_EXIST=1
|
BASH_COMPLETION_EXIST=1
|
||||||
shopt -s direxpand
|
shopt -s direxpand
|
||||||
|
|
||||||
|
[[ -r ~/.local/share/complete-alias/complete_alias ]] \
|
||||||
|
&& source ~/.local/share/complete-alias/complete_alias
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
alias which-command="type -fP "
|
|
||||||
function which-command() {
|
function which-command() {
|
||||||
|
local ANSWER=$(type -t "${@}") || return $?
|
||||||
|
[[ $ANSWER == "function" ]] && printf "function " && type "${@}" | tail +2 && return
|
||||||
|
[[ $ANSWER == "alias" ]] && {
|
||||||
|
alias "${@}"
|
||||||
|
}
|
||||||
type -fP "${@}"
|
type -fP "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
alias which-command="whence "
|
function which-command() {
|
||||||
|
local ANSWER=$(whence -w "${@}") || return $?
|
||||||
|
ANSWER=${ANSWER##*: }
|
||||||
|
[[ $ANSWER == "function" ]] && printf "function " && whence -f "${@}" && return
|
||||||
|
[[ $ANSWER == "alias" ]] && {
|
||||||
|
alias "${@}"
|
||||||
|
}
|
||||||
|
whence "${@}"
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
GH_PROJECT="${1}"
|
||||||
|
GH_DL_TAG="${2:-latest}"
|
||||||
|
GH_FILTER="${3:-deb}"
|
||||||
|
if [[ ! "$GH_FILTER" =~ '(' ]]; then
|
||||||
|
GH_FILTER="contains(\"${GH_FILTER}\")"
|
||||||
|
fi
|
||||||
|
SRC_URL=https://api.github.com/repos/${GH_PROJECT}/releases/${GH_DL_TAG}
|
||||||
|
DL_URL=$( \
|
||||||
|
curl -sL curl ${SRC_URL} \
|
||||||
|
| jq -r " \
|
||||||
|
.assets[] \
|
||||||
|
| select(.browser_download_url \
|
||||||
|
| ${GH_FILTER} ) \
|
||||||
|
| .browser_download_url \
|
||||||
|
")
|
||||||
|
[[ -n "$DL_URL" ]] \
|
||||||
|
&& printf "%s\n" $DL_URL \
|
||||||
|
|| return 1 2>/dev/null || exit 1
|
|
@ -0,0 +1,13 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
LIMIT=${1:-10}
|
||||||
|
REV_LIST="$(git rev-list --objects --all)"
|
||||||
|
find $(git rev-parse --git-dir)/objects/pack -type f -name "pack-*.idx" \
|
||||||
|
| while read pack; do
|
||||||
|
git verify-pack -v "$pack" | sort -nrk 3 | head -${LIMIT}
|
||||||
|
done | sort -nrk 3 | head -${LIMIT} \
|
||||||
|
| while read blobinfo; do
|
||||||
|
blob=$(echo "$blobinfo" | cut -f1 -d' ')
|
||||||
|
printf "%s %12s %s\n" $(echo "$blobinfo" | cut -f1,5 -d' ') "$(echo "$REV_LIST" | grep "$blob" | cut -f2 -d' ';)"
|
||||||
|
done
|
||||||
|
unset REV_LIST
|
|
@ -0,0 +1,15 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
DL_URL="${1}"
|
||||||
|
DL_FILENAME="${2:-${DL_URL##*/}}"
|
||||||
|
DL_DIR=$(mktemp -dt)
|
||||||
|
cd "$DL_DIR"
|
||||||
|
# Download the .deb file
|
||||||
|
wget "$DL_URL"
|
||||||
|
# Install the package
|
||||||
|
sudo dpkg -i "${DL_FILENAME}"
|
||||||
|
# Clean up
|
||||||
|
rm "${DL_FILENAME}"
|
||||||
|
cd /
|
||||||
|
rmdir "$DL_DIR"
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
### based on the code shared at https://community.teamviewer.com/English/discussion/comment/116988/#Comment_116988
|
|
||||||
|
|
||||||
clear
|
|
||||||
cat <<EOF
|
|
||||||
===================================================="
|
|
||||||
Latest TeamViewer QuickSupport Downloader & Launcher"
|
|
||||||
====================================================
|
|
||||||
|
|
||||||
Refreshing local versino fo TeamViewer QS
|
|
||||||
|
|
||||||
EOF
|
|
||||||
TVQS=${TVQS:-$1}
|
|
||||||
#RemoteFile=https://dl.teamviewer.com/download/linux/teamviewer_amd64.deb
|
|
||||||
#RemoteFile=https://download.teamviewer.com/download/linux/teamviewer_amd64.deb
|
|
||||||
#RemoteFile=https://download.teamviewer.com/download/version_11x/teamviewer_qs.tar.gz
|
|
||||||
# Prefer dl.teamviewer.com as it provides the `content-length` header
|
|
||||||
RemoteFile=https://dl.teamviewer.com/download/version_11x/teamviewer_qs.tar.gz
|
|
||||||
RemoteSize="$(curl -sI "$RemoteFile" | grep -i '^Content-Length:.*$' | awk '{sub("\r",""); print $2} ')"
|
|
||||||
|
|
||||||
LocalFile=~/Downloads/TeamViewerQS.tgz
|
|
||||||
if [ "${TVQS}" == "gal" ]; then
|
|
||||||
RemoteFileCustom='https://customdesignservice.teamviewer.com/download/linux/v15/6fnv7gb/TeamViewerQS.tar.gz'
|
|
||||||
RemoteSizeCustom="$(curl -sI "$RemoteFileCustom" | grep -i '^Content-Length:.*$' | awk '{sub("\r",""); print $2} ')"
|
|
||||||
|
|
||||||
if [[ "$RemoteSize" -gt "0" ]]; then
|
|
||||||
LocalFile=~/Downloads/TeamViewerQS-gal.tgz
|
|
||||||
RemoteFile=$RemoteFileCustom
|
|
||||||
RemoteSize=$RemoteSizeCustom
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
LocalSize="$(wc -c "$LocalFile" 2>/dev/null | awk '{ print $1 }')"
|
|
||||||
|
|
||||||
if [[ ! -r "${LocalFile}" ]] || [ "$LocalSize" != "$RemoteSize" ]; then
|
|
||||||
echo "Downloading file into $LocalFile..."
|
|
||||||
curl -Lo "$LocalFile" "$RemoteFile"
|
|
||||||
else
|
|
||||||
echo "$LocalFile exists and is same size as on server, using existing file..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -fR /tmp/tvqs 2>&1 > /dev/null
|
|
||||||
mkdir -p /tmp/tvqs
|
|
||||||
pushd /tmp/tvqs > /dev/null
|
|
||||||
tar xzf "$LocalFile"
|
|
||||||
cd teamviewerqs
|
|
||||||
echo "Launching TeamViewer Quick Support in the background from $PWD, it should startup in a few seconds..."
|
|
||||||
./teamviewer &
|
|
||||||
sleep 8
|
|
||||||
popd
|
|
||||||
printf "TeamViewer launched, you might want to hit <ENTER> if you don't see the prompt\n\n"
|
|
|
@ -1,4 +1,5 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
USER_HOME=$HOME
|
USER_HOME=$HOME
|
||||||
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
||||||
. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions
|
. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
SHOW_ALIASES=0
|
||||||
|
SHOW_FUNCTIONS=0
|
||||||
|
SHOW_MEMBASED=0
|
||||||
|
SHOW_SCRIPTS=0
|
||||||
|
|
||||||
|
NAME="${0##*/}"
|
||||||
|
eval set -- $(getopt --name "$NAME" --options 'afmsh' --longoptions aliases,functions,membased,scripts,all,help -- "${@}")
|
||||||
|
|
||||||
|
ARG_COUNT=0
|
||||||
|
SHOW_USAGE=0
|
||||||
|
while [[ $# -gt 0 ]]
|
||||||
|
do
|
||||||
|
opt="$1";
|
||||||
|
#expose next argument
|
||||||
|
shift;
|
||||||
|
case "$opt" in
|
||||||
|
'--' ) break 2;;
|
||||||
|
'-h'|'-?' )
|
||||||
|
opt='--help' ;;
|
||||||
|
'-a' )
|
||||||
|
opt='--aliases' ;;
|
||||||
|
'-f' )
|
||||||
|
opt='--functions' ;;
|
||||||
|
'-m' )
|
||||||
|
opt='--membased' ;;
|
||||||
|
'-s' )
|
||||||
|
opt='--scripts' ;;
|
||||||
|
esac
|
||||||
|
((ARG_COUNT++))
|
||||||
|
case "$opt" in
|
||||||
|
'--help' ) SHOW_USAGE=1; break 2;;
|
||||||
|
'--aliases' )
|
||||||
|
SHOW_ALIASES=1 ;;
|
||||||
|
'--functions' )
|
||||||
|
SHOW_FUNCTIONS=1 ;;
|
||||||
|
'--membased' )
|
||||||
|
SHOW_MEMBASED=1 ;;
|
||||||
|
'--scripts' )
|
||||||
|
SHOW_SCRIPTS=1 ;;
|
||||||
|
*) echo >&2 "Invalid option: $@"; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# If no args, show_usage
|
||||||
|
[[ $ARG_COUNT -eq 0 ]] && SHOW_SCRIPTS=0
|
||||||
|
|
||||||
|
if [[ "$SHOW_USAGE" == "1" ]]; then
|
||||||
|
printf "%s\n" \
|
||||||
|
"${0##*/}: ${0##*/} [-afhms] [--aliases] [--functions] [--help] [--membased] [--script]" \
|
||||||
|
" List POLARISqb productivity and helpdesk commands supplied by ITOps" \
|
||||||
|
"" \
|
||||||
|
" Options:" \
|
||||||
|
" -a | --aliases List aliases defined in Pqb startup scripts" \
|
||||||
|
" -f | --functions List functions defined in Pqb startup scripts" \
|
||||||
|
" -h | --help Display this usage message" \
|
||||||
|
" -m | --membased List all memory based commands (aka, aliases " \
|
||||||
|
" and functions)." \
|
||||||
|
" -s | --scripts List Pqb supplied utility scripts" \
|
||||||
|
" This is the default when no arguments are passed" \
|
||||||
|
""
|
||||||
|
|
||||||
|
return 2>/dev/null || exit
|
||||||
|
fi
|
||||||
|
FILTER=""
|
||||||
|
if [[ "$SHOW_ALIASES" == "1" || "$SHOW_MEMBASED" == "1" ]]; then
|
||||||
|
FILTER+="^\W*alias\|"
|
||||||
|
fi
|
||||||
|
if [[ "$SHOW_FUNCTIONS" == "1" || "$SHOW_MEMBASED" == "1" ]]; then
|
||||||
|
FILTER+="^\W*functions\|"
|
||||||
|
fi
|
||||||
|
if [[ -n "$FILTER" ]]; then
|
||||||
|
FILTER=${FILTER%\\|*}
|
||||||
|
find ~/.pqb.shrc.d -type f \
|
||||||
|
| xargs grep "${FILTER}" \
|
||||||
|
| sed 's/^.*\.d\///; s/:.*function /:(f) /; s/() {.*$//; s/:.*alias /:(a) /; s/=.*$//;'
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "$SHOW_ALIASES" == "0" && "$SHOW_MEMBASED" == "0" && "$SHOW_MEMBASED" == "0" ]] && SHOW_SCRIPTS=1
|
||||||
|
|
||||||
|
if [[ "$SHOW_SCRIPTS" == "1" ]]; then
|
||||||
|
find ~/.local/bin -executable -type f -name "pqb*" -printf "%f\n"
|
||||||
|
fi
|
|
@ -0,0 +1,70 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
USER_HOME=$HOME
|
||||||
|
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
||||||
|
|
||||||
|
source $(ls -1 ~/.*.shrc | head -1); [[ -z "${SHRC_D}" ]] && { echo "ERROR: Couldn't load ~/.*.shrc script!" 1>&2; return 1 2>/dev/null; exit 1; }
|
||||||
|
source ${SHRC_D}/${SHELL##*/}.pre/21_aliases
|
||||||
|
source ${SHRC_D}/01_util.functions
|
||||||
|
source ${SHRC_D}/97_chezmoi_aliases
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
require_sudo \
|
||||||
|
|| eval $(error 3 "POLARISqb: Not in sudo group, skipping $(basename $0)")
|
||||||
|
|
||||||
|
printf "%s\n" \
|
||||||
|
"POLARISqb Workstation/Laptop Owner initialization tool" \
|
||||||
|
"" \
|
||||||
|
"The machine will be initialized with the following values unless" \
|
||||||
|
"specified otherwise:" \
|
||||||
|
"" \
|
||||||
|
$(cz-import-data) \
|
||||||
|
""
|
||||||
|
|
||||||
|
eval "$(cz-import-data)"
|
||||||
|
|
||||||
|
if [[ -z "${CZ_PQB_DATA_LOCAL_USER_NAME}" ]]; then eval $(error 1 \
|
||||||
|
"local_user_name not defined in 'cehzmoi data', " "please run 'chezmoi init' or 'chezmoi edit-config' to fix, then try again"
|
||||||
|
); fi
|
||||||
|
|
||||||
|
if [[ -n "$(getent passwd ${CZ_PQB_DATA_LOCAL_USER_NAME})" ]]; then eval $(error 2 \
|
||||||
|
"User '${CZ_PQB_DATA_LOCAL_USER_NAME}' already exists, aborting."
|
||||||
|
); fi
|
||||||
|
|
||||||
|
#gecos field: "Full_Name,Room_Number,Work_Phone,Home_Phone,Other"
|
||||||
|
sudo adduser --disabled-password --gecos "${CZ_PQB_DATA_LOCAL_OWNER_NAME},,,,${CZ_PQB_DATA_EMAIL}" ${CZ_PQB_DATA_LOCAL_USER_NAME}
|
||||||
|
sudo adduser ${CZ_PQB_DATA_LOCAL_USER_NAME} sudo
|
||||||
|
INITIAL_PASSWORD='password'
|
||||||
|
printf "${CZ_PQB_DATA_LOCAL_USER_NAME}:${INITIAL_PASSWORD}" | sudo chpasswd
|
||||||
|
|
||||||
|
NEW_USER_HOME=$( eval "printf ~${CZ_PQB_DATA_LOCAL_USER_NAME}" )
|
||||||
|
if [[ -z "${NEW_USER_HOME}" ]]; then eval $(error 3 \
|
||||||
|
"Something is wrong, couldn't find the home dir for ${CZ_PQB_DATA_LOCAL_USER_NAME}!"
|
||||||
|
); fi
|
||||||
|
|
||||||
|
NEW_HOSTNAME="${CZ_PQB_DATA_LOCAL_USER_NAME}-pqb"
|
||||||
|
[[ "$(hostname)" != "${NEW_HOSTNAME}" ]] && sudo hostname $NEW_HOSTNAME
|
||||||
|
|
||||||
|
_CZ_REMOTE_URL=$(chezmoi git -- remote get-url origin)
|
||||||
|
_CZ_REMOTE_BRANCH=$(chezmoi git -- branch --show-current)
|
||||||
|
_CZ_DATA_PAIRS="$(cz-import-data promptString)"
|
||||||
|
cat ~/.config/chezmoi/chezmoi.toml | env sudo -u ${CZ_PQB_DATA_LOCAL_USER_NAME} -- sh -c "mkdir -p ~/.config/chezmoi; cat - > ~/.config/chezmoi/chezmoi.toml"
|
||||||
|
sudo -u ${CZ_PQB_DATA_LOCAL_USER_NAME} -- sh -c "cd ~; $(curl -fsLS chezmoi.io/get)" -- init --promptString="${_CZ_DATA_PAIRS}" --apply --branch "${_CZ_REMOTE_BRANCH}" "${_CZ_REMOTE_URL}"
|
||||||
|
|
||||||
|
echo "Chezmoi complete"
|
||||||
|
|
||||||
|
CUR_USER=$SUDO_USER
|
||||||
|
[[ -z "$CUR_USER" ]] && CUR_USER=$USER
|
||||||
|
|
||||||
|
# setup local git config values
|
||||||
|
git config --global --get user.email > /dev/null || git config --global user.email "${CUR_USER}@${NEW_HOSTNAME}"
|
||||||
|
git config --global --get user.name > /dev/null || git config --global user.name $(getent passwd $USER | cut -d':' -f5 | cut -d',' -f1)
|
||||||
|
|
||||||
|
sudo -u ${CZ_PQB_DATA_LOCAL_USER_NAME} -- sh -c "cd ~; git config --global user.email '${CZ_PQB_DATA_EMAIL}' && git config --global user.name '${CZ_PQB_DATA_LOCAL_OWNER_NAME}'"
|
||||||
|
|
||||||
|
sudo chage -d0 ${CZ_PQB_DATA_LOCAL_USER_NAME}
|
||||||
|
|
||||||
|
#${CZ_PQB_DATA_EMAIL}
|
||||||
|
#${CZ_PQB_DATA_LOCAL_OWNER_NAME}
|
||||||
|
#${CZ_PQB_DATA_LOCAL_USER_NAME}
|
Loading…
Reference in New Issue