Starting rewrite
This commit is contained in:
parent
1d68354438
commit
788aa7db35
71
.alias
71
.alias
@ -1,71 +0,0 @@
|
|||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# ~/.alias
|
|
||||||
#
|
|
||||||
# Maintainer:
|
|
||||||
# TheFlyingFool - tff@theflyingfool.com
|
|
||||||
# http://theflyingfool.com
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Credits:
|
|
||||||
# Package Management Section
|
|
||||||
# https://gist.github.com/rroblak/8137276
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
alias vi="vim" #Insure vim
|
|
||||||
tmux_alias() {
|
|
||||||
if [[ $# -eq 0 ]]; then
|
|
||||||
tmux attach
|
|
||||||
else
|
|
||||||
tmux "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
alias tmux=tmux_alias
|
|
||||||
#Coloration of core utils
|
|
||||||
alias grep="grep -n --color=auto" #grep
|
|
||||||
alias egrep='egrep --color=auto'
|
|
||||||
alias fgrep='fgrep --color=auto'
|
|
||||||
alias ls="ls --color=auto" #ls
|
|
||||||
|
|
||||||
#VimLess
|
|
||||||
alias less="/usr/share/vim/vim91/macros/less.sh"
|
|
||||||
|
|
||||||
if [ -e "/usr/bin/apt-get" ] ; then # Apt-based distros (Debian, Ubuntu, etc.)
|
|
||||||
aptget="/usr/bin/apt-get" # I currently do not use any apt-based distros
|
|
||||||
sudoaptget="sudo $aptget"
|
|
||||||
aptcache="/usr/bin/apt-cache"
|
|
||||||
dpkg="/usr/bin/dpkg"
|
|
||||||
alias S="$sudoaptget install"
|
|
||||||
alias Syu="$sudoaptget update"
|
|
||||||
alias Ss="$aptcache search"
|
|
||||||
alias Si="$aptcache show"
|
|
||||||
elif [ -e "/usr/bin/yay" ] ; then
|
|
||||||
yay="/usr/bin/yay"
|
|
||||||
sudoyay="sudo $yay"
|
|
||||||
alias S="$yay -S"
|
|
||||||
alias Syy="$yay -Syy"
|
|
||||||
alias Syu="$yay -Syu"
|
|
||||||
alias Rns="$yay -Rns"
|
|
||||||
alias Ss="$yay -Ss"
|
|
||||||
alias Si="$yay -Si"
|
|
||||||
alias Q="$yay -Q"
|
|
||||||
elif [ -e "/usr/bin/pacman" ] ; then # Arch Linux
|
|
||||||
pacman="/usr/bin/pacman --color=auto"
|
|
||||||
sudopacman="sudo $pacman --color=auto"
|
|
||||||
alias S="$sudopacman -S"
|
|
||||||
alias Syy="$sudopacman -Syy"
|
|
||||||
alias Syu="$sudopacman -Syu"
|
|
||||||
alias Rns="$sudopacman -Rns"
|
|
||||||
alias Ss="$pacman -Ss"
|
|
||||||
alias Si="$pacman -Si"
|
|
||||||
alias Q="$pacman -Q"
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Dotfile Management
|
|
||||||
alias dot="git --git-dir=$HOME/.dot/ --work-tree=$HOME"
|
|
||||||
|
|
||||||
##Convenience
|
|
||||||
alias 'mkdir=mkdir -p'
|
|
||||||
|
|
||||||
#list empty dirs
|
|
||||||
alias le="find . -type d -empty"
|
|
75
.bashrc
75
.bashrc
@ -1,75 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
#
|
|
||||||
# ~/.bashrc
|
|
||||||
#
|
|
||||||
# https://git.theflyingfool.com/theflyingfool/dot/blob/master/bash/bashrc
|
|
||||||
#
|
|
||||||
# Maintainer:
|
|
||||||
# TheFlyingFool - tff@theflyingfool.com
|
|
||||||
# http://theflyingfool.com
|
|
||||||
#
|
|
||||||
# Version:
|
|
||||||
# 21/02/2015 23:03
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
|
||||||
[[ $- != *i* ]] && return
|
|
||||||
|
|
||||||
## Add color support to man pages
|
|
||||||
man() {
|
|
||||||
env LESS_TERMCAP_mb=$(printf "\e[1;31m") \
|
|
||||||
LESS_TERMCAP_md=$(printf "\e[1;31m") \
|
|
||||||
LESS_TERMCAP_me=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_se=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
|
|
||||||
LESS_TERMCAP_ue=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_us=$(printf "\e[1;32m") \
|
|
||||||
man "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
#better color support for ls
|
|
||||||
eval $(dircolors -b)
|
|
||||||
|
|
||||||
#alias
|
|
||||||
|
|
||||||
source ~/.alias
|
|
||||||
|
|
||||||
#less highlighting
|
|
||||||
export LESSOPEN="| /usr/bin/source-highlight-esc.sh %s"
|
|
||||||
export LESS=' -R '
|
|
||||||
|
|
||||||
## Typing a dir without cd will change directories anyway
|
|
||||||
shopt -s autocd
|
|
||||||
|
|
||||||
## Allows for tab completion using sudo / man
|
|
||||||
complete -cf sudo
|
|
||||||
complete -cf man
|
|
||||||
|
|
||||||
|
|
||||||
shopt -s checkwinsize
|
|
||||||
|
|
||||||
shopt -s histappend
|
|
||||||
|
|
||||||
[[ "$PS1" ]] && /usr/bin/fortune
|
|
||||||
|
|
||||||
PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"
|
|
||||||
#PS1='[\u@\h \W]\$ '
|
|
||||||
PS2='> '
|
|
||||||
PS3='> '
|
|
||||||
PS4='+ '
|
|
||||||
|
|
||||||
case ${TERM} in
|
|
||||||
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
|
|
||||||
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
|
|
||||||
|
|
||||||
;;
|
|
||||||
screen)
|
|
||||||
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
16
.gitconfig
16
.gitconfig
@ -1,9 +1,9 @@
|
|||||||
[user]
|
[user]
|
||||||
name = TheFlyingFool
|
email = nick@theflyingfool.com
|
||||||
email = nick.kyky@gmail.com
|
name = TheFlyingFool
|
||||||
[diff]
|
; [diff]
|
||||||
tool = vscode
|
; tool = vscode
|
||||||
[difftool "vscode"]
|
; [difftool "vscode"]
|
||||||
cmd = "code --wait --diff $LOCAL $REMOTE "
|
; cmd = "code --wait --diff $LOCAL $REMOTE "
|
||||||
[fetch]
|
; [fetch]
|
||||||
prune = true
|
; prune = true
|
||||||
|
116
.tmux.conf
116
.tmux.conf
@ -1,116 +0,0 @@
|
|||||||
# Switch to screen prefix
|
|
||||||
# Ctrl-a
|
|
||||||
unbind C-b
|
|
||||||
set -g prefix C-a
|
|
||||||
bind-key b send-prefix
|
|
||||||
|
|
||||||
|
|
||||||
set -g base-index 1 # start windows numbering at 1
|
|
||||||
set-window-option -g pane-base-index 1 # make pane numbering consistent with windows
|
|
||||||
|
|
||||||
set-window-option -g automatic-rename on # rename window to reflect current program
|
|
||||||
set -g renumber-windows on # renumber windows when a window is closed
|
|
||||||
|
|
||||||
set -g set-titles on # set terminal title
|
|
||||||
|
|
||||||
|
|
||||||
## Commonly found settings not 100% sure on the point
|
|
||||||
set-window-option -g monitor-activity on
|
|
||||||
set-option -g visual-activity on
|
|
||||||
|
|
||||||
#Double cntl-a goes to last window
|
|
||||||
bind-key C-a last-window
|
|
||||||
|
|
||||||
# Turn on mouse support
|
|
||||||
set-option -g mouse on
|
|
||||||
|
|
||||||
bind-key -n C-S-Left swap-pane -t :-
|
|
||||||
bind-key -n C-S-Right swap-pane -t :+
|
|
||||||
|
|
||||||
#Cntl-a Backspace goes to previous window
|
|
||||||
unbind BSpace
|
|
||||||
bind BSpace previous-window
|
|
||||||
|
|
||||||
#Splitting to current $PWD
|
|
||||||
bind % split-window -c "#{pane_current_path}" -h
|
|
||||||
bind '"' split-window -c "#{pane_current_path}" -v
|
|
||||||
bind c new-window -c "#{pane_current_path}"
|
|
||||||
|
|
||||||
#kill window/server with confirm
|
|
||||||
bind-key k confirm kill-window
|
|
||||||
bind-key K confirm kill-server
|
|
||||||
|
|
||||||
|
|
||||||
# Status bar
|
|
||||||
# Enable two lines for the status bar
|
|
||||||
set-option -g status 2
|
|
||||||
set-option -g status-position bottom
|
|
||||||
|
|
||||||
# First line: Center (Window List)
|
|
||||||
set-option -g status-format[0] '#[align=centre]#{W:#{E:window-status-format} ,#{E:window-status-current-format} }'
|
|
||||||
|
|
||||||
# Second line: Center (Time/Date, ACPI, CPU/Mem, Hostname)
|
|
||||||
set-option -g status-format[1] "#[align=centre]#[fg=red][Pending Updates: #(checkupdates | wc -l || echo "N/A")] #[fg=cyan][%H:%M %d-%b-%y] #[fg=yellow][#(acpi -b | awk -F', ' '{print $2, $3}')] #[fg=green,bg=default,bright][#(tmux-mem-cpu-load)] #[fg=blue][#h]"
|
|
||||||
|
|
||||||
# Ensure window list is properly justified
|
|
||||||
# set-option -g status-justify centre # Changed to centre
|
|
||||||
|
|
||||||
# Background color for status bar (Blue)
|
|
||||||
set -g status-bg colour24
|
|
||||||
set -g status-fg colour231
|
|
||||||
|
|
||||||
# Window list formatting
|
|
||||||
set-window-option -g window-status-format '#[fg=colour117,bg=colour24] #I:#W #[fg=colour24,bg=colour24]'
|
|
||||||
set-window-option -g window-status-current-format '#[fg=colour16,bg=colour231] #I:#W #[fg=colour24,bg=colour24]'
|
|
||||||
|
|
||||||
# Bind function keys to windows
|
|
||||||
bind -n F1 select-window -t :=1
|
|
||||||
bind -n F2 select-window -t :=2
|
|
||||||
bind -n F3 select-window -t :=3
|
|
||||||
bind -n F4 select-window -t :=4
|
|
||||||
bind -n F5 select-window -t :=5
|
|
||||||
bind -n F6 select-window -t :=6
|
|
||||||
bind -n F7 select-window -t :=7
|
|
||||||
bind -n F8 select-window -t :=8
|
|
||||||
bind -n F9 select-window -t :=9
|
|
||||||
bind -n F10 select-window -t :=10
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#start programs
|
|
||||||
new -s mysession -n "sys-mon" glances
|
|
||||||
neww -n "Log" "journalctl -f"
|
|
||||||
#neww -n "Music" if-shell -b '[[ "$TERM" == "xterm-kitty" ]]' "rmpc" if-shell -b '[["$TERM" == " != "kitty" ]] "ncmpcpp"
|
|
||||||
neww -n "ARA Server" "bash -c 'cd ~/Repos/homelab-ansible && export ARA_SETTINGS="/home/nick/Repos/homelab-ansible/.ara/server/settings.yaml" && source .venv/bin/activate && ara-manage runserver'"
|
|
||||||
neww
|
|
||||||
#neww -n "Music" ncmpcpp
|
|
||||||
#neww -n "Deluge" deluge-console
|
|
||||||
|
|
||||||
#reload tmux config
|
|
||||||
bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
|
|
||||||
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
|
|
||||||
|
|
||||||
#vi keybindings
|
|
||||||
set -g mode-keys vi
|
|
||||||
|
|
||||||
#send actual f keys
|
|
||||||
bind F1 send-keys F1
|
|
||||||
bind F2 send-keys F2
|
|
||||||
bind F3 send-keys F3
|
|
||||||
bind F4 send-keys F4
|
|
||||||
bind F5 send-keys F5
|
|
||||||
bind F6 send-keys F6
|
|
||||||
bind F7 send-keys F7
|
|
||||||
bind F8 send-keys F8
|
|
||||||
bind F9 send-keys F9
|
|
||||||
bind F10 send-keys F10
|
|
||||||
bind F11 send-keys F11
|
|
||||||
bind F12 send-keys F12
|
|
||||||
|
|
||||||
set -g history-limit 50000
|
|
||||||
|
|
||||||
set-window-option -g aggressive-resize on
|
|
||||||
|
|
||||||
set-option -g automatic-rename on
|
|
||||||
setw -g automatic-rename on
|
|
73
.vimrc
73
.vimrc
@ -1,73 +0,0 @@
|
|||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
||||||
"
|
|
||||||
" ~/.vimrc
|
|
||||||
"
|
|
||||||
" https://git.theflyingfool.com/theflyingfool/dot/blob/master/vim/vimrc
|
|
||||||
"
|
|
||||||
" Maintainer:
|
|
||||||
" TheFlyingFool - tff@theflyingfool.com
|
|
||||||
" http://theflyingfool.com
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" Mon Mar 16 19:37:55 CDT 2015
|
|
||||||
"
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
||||||
|
|
||||||
" Visual Settings
|
|
||||||
set ruler
|
|
||||||
" Show Line Number
|
|
||||||
set nu
|
|
||||||
" make :w!! do a sudo save
|
|
||||||
cmap w!! w !sudo tee > /dev/null %
|
|
||||||
|
|
||||||
" Search settings
|
|
||||||
" Searches as you type
|
|
||||||
" Ignores case while searching
|
|
||||||
" If case specified only search that
|
|
||||||
" Highlight search results
|
|
||||||
" Forces VIM instead of Vi
|
|
||||||
set incsearch
|
|
||||||
set ignorecase
|
|
||||||
set smartcase
|
|
||||||
set hlsearch
|
|
||||||
set nocompatible
|
|
||||||
filetype off
|
|
||||||
|
|
||||||
|
|
||||||
" Load Vundle
|
|
||||||
"set rtp+=~/.vim/bundle/Vundle.vim
|
|
||||||
"call vundle#begin()
|
|
||||||
"Plugin 'VundleVim/Vundle.vim'
|
|
||||||
|
|
||||||
" Plugin 'Valloric/YouCompleteMe'
|
|
||||||
|
|
||||||
" Plugins must be loaded before following two lines
|
|
||||||
"call vundle#end()
|
|
||||||
filetype plugin indent on
|
|
||||||
|
|
||||||
" Syntax Highlighting
|
|
||||||
" Forces .md files to load as Markdown
|
|
||||||
syntax on
|
|
||||||
au BufRead,BufNewFile *.md set filetype=markdown
|
|
||||||
|
|
||||||
"Turns on Spell Check
|
|
||||||
:setlocal spell spelllang=en_us
|
|
||||||
|
|
||||||
|
|
||||||
" Normal mode
|
|
||||||
nnoremap <C-j> :m .+1<CR>==
|
|
||||||
nnoremap <C-k> :m .-2<CR>==
|
|
||||||
|
|
||||||
" Insert mode
|
|
||||||
inoremap <C-j> <ESC>:m .+1<CR>==gi
|
|
||||||
inoremap <C-k> <ESC>:m .-2<CR>==gi
|
|
||||||
|
|
||||||
" Visual mode
|
|
||||||
vnoremap <C-j> :m '>+1<CR>gv=gv
|
|
||||||
vnoremap <C-k> :m '<-2<CR>gv=gv
|
|
||||||
|
|
||||||
" fix some common typos
|
|
||||||
iabbrev waht what
|
|
||||||
iabbrev tehn then
|
|
||||||
|
|
||||||
set modeline
|
|
217
.zfunc/_poetry
217
.zfunc/_poetry
@ -1,217 +0,0 @@
|
|||||||
#compdef poetry
|
|
||||||
|
|
||||||
_poetry_0943c661d469fe49_complete()
|
|
||||||
{
|
|
||||||
local state com cur
|
|
||||||
local -a opts
|
|
||||||
local -a coms
|
|
||||||
|
|
||||||
cur=${words[${#words[@]}]}
|
|
||||||
|
|
||||||
# lookup for command
|
|
||||||
for word in ${words[@]:1}; do
|
|
||||||
if [[ $word != -* ]]; then
|
|
||||||
com=$word
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${cur} == --* ]]; then
|
|
||||||
state="option"
|
|
||||||
opts+=("--ansi:Force ANSI output." "--directory:The working directory for the Poetry command \(defaults to the current working directory\). All command-line arguments will be resolved relative to the given directory." "--help:Display help for the given command. When no command is given display help for the list command." "--no-ansi:Disable ANSI output." "--no-cache:Disables Poetry source caches." "--no-interaction:Do not ask any interactive question." "--no-plugins:Disables plugins." "--project:Specify another path as the project root. All command-line arguments will be resolved relative to the current working directory." "--quiet:Do not output any message." "--verbose:Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug." "--version:Display this application version.")
|
|
||||||
elif [[ $cur == $com ]]; then
|
|
||||||
state="command"
|
|
||||||
coms+=("about:Shows information about Poetry." "add:Adds a new dependency to pyproject.toml and installs it." "build:Builds a package, as a tarball and a wheel by default." "'cache clear':Clears a Poetry cache by name." "'cache list':List Poetry\'s caches." "check:Validates the content of the pyproject.toml file and its consistency with the poetry.lock file." "config:Manages configuration settings." "'debug info':Shows debug information." "'debug resolve':Debugs dependency resolution." "'debug tags':Shows compatible tags for your project\'s current active environment." "'env activate':Print the command to activate a virtual environment." "'env info':Displays information about the current environment." "'env list':Lists all virtualenvs associated with the current project." "'env remove':Remove virtual environments associated with the project." "'env use':Activates or creates a new virtualenv for the current project." "help:Displays help for a command." "init:Creates a basic pyproject.toml file in the current directory." "install:Installs the project dependencies." "list:Lists commands." "lock:Locks the project dependencies." "new:Creates a new Python project at <path\>." "publish:Publishes a package to a remote repository." "'python install':Install the specified Python version from the Python Standalone Builds project. \(experimental feature\)" "'python list':Shows Python versions available for this environment. \(experimental feature\)" "'python remove':Remove the specified Python version if managed by Poetry. \(experimental feature\)" "remove:Removes a package from the project dependencies." "run:Runs a command in the appropriate environment." "search:Searches for packages on remote repositories." "'self add':Add additional packages to Poetry\'s runtime environment." "'self install':Install locked packages \(incl. addons\) required by this Poetry installation." "'self lock':Lock the Poetry installation\'s system requirements." "'self remove':Remove additional packages from Poetry\'s runtime environment." "'self show':Show packages from Poetry\'s runtime environment." "'self show plugins':Shows information about the currently installed plugins." "'self sync':Sync Poetry\'s own environment according to the locked packages \(incl. addons\) required by this Poetry installation." "'self update':Updates Poetry to the latest version." "show:Shows information about packages." "'source add':Add source configuration for project." "'source remove':Remove source configured for the project." "'source show':Show information about sources configured for the project." "sync:Update the project\'s environment according to the lockfile." "update:Update the dependencies as according to the pyproject.toml file." "version:Shows the version of the project or bumps it when a valid bump rule is provided.")
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
(command)
|
|
||||||
_describe 'command' coms
|
|
||||||
;;
|
|
||||||
(option)
|
|
||||||
case "$com" in
|
|
||||||
|
|
||||||
(about)
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(add)
|
|
||||||
opts+=("--allow-prereleases:Accept prereleases." "--dev:Add as a development dependency. \(shortcut for \'-G dev\'\)" "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--editable:Add vcs/path dependencies as editable." "--extras:Extras to activate for the dependency." "--group:The group to add the dependency to." "--lock:Do not perform operations \(only update the lockfile\)." "--markers:Environment markers which describe when the dependency should be installed." "--optional:Add as an optional dependency to an extra." "--platform:Platforms for which the dependency must be installed." "--python:Python version for which the dependency must be installed." "--source:Name of the source to use to install the package.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(build)
|
|
||||||
opts+=("--clean:Clean output directory before building." "--config-settings:Provide config settings that should be passed to backend in <key\>=<value\> format." "--format:Limit the format to either sdist or wheel." "--local-version:Add or replace a local version label to the build. \(Deprecated\)" "--output:Set output directory for build artifacts. Default is \`dist\`.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('cache clear')
|
|
||||||
opts+=("--all:Clear all entries in the cache.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('cache list')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(check)
|
|
||||||
opts+=("--lock:Checks that poetry.lock exists for the current version of pyproject.toml." "--strict:Fail if check reports warnings.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(config)
|
|
||||||
opts+=("--list:List configuration settings." "--local:Set/Get from the project\'s local configuration." "--migrate:Migrate outdated configuration settings." "--unset:Unset configuration setting.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('debug info')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('debug resolve')
|
|
||||||
opts+=("--extras:Extras to activate for the dependency." "--install:Show what would be installed for the current system." "--python:Python version\(s\) to use for resolution." "--tree:Display the dependency tree.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('debug tags')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('env activate')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('env info')
|
|
||||||
opts+=("--executable:Only display the environment\'s python executable path." "--path:Only display the environment\'s path.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('env list')
|
|
||||||
opts+=("--full-path:Output the full paths of the virtualenvs.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('env remove')
|
|
||||||
opts+=("--all:Remove all managed virtual environments associated with the project.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('env use')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(help)
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(init)
|
|
||||||
opts+=("--author:Author name of the package." "--dependency:Package to require, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--description:Description of the package." "--dev-dependency:Package to require for development, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--license:License of the package." "--name:Name of the package." "--python:Compatible Python versions.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(install)
|
|
||||||
opts+=("--all-extras:Install all extra dependencies." "--all-groups:Install dependencies from all groups." "--compile:Compile Python source files to bytecode." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--extras:Extra sets of dependencies to install." "--no-directory:Do not install any directory path dependencies\; useful to install dependencies without source code, e.g. for caching of Docker layers\)" "--no-root:Do not install the root package \(the current project\)." "--only:The only dependency groups to include." "--only-root:Exclude all dependencies." "--sync:Synchronize the environment with the locked packages and the specified groups. \(Deprecated\)" "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(list)
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(lock)
|
|
||||||
opts+=("--regenerate:Ignore existing lock file and overwrite it with a new lock file created from scratch.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(new)
|
|
||||||
opts+=("--author:Author name of the package." "--dependency:Package to require, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--description:Description of the package." "--dev-dependency:Package to require for development, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--flat:Use the flat layout for the project." "--interactive:Allow interactive specification of project configuration." "--license:License of the package." "--name:Set the resulting package name." "--python:Compatible Python versions." "--readme:Specify the readme file format. Default is md." "--src:Use the src layout for the project. Deprecated: This is the default option now.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(publish)
|
|
||||||
opts+=("--build:Build the package before publishing." "--cert:Certificate authority to access the repository." "--client-cert:Client certificate to access the repository." "--dist-dir:Dist directory where built artifact are stored. Default is \`dist\`." "--dry-run:Perform all actions except upload the package." "--password:The password to access the repository." "--repository:The repository to publish the package to." "--skip-existing:Ignore errors from files already existing in the repository." "--username:The username to access the repository.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('python install')
|
|
||||||
opts+=("--clean:Clean up installation if check fails." "--free-threaded:Use free-threaded version if available." "--implementation:Python implementation to use. \(cpython, pypy\)" "--reinstall:Reinstall if installation already exists.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('python list')
|
|
||||||
opts+=("--all:List all versions, including those available for download." "--implementation:Python implementation to search for." "--managed:List only Poetry managed Python versions.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('python remove')
|
|
||||||
opts+=("--implementation:Python implementation to use. \(cpython, pypy\)")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(remove)
|
|
||||||
opts+=("--dev:Remove a package from the development dependencies. \(shortcut for \'-G dev\'\)" "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--group:The group to remove the dependency from." "--lock:Do not perform operations \(only update the lockfile\).")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(run)
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(search)
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self add')
|
|
||||||
opts+=("--allow-prereleases:Accept prereleases." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--editable:Add vcs/path dependencies as editable." "--extras:Extras to activate for the dependency." "--source:Name of the source to use to install the package.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self install')
|
|
||||||
opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--sync:Synchronize the environment with the locked packages and the specified groups. \(Deprecated\)")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self lock')
|
|
||||||
opts+=("--regenerate:Ignore existing lock file and overwrite it with a new lock file created from scratch.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self remove')
|
|
||||||
opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\).")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self show')
|
|
||||||
opts+=("--addons:List only add-on packages installed." "--latest:Show the latest version." "--outdated:Show the latest version but only for packages that are outdated." "--tree:List the dependencies as a tree.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self show plugins')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self sync')
|
|
||||||
opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\).")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('self update')
|
|
||||||
opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--preview:Allow the installation of pre-release versions.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(show)
|
|
||||||
opts+=("--all:Show all packages \(even those not compatible with current system\)." "--latest:Show the latest version." "--no-truncate:Do not truncate the output based on the terminal width." "--only:The only dependency groups to include." "--outdated:Show the latest version but only for packages that are outdated." "--top-level:Show only top-level dependencies." "--tree:List the dependencies as a tree." "--why:When showing the full list, or a --tree for a single package, display whether they are a direct dependency or required by other packages" "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('source add')
|
|
||||||
opts+=("--priority:Set the priority of this source. One of: primary, supplemental, explicit. Defaults to primary, but will switch to supplemental in a later release.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
('source remove')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
('source show')
|
|
||||||
opts+=()
|
|
||||||
;;
|
|
||||||
|
|
||||||
(sync)
|
|
||||||
opts+=("--all-extras:Install all extra dependencies." "--all-groups:Install dependencies from all groups." "--compile:Compile Python source files to bytecode." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--extras:Extra sets of dependencies to install." "--no-directory:Do not install any directory path dependencies\; useful to install dependencies without source code, e.g. for caching of Docker layers\)" "--no-root:Do not install the root package \(the current project\)." "--only:The only dependency groups to include." "--only-root:Exclude all dependencies." "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(update)
|
|
||||||
opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--lock:Do not perform operations \(only update the lockfile\)." "--only:The only dependency groups to include." "--sync:Synchronize the environment with the locked packages and the specified groups." "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.")
|
|
||||||
;;
|
|
||||||
|
|
||||||
(version)
|
|
||||||
opts+=("--dry-run:Do not update pyproject.toml file" "--next-phase:Increment the phase of the current version" "--short:Output the version number only")
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
_describe 'option' opts
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# fallback to file completion
|
|
||||||
_arguments '*:file:_files'
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_poetry_0943c661d469fe49_complete "$@"
|
|
||||||
compdef _poetry_0943c661d469fe49_complete /home/nick/poetry
|
|
235
.zshrc
235
.zshrc
@ -1,235 +0,0 @@
|
|||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# ~/.zshrc
|
|
||||||
#
|
|
||||||
# Dot file git:
|
|
||||||
# https://
|
|
||||||
#
|
|
||||||
# Maintainer:
|
|
||||||
# TheFlyingFool - tff@theflyingfool.com
|
|
||||||
# http://theflyingfool.com
|
|
||||||
#
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Skip erything for non-interactive shell
|
|
||||||
[[ -z "$PS1" ]] && return
|
|
||||||
|
|
||||||
##History
|
|
||||||
HISTFILE=~/.zsh_history
|
|
||||||
HISTSIZE=100000
|
|
||||||
SAVEHIST=50000
|
|
||||||
setopt INC_APPEND_HISTORY
|
|
||||||
setopt incappendhistory
|
|
||||||
setopt sharehistory
|
|
||||||
setopt HIST_REDUCE_BLANKS
|
|
||||||
setopt HIST_IGNORE_ALL_DUPS
|
|
||||||
setopt appendhistory
|
|
||||||
setopt autocd
|
|
||||||
setopt beep
|
|
||||||
setopt nomatch
|
|
||||||
setopt correct
|
|
||||||
setopt noclobber
|
|
||||||
setopt prompt_subst
|
|
||||||
setopt notify
|
|
||||||
unsetopt extendedglob
|
|
||||||
bindkey -v
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# make history searchable with ctrl-r
|
|
||||||
bindkey "^r" history-incremental-search-backward
|
|
||||||
|
|
||||||
##Variables
|
|
||||||
export EDITOR="code"
|
|
||||||
export USE_EDITOR=$EDITOR
|
|
||||||
export VISUAL=$EDITOR
|
|
||||||
#export BROWSWER="vivaldi"
|
|
||||||
# fixes issue with atom
|
|
||||||
#export ELECTRON_TRASH="kioclient5 atom"
|
|
||||||
# export GITEA_TOKEN=a2a8542ad8fcf4de4156e9b5a83c09f826e53dc0
|
|
||||||
# export GITEA_TOKEN=55fa045ffdc1ffabbabcdc429e353e4883b04b17
|
|
||||||
##Alias
|
|
||||||
export SSH_AUTH_SOCK=/home/nick/.bitwarden-ssh-agent.sock
|
|
||||||
source ~/.alias
|
|
||||||
|
|
||||||
|
|
||||||
zstyle :compinstall filename '/home/nick/.zshrc'
|
|
||||||
|
|
||||||
autoload -Uz compinit
|
|
||||||
compinit
|
|
||||||
|
|
||||||
|
|
||||||
zstyle ':completion:*' rehash true
|
|
||||||
fpath+=~/.zfunc
|
|
||||||
|
|
||||||
##Colored man pages
|
|
||||||
|
|
||||||
man() {
|
|
||||||
env \
|
|
||||||
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
|
|
||||||
LESS_TERMCAP_md=$(printf "\e[1;31m") \
|
|
||||||
LESS_TERMCAP_me=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_se=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
|
|
||||||
LESS_TERMCAP_ue=$(printf "\e[0m") \
|
|
||||||
LESS_TERMCAP_us=$(printf "\e[1;32m") \
|
|
||||||
man "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
##Command not found
|
|
||||||
##Requires extra/pkgfile -- Arch Linux
|
|
||||||
if [ -f "/usr/share/doc/pkgfile/command-not-found.zsh" ]; then
|
|
||||||
source /usr/share/doc/pkgfile/command-not-found.zsh
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# The following lines were added by compinstall
|
|
||||||
|
|
||||||
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
|
|
||||||
zstyle ':completion:*' format ''\''Completing %d'\'''
|
|
||||||
zstyle ':completion:*' max-errors 3 numeric
|
|
||||||
zstyle ':completion:*' prompt 'Errors '\''%e'\'''
|
|
||||||
zstyle :compinstall filename '/home/nick/.zshrc'
|
|
||||||
|
|
||||||
autoload -Uz compinit
|
|
||||||
compinit
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# #eval 'keychain --eval id_ed25519'
|
|
||||||
# if [[ -f /usr/bin/keychain ]]; then
|
|
||||||
# keychain --agents gpg,ssh id_ed25519 31936033 github_rsa
|
|
||||||
# [ -z "$HOSTNAME" ] && HOSTNAME=`uname -n`
|
|
||||||
# [ -f $HOME/.keychian/$HOSTNAME-sh ]
|
|
||||||
# source $HOME/.keychain/$HOSTNAME-sh ]
|
|
||||||
# [ -f $HOME/.keychain/$HOSTNAME-sh-gpg ]
|
|
||||||
# source $HOME/.keychain/$HOSTNAME-sh-gpg
|
|
||||||
# fi
|
|
||||||
|
|
||||||
##Prompt
|
|
||||||
|
|
||||||
#Load Colors for Prompt
|
|
||||||
autoload -U colors && colors
|
|
||||||
#Enables a quick prompt switch, can be used with
|
|
||||||
# %prompt -l #Lists Prompts
|
|
||||||
# %prompt name #Selects Prompt
|
|
||||||
|
|
||||||
if [[ -n $SSH_CLIENT ]]; then
|
|
||||||
PROMPT="[%{$fg[yellow]%}%n%{$reset_color%}@%B%{$fg[red]%}%M%{$reset_color%}]%{$reset_color%}-%{$reset_color%}[%{$fg[green]%}%~%{$reset_color%}]
|
|
||||||
%#"
|
|
||||||
else
|
|
||||||
PROMPT="[%{$fg[yellow]%}%n%{$reset_color%}@%{$fg[cyan]%}%M%{$reset_color%}]%{$reset_color%}-%{$reset_color%}[%{$fg[green]%}%~%{$reset_color%}]
|
|
||||||
%#"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Modify the colors and symbols in these variables as desired.
|
|
||||||
GIT_PROMPT_SYMBOL="%{$fg[blue]%}±"
|
|
||||||
GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$reset_color%}"
|
|
||||||
GIT_PROMPT_SUFFIX="%{$fg[green]%}]%{$reset_color%}"
|
|
||||||
GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}"
|
|
||||||
GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}"
|
|
||||||
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}"
|
|
||||||
GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
|
||||||
GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
|
||||||
GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
|
|
||||||
|
|
||||||
# Show Git branch/tag, or name-rev if on detached head
|
|
||||||
parse_git_branch() {
|
|
||||||
(git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show different symbols as appropriate for various Git repository states
|
|
||||||
parse_git_state() {
|
|
||||||
|
|
||||||
# Compose this value via multiple conditional appends.
|
|
||||||
local GIT_STATE=""
|
|
||||||
|
|
||||||
local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')"
|
|
||||||
if [ "$NUM_AHEAD" -gt 0 ]; then
|
|
||||||
GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')"
|
|
||||||
if [ "$NUM_BEHIND" -gt 0 ]; then
|
|
||||||
GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)"
|
|
||||||
if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! git diff --quiet 2> /dev/null; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! git diff --cached --quiet 2> /dev/null; then
|
|
||||||
GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $GIT_STATE ]]; then
|
|
||||||
echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# If inside a Git repository, print its branch and state
|
|
||||||
git_prompt_string() {
|
|
||||||
local git_where="$(parse_git_branch)"
|
|
||||||
[ -n "$git_where" ] && echo "$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX"
|
|
||||||
}
|
|
||||||
|
|
||||||
## alt-s inserts "sudo" at start of line
|
|
||||||
insert_sudo() { zle beginning-of-line; zle -U "sudo " }
|
|
||||||
zle -N insert-sudo insert_sudo
|
|
||||||
bindkey "^[s" insert-sudo
|
|
||||||
|
|
||||||
|
|
||||||
# Set the right-hand prompt
|
|
||||||
RPS1='$(git_prompt_string)'
|
|
||||||
|
|
||||||
# Created by `pipx` on 2025-03-03 18:34:12
|
|
||||||
export PATH="$PATH:/home/nick/.local/bin"
|
|
||||||
|
|
||||||
# show_venv() {
|
|
||||||
# if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
|
|
||||||
# echo "($(basename $VIRTUAL_ENV))"
|
|
||||||
# fi
|
|
||||||
# }
|
|
||||||
#PS1='$(show_venv)'$PS1
|
|
||||||
|
|
||||||
# requires direnv to be installed
|
|
||||||
eval "$(direnv hook zsh)"
|
|
||||||
|
|
||||||
## UNTESTED NEEDS REVIEW
|
|
||||||
# SHOULD Allow > / >> to auto create directories
|
|
||||||
# # This function will be called before executing any command
|
|
||||||
# preexec() {
|
|
||||||
# # Match something like > ~/path/to/file or >> ~/path/to/file
|
|
||||||
# if [[ "$1" =~ '>>?\s*(~?/.+)' ]]; then
|
|
||||||
# local outfile=${match[1]}
|
|
||||||
# # Expand ~ to full path
|
|
||||||
# outfile=${outfile/#\~/$HOME}
|
|
||||||
# local outdir=$(dirname "$outfile")
|
|
||||||
|
|
||||||
# if [[ ! -d "$outdir" ]]; then
|
|
||||||
# echo "Output redirection to: $outfile"
|
|
||||||
# echo -n "Directory '$outdir' does not exist. Create it? [Y/n]: "
|
|
||||||
# read -r reply
|
|
||||||
# if [[ -z "$reply" || "$reply" =~ ^[Yy] ]]; then
|
|
||||||
# mkdir -p "$outdir"
|
|
||||||
# echo "✅ Created $outdir"
|
|
||||||
# else
|
|
||||||
# echo "❌ Skipped creating directory. Command might fail."
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# }
|
|
@ -7,11 +7,12 @@ My dotfiles for both Arch Linux and Windows
|
|||||||
### Checking out the repo
|
### Checking out the repo
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone --bare gitea@git.theflyingfool.com:theflyingfool/dotfiles.git $HOME/.dot
|
mkdir ~/Repos
|
||||||
alias dot='/usr/bin/git --git-dir="$HOME/.dot/" --work-tree="$HOME"'
|
cd Repos
|
||||||
|
git clone --bare gitea@git.theflyingfool.com:theflyingfool/dotfiles.git $HOME/Repos/dotfiles
|
||||||
|
alias dot='/usr/bin/git --git-dir="$HOME/Repos/dotfiles/" --work-tree="$HOME"'
|
||||||
dot checkout
|
dot checkout
|
||||||
dot config --local status.showUntrackedFiles no
|
dot config --local status.showUntrackedFiles no
|
||||||
source ~/.zshrc
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If there are conflicts:
|
If there are conflicts:
|
||||||
|
@ -1,122 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
getgit.py - Pull or clone all of your Gitea user repositories.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
./getgit.py --server https://gitea.example.com --token YOUR_API_TOKEN
|
|
||||||
or, after setting the environment variable GITEA_TOKEN:
|
|
||||||
export GITEA_TOKEN=YOUR_API_TOKEN
|
|
||||||
./getgit.py --server https://gitea.example.com
|
|
||||||
|
|
||||||
By default the repositories will be placed under ~/repos.
|
|
||||||
If a repository directory already exists, a 'git pull' will be run;
|
|
||||||
otherwise, the repository will be cloned using its SSH URL.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import argparse
|
|
||||||
import subprocess
|
|
||||||
import requests
|
|
||||||
|
|
||||||
server = "https://git.theflyingfool.com"
|
|
||||||
|
|
||||||
def get_repos(server, token, per_page=100):
|
|
||||||
"""Fetch all repositories for the authenticated user from Gitea."""
|
|
||||||
repos = []
|
|
||||||
page = 1
|
|
||||||
headers = {
|
|
||||||
"Authorization": f"token {token}",
|
|
||||||
"Accept": "application/json"
|
|
||||||
}
|
|
||||||
while True:
|
|
||||||
url = f"{server.rstrip('/')}/api/v1/user/repos?page={page}&limit={per_page}"
|
|
||||||
response = requests.get(url, headers=headers)
|
|
||||||
if response.status_code != 200:
|
|
||||||
print(f"Error fetching repositories (HTTP {response.status_code}): {response.text}")
|
|
||||||
sys.exit(1)
|
|
||||||
data = response.json()
|
|
||||||
if not data:
|
|
||||||
break
|
|
||||||
repos.extend(data)
|
|
||||||
if len(data) < per_page:
|
|
||||||
break
|
|
||||||
page += 1
|
|
||||||
return repos
|
|
||||||
|
|
||||||
def clone_or_pull_repo(repo, dest_dir):
|
|
||||||
"""
|
|
||||||
Given a repository object (as returned from the Gitea API), check if it exists locally.
|
|
||||||
If it exists, run 'git pull'; if not, run 'git clone' using the SSH URL.
|
|
||||||
"""
|
|
||||||
repo_name = repo.get('name')
|
|
||||||
ssh_url = repo.get('ssh_url')
|
|
||||||
if not repo_name or not ssh_url:
|
|
||||||
print(f"Skipping a repo entry with missing information: {repo}")
|
|
||||||
return
|
|
||||||
|
|
||||||
repo_path = os.path.join(dest_dir, repo_name)
|
|
||||||
if os.path.exists(repo_path):
|
|
||||||
print(f"Updating repository '{repo_name}'...")
|
|
||||||
try:
|
|
||||||
subprocess.run(["git", "-C", repo_path, "pull"], check=True)
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
print(f"Warning: Failed to update repository '{repo_name}'.")
|
|
||||||
else:
|
|
||||||
print(f"Cloning repository '{repo_name}'...")
|
|
||||||
try:
|
|
||||||
subprocess.run(["git", "clone", ssh_url, repo_path], check=True)
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
print(f"Warning: Failed to clone repository '{repo_name}'.")
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description="Clone or update all Gitea user repositories."
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--server",
|
|
||||||
type=str,
|
|
||||||
default="https://git.theflyingfool.com",
|
|
||||||
help="Base URL of your Gitea server (e.g. https://gitea.example.com)"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--dest",
|
|
||||||
type=str,
|
|
||||||
default=os.path.expanduser("~/repos"),
|
|
||||||
help="Local destination directory to clone repositories (default: ~/repos)"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--token",
|
|
||||||
type=str,
|
|
||||||
help="Your Gitea API token. Alternatively, set the GITEA_TOKEN environment variable."
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--per-page",
|
|
||||||
type=int,
|
|
||||||
default=100,
|
|
||||||
help="Number of repositories to fetch per API page (default: 100)"
|
|
||||||
)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Retrieve the API token from argument or environment variable.
|
|
||||||
token = args.token or os.environ.get("GITEA_TOKEN")
|
|
||||||
if not token:
|
|
||||||
print("Error: No API token provided. Supply it via --token or set GITEA_TOKEN.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Ensure the destination directory exists.
|
|
||||||
dest_dir = os.path.expanduser(args.dest)
|
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
|
||||||
|
|
||||||
print("Fetching repository list from Gitea...")
|
|
||||||
repos = get_repos(args.server, token, args.per_page)
|
|
||||||
if not repos:
|
|
||||||
print("No repositories found.")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
print(f"Found {len(repos)} repositories. Processing each one...")
|
|
||||||
for repo in repos:
|
|
||||||
clone_or_pull_repo(repo, dest_dir)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -1,15 +0,0 @@
|
|||||||
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
|
|
||||||
param($wordToComplete, $commandAst, $cursorPosition)
|
|
||||||
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
|
|
||||||
$Local:word = $wordToComplete.Replace('"', '""')
|
|
||||||
$Local:ast = $commandAst.ToString().Replace('"', '""')
|
|
||||||
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
|
|
||||||
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function dot { & git --git-dir="$HOME/.dot/" --work-tree="$HOME" @args }
|
|
||||||
|
|
||||||
# Source the aliases.ps1 file
|
|
||||||
. "$PSScriptRoot/aliases.ps1"
|
|
@ -1,9 +0,0 @@
|
|||||||
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
|
|
||||||
param($wordToComplete, $commandAst, $cursorPosition)
|
|
||||||
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
|
|
||||||
$Local:word = $wordToComplete.Replace('"', '""')
|
|
||||||
$Local:ast = $commandAst.ToString().Replace('"', '""')
|
|
||||||
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
|
|
||||||
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
function Upgrade-All { winget upgrade --all }
|
|
||||||
|
|
||||||
Set-Alias -Name Syu -Value Upgrade-All
|
|
||||||
|
|
||||||
function touch($file) {
|
|
||||||
"" | Out-File $file -Encoding ASCII
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user