From 16f41bd98a1e8091b28d1b22ff2b655a2b4cc369 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 18 Aug 2025 01:50:02 +0000 Subject: [PATCH] first commit --- LICENSE | 22 +++++++ bash_aliases | 109 ++++++++++++++++++++++++++++++++++ bashrc | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++ gitconfig | 20 +++++++ rtorrent.rc | 128 ++++++++++++++++++++++++++++++++++++++++ setup.sh | 21 +++++++ vimrc | 99 +++++++++++++++++++++++++++++++ 7 files changed, 560 insertions(+) create mode 100644 LICENSE create mode 100644 bash_aliases create mode 100644 bashrc create mode 100644 gitconfig create mode 100644 rtorrent.rc create mode 100755 setup.sh create mode 100644 vimrc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..edf7e58 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Jamie Harrell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/bash_aliases b/bash_aliases new file mode 100644 index 0000000..4d3d76f --- /dev/null +++ b/bash_aliases @@ -0,0 +1,109 @@ +# Colourize All the Things +alias ls='ls -CF --color=auto' +alias dir='dir --color=auto' +alias vdir='vdir --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias diff='colordiff' +alias less='less -R' + +# Set some sane defaults +alias df='df -h' +alias du='du -ch' +alias mv='mv -v' +alias cp='cp -v' +alias rm='rm -v' +alias ln='ln -v' +alias diff='diff -u' +alias free='free -mlth' + +# Never run as root, always sudo +alias su='su -' +alias sudo='sudo ' #Fix alias post-sudo + +# I am seriously lazy +alias cd..='cd ..' + +for ((i=2; i <= 8; i++)) +do + unset DD + unset DDS + for ((j=0; j < i; j++)) + do + DD="${DD}../" + DDS="${DDS}." + done + alias "$DDS"="cd $DD" +done + +#alias ..='cd ..' +#alias ...='cd ../..' +#alias ....='cd ../../..' +#alias .....='cd ../../../..' +#alias ......='cd ../../../../../..' +#alias .......='cd ../../../../../../..' +#alias ........='cd ../../../../../../../..' +#alias .........='cd ../../../../../../../../..' + +# new commands +alias du1='du --max-depth=1' +alias ll='ls -lF' +alias la='ls -A' +alias pcinfo='inxi -v6 -c10' +alias grouplist='cut -d: -f1 /etc/group' + +# git +alias gl='git pull' +alias gp='git push' +alias gd='git diff' +alias gc='git commit' +alias gca='git commit -a' +alias gco='git checkout' +alias gb='git branch' +alias gs='git status' +alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm" +alias changelog='git log `git log -1 --format=%H -- CHANGELOG*`..; cat CHANGELOG*' + +# Generate some random passwords +alias pass='pwgen -s1 18 5' + +# Get IPv4 address +alias ipv4="ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print \$2}' | cut -f1 -d'/'" + +# Create parent directories +alias mkdir='mkdir -pv' + +# Continue downloads by default +alias wget='wget -c --content-disposition' + +# handy shortcuts +alias showports='sudo netstat -tulpn' + +# Case insensitive grepping! +alias igrep='grep -i' + +# List running services +alias servicelist='systemctl --no-page --no-legend --plain -t service --state=running' + +# Search for only uncommented linkes +alias uncomment="grep -vE '^#|^$' " + +# I hate Mondays... +alias fuck='sudo $(history -p \!\!)' +#eval $(thefuck --alias) + +# Octal permissions +alias operms="stat -c '%A %a %n' " + +# Parenting changing perms on / +alias chown='chown --preserve-root' +alias chmod='chmod --preserve-root' +alias chgrp='chgrp --preserve-root' + +# do not delete / or prompt if deleting more than 3 files at a time +alias rm='rm -I --preserve-root' + +# External Tools +alias weather='curl wttr.in/Halifax' +alias moon=' curl wttr.in/Moon' diff --git a/bashrc b/bashrc new file mode 100644 index 0000000..14a8d41 --- /dev/null +++ b/bashrc @@ -0,0 +1,161 @@ +# Test for an interactive shell. There is no need to set anything +# past this point for scp and rcp, and it's important to refrain from +# outputting anything in those cases. +if [[ $- != *i* ]] ; then + # Shell is non-interactive. Be done now! + return +fi + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# PATH Time +export EDITOR='vim' +export VISUAL='vim' +export GOPATH=$HOME/go +export PATH=$PATH:$GOPATH/bin:$HOME/.local/bin:$HOME/bin:/usr/local/go/bin + +# cd then ls immediately, show git branch if approperiate +function cd() { + if [ -n "$1" ]; then + builtin cd "$1"; + else + builtin cd ~; + fi + if [ -d "./.git" ]; then + GIT_STATUS=$(git branch --color | grep \* | cut --complement -f 1 -d ' ') + echo "Git Branch: ${GIT_STATUS}"; + fi + ls -al --color; +} + +# disable crontab -r +function crontab { + /usr/bin/crontab "${@/-r/-e}" +} + +# Show Open Files +function openfiles { + if [ "${1}" = "-h" ]; then + echo -e "Usage: openfiles [r|w|m|R|W] regex\n -r opened for reading or read/write\n -w opened for writing or read/write\n -m accessed from memory (includes running command)\n -R opened for reading only\n -W opened for writing only" + return + fi + if [ "$#" = "0" ]; then + echo "Process signature/regex required." + return + fi + MODE="(w|u)" + ACTION="for writing" + if [ "${1}" = "r" ]; then + MODE="(r|u)" + ACTION="for reading" + shift + elif [ "${1}" = "R" ]; then + MODE="r" + ACTION="for reading (only)" + shift + elif [ "${1}" = "W" ]; then + MODE="w" + ACTION="for writing (only)" + shift + elif [ "${1}" = "m" ]; then + MODE="(txt|mem)" + ACTION="in memory" + shift + elif [ "${1}" = "w" ]; then + shift + fi + if [ "${MODE}" != "(txt|mem)" ]; then + MODE="[0-9]+${MODE}" + fi + PIDS=$(pgrep -d "," -f "${@}") + if [ "${PIDS}" = "" ]; then + echo "No processes found matching '${@}'." + return + fi + OPENFILES=$(sudo lsof -PXn -p ${PIDS} | egrep "${MODE}[A-Za-z]* +REG" | awk '{print $9}' | egrep -v "^\[" | sort | uniq); + if [ "${OPENFILES}" = "" ]; then + echo "No files opened ${ACTION}." + else + echo "Files opened ${ACTION}:" + sudo ls -ahl $OPENFILES + fi +} + +# Listening Ports +function listening { + if [ "${1}" = "-h" ]; then + echo "Usage: listening [t|tcp|u|udp] [ps regex]" + return + fi + DISP="both" + NSOPTS="tu" + if [ "${1}" = "t" -o "${1}" = "tcp" ]; then + DISP="tcp" + NSOPTS="t" + shift + elif [ "${1}" = "u" -o "${1}" = "udp" ]; then + DISP="udp" + NSOPTS="u" + shift + fi + FILTER="${@}" + PORTS_PIDS=$(sudo netstat -"${NSOPTS}"lnp | tail -n +3 | tr -s ' ' | sed -n 's/\(tcp\|udp\) [0-9]* [0-9]* \(::\|0\.0\.0\.0\|127\.[0-9]*\.[0-9]*\.[0-9]*\):\([0-9]*\) .* \(-\|\([0-9-]*\)\/.*\)/\3 \1 \5 \2/p' | sed 's/\(::\|0\.0\.0\.0\)/EXTERNAL/' | sed 's/127\.[0-9]*\.[0-9]*\.[0-9]*/LOCALHOST/' | sort -n | tr ' ' ':' | sed 's/::/:-:/' | sed 's/:$//' | uniq) + PS=$(sudo ps -e --format '%p %a') + echo -e ' Port - Protocol - Interface - Program\n-----------------------------------------------' + for PORT_PID in ${PORTS_PIDS}; do + PORT=$(echo ${PORT_PID} | cut -d':' -f1) + PROTOCOL=$(echo ${PORT_PID} | cut -d':' -f2) + PID=$(echo ${PORT_PID} | cut -d':' -f3) + INTERFACE=$(echo ${PORT_PID} | cut -d':' -f4) + if [ "${PROTOCOL}" != "${DISP}" -a "${DISP}" != "both" ]; then + continue + fi + if [ "${PID}" = "-" ]; then + if [ "${FILTER}" != "" ]; then + continue + fi + printf "%7s - %8s - %9s - -\n" "${PORT}" "${PROTOCOL}" "${INTERFACE}" + else + PROG=$(echo "${PS}" | grep "^ *${PID}" | grep -o '[0-9] .*' | cut -d' ' -f2-) + if [ "${FILTER}" != "" ]; then + echo "${PROG}" | grep -q "${FILTER}" + if [ $? -ne 0 ]; then + continue + fi + fi + printf "%7s - %8s - %9s - %s\n" "${PORT}" "${PROTOCOL}" "${INTERFACE}" "${PROG}" + fi + done +} + +# Setup my prompt +## Normal User +if [[ $EUID -ne 0 ]]; then + export PS1="\[$(tput bold)\]\[$(tput setaf 0)\]-\[$(tput setaf 6)\] \h \[$(tput setaf 0)\]| \t |\[$(tput setaf 6)\] \W\[$(tput setaf 0)\] -\\$ \[$(tput sgr0)\]\[$(tput sgr0)\]" +else +## root + export PS1="\[$(tput bold)\]\[$(tput setaf 0)\]-\[$(tput setaf 1)\] \h \[$(tput setaf 0)\]| \t |\[$(tput setaf 1)\] \W\[$(tput setaf 0)\] -\\$ \[$(tput sgr0)\]\[$(tput sgr0)\]" +fi + +# Man page colours: +export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking +export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold +export LESS_TERMCAP_me=$'\E[0m' # end mode +export LESS_TERMCAP_se=$'\E[0m' # end standout-mode +export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box +export LESS_TERMCAP_ue=$'\E[0m' # end underline +export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline +export LESS=cR + +source ~/.bash_aliases +if [ -e /etc/bash_completion ]; then + source /etc/bash_completion +fi + +if [ -f ~/.bash_local ]; then + . ~/.bash_local +fi + diff --git a/gitconfig b/gitconfig new file mode 100644 index 0000000..eeb2b00 --- /dev/null +++ b/gitconfig @@ -0,0 +1,20 @@ +[user] + name = Jason King + email = mazdagtr@gmail.com +[core] + editor = vim +[color] + ui = auto + +[url "https://github.com/"] + insteadOf = gh +[credential "https://github.com/"] + username = mazdagtr + +[url "https://gist.github.com/"] + insteadOf = gist +[credential "https://gist.github.com/"] + username = mazdagtr + +[credential] + helper = store diff --git a/rtorrent.rc b/rtorrent.rc new file mode 100644 index 0000000..9539205 --- /dev/null +++ b/rtorrent.rc @@ -0,0 +1,128 @@ +# This is an example resource file for rTorrent. Copy to +# ~/.rtorrent.rc and enable/modify the options as needed. Remember to +# uncomment the options you wish to enable. +# +# Based on original .rtorrent.rc file from http://libtorrent.rakshasa.no/ +# Modified by Lemonberry for rtGui http://rtgui.googlecode.com/ +# +# This assumes the following directory structure: +# +# /Torrents/Downloading - temporaray location for torrents while downloading (see "directory") +# /Torrents/Complete - Torrents are moved here when complete (see "on_finished") +# /Torrents/TorrentFiles/Auto - The 'autoload' directory for rtorrent to use. Place a file +# in here, and rtorrent loads it #automatically. (see "schedule = watch_directory") +# /Torrents/Downloading/rtorrent.session - for storing rtorrent session information +# + +# Maximum and minimum number of peers to connect to per torrent. +#min_peers = 40 +#max_peers = 100 + +# Same as above but for seeding completed torrents (-1 = same as downloading) +min_peers_seed = 1 +max_peers_seed = 10 + +# Maximum number of simultanious uploads per torrent. +max_uploads = 2 + +# Global upload and download rate in KiB. "0" for unlimited. +download_rate = 0 +upload_rate = 5 + +# Default directory to save the downloaded torrents. +directory = /Torrents/Downloading + +# Default session directory. Make sure you don't run multiple instance +# of rtorrent using the same session directory. Perhaps using a +# relative path? +session = /Torrents/Downloading/rtorrent.session + +# Watch a directory for new torrents, and stop those that have been +# deleted. +schedule = watch_directory,5,5,load_start=/Torrents/TorrentFiles/Auto/*.torrent +schedule = untied_directory,5,5,stop_untied= + +# Close torrents when diskspace is low. */ +#schedule = low_diskspace,5,60,close_low_diskspace=100M + +# Stop torrents when reaching upload ratio in percent, +# when also reaching total upload in bytes, or when +# reaching final upload ratio in percent. +# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0 +#schedule = ratio,60,60,stop_on_ratio=200,200M,2000 + +#execute_log = /home/jamie/rtorrent.log + +# When the torrent finishes, it executes "mv -n ~/Download/" +# and then sets the destination directory to "~/Download/". (0.7.7+) +#on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/Torrents/Complete/ ;d.set_directory=/Torrents/Complete/" + +# The ip address reported to the tracker. +#ip = 127.0.0.1 +#ip = rakshasa.no + +# The ip address the listening socket and outgoing connections is +# bound to. +#bind = 127.0.0.1 +#bind = rakshasa.no + +# Port range to use for listening. +port_range = 55556-55560 + +scgi_port = 127.0.0.1:5000 + +# Start opening ports at a random position within the port range. +#port_random = no + +# Check hash for finished torrents. Might be usefull until the bug is +# fixed that causes lack of diskspace not to be properly reported. +#check_hash = no + +# Set whetever the client should try to connect to UDP trackers. +use_udp_trackers = yes + +# Alternative calls to bind and ip that should handle dynamic ip's. +#schedule = ip_tick,0,1800,ip=rakshasa +#schedule = bind_tick,0,1800,bind=rakshasa + +# Encryption options, set to none (default) or any combination of the following: +# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext +# +# The example value allows incoming encrypted connections, starts unencrypted +# outgoing connections but retries with encryption if they fail, preferring +# plaintext to RC4 encryption after the encrypted handshake +# +encryption = allow_incoming,enable_retry,prefer_plaintext + +# +# Do not modify the following parameters unless you know what you're doing. +# + +# Hash read-ahead controls how many MB to request the kernel to read +# ahead. If the value is too low the disk may not be fully utilized, +# while if too high the kernel might not be able to keep the read +# pages in memory thus end up trashing. +#hash_read_ahead = 10 + +# Interval between attempts to check the hash, in milliseconds. +#hash_interval = 100 + +# Number of attempts to check the hash while using the mincore status, +# before forcing. Overworked systems might need lower values to get a +# decent hash checking rate. +#hash_max_tries = 10 + +# Max number of files to keep open simultaniously. +#max_open_files = 128 + +# Number of sockets to simultaneously keep open. +#max_open_sockets = + + +# Example of scheduling commands: Switch between two ip's every 5 +# seconds. +#schedule = "ip_tick1,5,10,ip=torretta" +#schedule = "ip_tick2,10,10,ip=lampedusa" + +# Remove a scheduled event. +#schedule_remove = "ip_tick1" diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..8e09ef6 --- /dev/null +++ b/setup.sh @@ -0,0 +1,21 @@ +ln -sf $HOME/dotcfg/bashrc $HOME/.bashrc +ln -sf $HOME/dotcfg/bash_aliases $HOME/.bash_aliases +ln -sf $HOME/dotcfg/vimrc $HOME/.vimrc +ln -sf $HOME/dotcfg/rtorrent.rc $HOME/.rtorrent.rc +ln -sf $HOME/dotcfg/gitconfig $HOME/.gitconfig + +GIT=false +for d in $PATH + do test -x $d/git && GIT=true +done + +if $GIT; then + echo "git found! Setting up git..." + git config --global user.name "Jason King" + git config --global user.email "mazdagtr@gmail.com" + git config --global user.ename "mazdagtr@gmail.com" + git config --global credential.helper store +fi + +git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim +vim +PluginInstall +qall diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..444bfbb --- /dev/null +++ b/vimrc @@ -0,0 +1,99 @@ +set nocompatible " be iMproved, required +filetype off + +set runtimepath+=~/.vim/bundle/Vundle.vim +call vundle#begin() + " let Vundle manage Vundle, required + Plugin 'gmarik/Vundle.vim' + + "Put your non-Plugin stuff after this line + Plugin 'jlanzarotta/bufexplorer' " Buffer Explorer :BufExplore + Plugin 'tpope/vim-fugitive' " Git wrapper + Plugin 'terryma/vim-multiple-cursors' " Multiple cursors work + Plugin 'edkolev/promptline.vim' " Prompt generator for bash + Plugin 'godlygeek/tabular' " Lineup that text + Plugin 'plasticboy/vim-markdown' " Better Markdown + Plugin 'fatih/vim-go' " Go Syntax + Plugin 'cespare/vim-toml' " TOML Syntax + Plugin 'pangloss/vim-javascript' " Better Javascript + Plugin 'ryanoasis/vim-devicons' " Dev Icons + Plugin 'editorconfig/editorconfig-vim' " EditorConfig + Plugin 'itchyny/lightline.vim' " Lightline, it's simple and does just what it does + Plugin 'airblade/vim-gitgutter' " GitGutter + Plugin 'nathanaelkane/vim-indent-guides' " Indenting is a PITA. + + " Colour schemes + Plugin 'ninja/sky' " Vim Sky + Plugin 'dracula/vim' " Dracula! + + " All of your Plugins must be added before the following line +call vundle#end() + +set guifont=Droid\ Sans\ Mono\ Slashed\ for\ Powerline +set encoding=utf-8 + +if !has('gui_running') + set t_Co=256 +endif + +colorscheme sky +set background=dark + +let g:lightline = { 'colorscheme': 'dracula',} + +let g:indent_guides_guide_size = 1 +"let g:indent_guides_color_change_percent = 3 +let g:indent_guides_enable_on_vim_startup = 1 + +" set number " Show line numbers +set showcmd " show command on last line of screen +set cursorline " Underline the line the cursor is on +set wildmenu " enhanced cmd line completion +set lazyredraw " don't update screen when executing macros +set showmatch " show bracket matches +set backspace=2 " enable for everything +set completeopt=longest,menuone " Autocompletion options +set complete=.,w,b,u,t,i,d " autocomplete options (:help 'complete') +set hidden " hide when switching buffers, don't unload +set laststatus=2 " always show status line +set noshowmode " don't show mode, since I'm already using airline +set nowrap " disable word wrap +set showbreak="+++ " " String to show with wrap lines +set spelllang=en " spell +set spellfile=~/.vim/spell/en.utf-8.add +set textwidth=0 " don't break lines after some maximum width +set ttyfast " increase chars sent to screen for redrawing +"set ttyscroll=3 " limit lines to scroll to speed up display +set title " use filename in window title +set wildchar= " key for line completion +set noerrorbells " no error sound +set splitright " Split new buffer at right + +" Folding +set foldenable " Enable Folding +set foldignore= " don't ignore anything when folding +set foldlevelstart=99 " no folds closed on open +set foldmethod=indent " collapse code using indents +set foldnestmax=10 " limit max folds for indent and syntax methods + +" Tabs +set tabstop=2 " spaces for +set softtabstop=2 " spaces for editing, e.g. or +set expandtab " replace tabs with spaces + +" Searches +set hlsearch " highlight search results +set incsearch " search whilst typing +set ignorecase " case insensitive searching +set smartcase " override ignorecase if upper case typed +set more " Stop in list + +" Status bar +set laststatus=2 " show ever +set noshowmode " show mode +set showcmd " show cmd +set ruler " show cursor line number +set shm=atI " cut large messages + + +syntax enable