This commit is contained in:
Mike McFetridge
2026-07-20 09:23:17 -04:00
parent c1315882da
commit 72272e4006
3179 changed files with 562960 additions and 14 deletions
+40
View File
@@ -0,0 +1,40 @@
---
tags:
- Desktop
- Configs
---
| Field | Allowed Values | Description |
| --- | --- | --- |
| `SECOND` | 0-59 | Trigger every SECOND second(s) |
| `MINUTE` | 0-59 | Trigger every MINUTE minute(s) |
| `HOUR` | 0-23 | Trigger every HOUR hour(s) |
| `DAY` | 1-31 | Trigger every DAY day(s) of month |
| `MONTH` | 1-12 | Trigger every MONTH month(s) |
| `DAY OF WEEK` | 0-6 | MON-SUN Trigger on specific DAY OF WEEK |
Special Characters
------------------
| Special Character | Description |
| --- | --- |
| `*` | Trigger on tick of every time unit |
| `,` | List separator |
| `` | Specifies a range |
| `/` | Defines an increment |
Examples
--------
| Cron Expression | Description |
| --- | --- |
| `0 * * * * *` | Executes every minute |
| `0 0 * * * *` | Executes every hour |
| `0 0 0 * * *` | Executes every day |
| `0 0 0 0 * *` | Executes every month |
| `0 0 0 1 1 *` | Executes on first day of Jan each year |
| `30 20 * * SAT` | Executes at 08:30pm every Saturday |
| `30 20 * * 6` | Executes at 08:30pm every Saturday |
| `0 */5 * * * *` | Executes every five minutes |
| `0 0 8-10/1 * * *` | Executes every hour between 8am and 10am |
+154
View File
@@ -0,0 +1,154 @@
---
tags:
- Desktop
- Configs
---
config.json
```
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "builtin",
"height": 15,
"width": 30,
"padding": {
"top": 5,
"left": 3
}
},
"modules": [
"break",
{
"type": "custom",
"format": "\u001b[90m┌──────────────────────Hardware──────────────────────┐"
},
{
"type": "host",
"key": " PC",
"keyColor": "green"
},
{
"type": "cpu",
"key": "│ ├",
"keyColor": "green"
},
{
"type": "gpu",
"key": "│ ├󰍛",
"keyColor": "green"
},
{
"type": "memory",
"key": "│ ├󰍛",
"keyColor": "green"
},
{
"type": "disk",
"key": "└ └",
"keyColor": "green"
},
{
"type": "custom",
"format": "\u001b[90m└────────────────────────────────────────────────────┘"
},
"break",
{
"type": "custom",
"format": "\u001b[90m┌──────────────────────Software──────────────────────┐"
},
{
"type": "os",
"key": " OS",
"keyColor": "yellow"
},
{
"type": "kernel",
"key": "│ ├",
"keyColor": "yellow"
},
{
"type": "bios",
"key": "│ ├",
"keyColor": "yellow"
},
{
"type": "packages",
"key": "│ ├󰏖",
"keyColor": "yellow"
},
{
"type": "shell",
"key": "└ └",
"keyColor": "yellow"
},
"break",
{
"type": "de",
"key": " DE",
"keyColor": "blue"
},
{
"type": "lm",
"key": "│ ├",
"keyColor": "blue"
},
{
"type": "wm",
"key": "│ ├",
"keyColor": "blue"
},
{
"type": "wmtheme",
"key": "│ ├󰉼",
"keyColor": "blue"
},
{
"type": "terminal",
"key": "└ └",
"keyColor": "blue"
},
{
"type": "custom",
"format": "\u001b[90m└────────────────────────────────────────────────────┘"
},
"break",
{
"type": "custom",
"format": "\u001b[90m┌────────────────────Uptime / Age / DT────────────────────┐"
},
{
"type": "command",
"key": " OS Age ",
"keyColor": "magenta",
"text": "birth_install=$(stat -c %W /); current=$(date +%s); time_progression=$((current - birth_install)); days_difference=$((time_progression / 86400)); echo $days>
},
{
"type": "uptime",
"key": " Uptime ",
"keyColor": "magenta"
},
{
"type": "datetime",
"key": " DateTime ",
"keyColor": "magenta"
},
{
"type": "custom",
"format": "\u001b[90m└─────────────────────────────────────────────────────────┘"
},
// {
// "type": "colors"
// },
{
"type": "colors",
"paddingLeft": 2,
"symbol": "circle"
}
]
}
```
@@ -0,0 +1,22 @@
---
tags:
- Desktop
- Configs
---
Sample config
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
      - 192.168.0.200/24
      routes:
          - to: default
            via: 192.168.0.1
      nameservers:
        addresses:
         - 192.168.0.200
         - 9.9.9.9
         search: \[home.mikemcfetridge.com\]
+333
View File
@@ -0,0 +1,333 @@
---
tags:
- Desktop
- Configs
---
.nanorc file
```
## Sample initialization file for GNU nano.
##
## For the options that take parameters, the default value is shown.
## Other options are unset by default. To make sure that an option
## is disabled, you can use "unset <option>".
##
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
# set atblanks
## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
# set autoindent
## Back up files to the current filename plus a tilde.
# set backup
## The directory to put unique backup files in.
# set backupdir ""
## Use bold text instead of reverse video text.
# set boldtext
## Treat any line with leading whitespace as the beginning of a paragraph.
# set bookstyle
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
# set brackets ""')>]}"
## Automatically hard-wrap the current line when it becomes overlong.
# set breaklonglines
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the status bar or minibar.
# set constantshow
## Use cut-from-cursor-to-end-of-line by default.
# set cutfromcursor
## Do not use the line below the title bar, leaving it entirely blank.
# set emptyline
## Set the target width for automatic hard-wrapping and for justifying
## paragraphs. If the specified value is 0 or less, the wrapping point
## will be the terminal's width minus this number.
# set fill -8
## Draw a vertical stripe at the given column, to help judge text width.
## (This option does not have a default value.)
# set guidestripe 75
## Remember the used search/replace strings for the next session.
set historylog
## Display a "scrollbar" on the righthand side of the edit window.
# set indicator
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left (and any anchors in the margin).
# set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
## are editing a file [s]he is trying to edit and vice versa. There are
## no plans to implement vim-style undo state in these files.
set locking
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that are found by a matching-bracket
## search. This may not contain blank characters. The opening brackets
## must come before the closing ones, and they must be in the same order.
# set matchbrackets "(<[{)>]}"
## Suppress the title bar and show the filename plus a cursor-position
## percentage in the space of the status bar.
# set minibar
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the
## X Window System, and on the console when gpm is running.
# set mouse
## Switch on multiple file buffers (inserting a file will put it into
## a separate buffer).
# set multibuffer
## Don't convert files from DOS/Mac format.
# set noconvert
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Set operating directory. nano will not read or write files outside
## this directory and its subdirectories. Also, the current directory
## is changed to here, so any files are inserted from this dir. A blank
## string means the operating-directory feature is turned off.
# set operatingdir ""
## Remember the cursor position in each file for the next editing session.
# set positionlog
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
## The characters treated as closing punctuation when justifying paragraphs.
## This may not contain blank characters. Only these closing punctuations,
## optionally followed by closing brackets, can end sentences.
# set punct "!.?"
## Make status-bar messages disappear after 1 keystroke instead of after 20.
# set quickblank
## The regular expression that matches quoting characters in email
## or line-comment introducers in source code. The default is:
# set quotestr "^([ ]*([!#%:;>|}]|//))+"
## Try to work around a mismatching terminfo terminal description.
# set rawsequences
## Fix Backspace/Delete confusion problem.
# set rebinddelete
## Do regular-expression searches by default.
## Regular expressions are of the extended type (ERE).
# set regexp
## Save a changed buffer automatically on exit; don't prompt.
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and
## show the cursor in the help viewer; useful for people who use a
## braille display and people with poor vision.
# set showcursor
## Make the Home key smarter: when Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
## cursor is already at that position, it will jump to the true start
## of the line (the left edge).
# set smarthome
## Spread overlong lines over multiple screen lines.
# set softwrap
## Use this spelling checker instead of the internal one. This option
## does not have a default value.
# set speller "aspell -x -c"
## Use the end of the title bar for some state flags: I = auto-indenting,
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
set stateflags
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
## Convert each typed tab to the fitting number of spaces.
# set tabstospaces
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
## Save files by default in Unix format (also when they were DOS or Mac).
# set unix
## The two single-column characters used to display the first characters
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
## The default when in a UTF-8 locale:
# set whitespace "»·"
## The default otherwise:
# set whitespace ">."
## Detect word boundaries differently by treating punctuation
## characters as parts of words.
# set wordbounds
## The characters (besides alphanumeric ones) that should be considered
## as parts of words. This option does not have a default value. When
## set, it overrides option 'set wordbounds'.
# set wordchars "<_>."
## Let an unmodified Backspace or Delete erase the marked region (instead
## of a single character, and without affecting the cutbuffer).
# set zap
## Hide the bars plus help lines and use the whole terminal as edit area.
# set zero
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
# set titlecolor bold,white,blue
# set promptcolor lightwhite,grey
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor lightmagenta
# set functioncolor magenta
## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
## To include most of the existing syntax definitions, you can do:
include "/usr/share/nano/*.nanorc"
## Or you can select just the ones you need. For example:
# include "/usr/share/nano/html.nanorc"
# include "/usr/share/nano/python.nanorc"
# include "/usr/share/nano/sh.nanorc"
## In /usr/share/nano/extra/ you can find some syntaxes that are
## specific for certain distros or for some less common languages.
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
# extendsyntax python tabgives " "
## If <Tab> should always produce an actual TAB when editing a Makefile:
# extendsyntax makefile tabgives " "
## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
## If you want to suspend nano with one keystroke (instead of with ^T^Z):
# bind ^Z suspend main
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function. The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function. So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H chopwordleft main
## For a more mnemonic Comment keystroke (overriding Cut-from-cursor):
# bind M-K comment main
## If you want ^L to just refresh the screen and not center the cursor:
# bind ^L refresh main
## When you sometimes type M-J instead of M-K, or M-T instead of M-R:
# unbind M-J main
# unbind M-T main
## (Those functions are still accessible through ^T^J and ^T^V.)
## For quickly uppercasing or lowercasing the word under the cursor.
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
## and then pipe the selected text through a sed command.)
#bind Sh-M-U "^[Oc^[[1;6D^T|sed 's/.*/\U&/'^M" main
#bind Sh-M-L "^[Oc^[[1;6D^T|sed 's/.*/\L&/'^M" main
## If you would like nano to have keybindings that are more "usual",
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
#bind ^X cut main
#bind ^C copy main
#bind ^V paste all
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#set multibuffer
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind ^Z undo main
#bind ^Y redo main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^A mark main
#bind ^P location main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^T cutrestoffile execute
#bind ^L linter execute
#bind ^E execute main
```
@@ -0,0 +1,59 @@
---
tags:
- Desktop
- Configs
---
# /home/etc/.ssh/config file
# /home/etc/.ssh/config file
Host homelab-oracle
Hostname 129.213.86.62
Host rackserver2
Hostname 216.144.227.142
Host pve1
Hostname 192.168.2.1
Host pve2
Hostname 192.168.2.2
Host docker-prod-01
Hostname 192.168.2.3
Host pangolin
Hostname 192.168.2.4
Host DomainLocker
Hostname 192.168.2.5
Host pihole
Hostname 192.168.2.8
Host tech-dns
Hostname 192.168.2.9
Host arrstack
Hostname 192.168.2.10
Host arr-stack
Hostname 192.168.2.11
Host linkwarden
Hostname 192.168.2.12
Host docker-deploy
Hostname 192.168.2.15
Host mygitea.mikemcfetridge.com
HostName 192.168.2.15
User git
Port 222
Host vaultwarder
Hostname 192.168.2.19
Host edge-waf
Hostname 192.168.2.20
@@ -0,0 +1,277 @@
---
tags:
- Server
- Security
---
# **Initial Server Setup with Debian-Based Distributions**
Setting up a new Debian-based server (e.g., **Debian**, **Ubuntu**, or **Linux Mint**) is the foundation of a secure and efficient system. This guide walks you through the essential steps I follow to establish a secure and functional environment, ensuring long-term stability and reliability.
---
## **Why Initial Server Setup Matters**
Properly configuring a server during its initial setup is crucial to:
- **Enhance Security**: Protect against unauthorized access.
- **Ensure Reliability**: Lay the groundwork for stable and efficient operations.
- **Save Time**: Avoid future headaches by configuring the server correctly upfront.
---
## **Logging in as Root**
Many Debian-based distributions disable direct `root` SSH access for security. If root login is allowed or you're accessing the server via the console, log in as the root user:
```bash
ssh root@<your-server-ip>
```
For cloud-based servers, you might need to log in with a default user like `ubuntu` or `debian`.
---
## **Secure Password Update**
Immediately update the root password (if root login is enabled):
```bash
passwd
```
If youre using a default user, update its password as well:
```bash
sudo passwd
```
---
## **Creating a New User**
Using `root` for daily operations is discouraged. Create a new user for regular use:
```bash
adduser username
```
This prompts you to set a password and optional user details.
---
## **Granting Administrative Privileges**
To allow the new user to execute administrative tasks, add them to the `sudo` group:
```bash
usermod -aG sudo username
```
If `sudo` is not installed (common on Debian minimal installs):
```bash
apt install sudo
```
Test the configuration by switching to the new user:
```bash
su - username
sudo apt update
```
---
## **Configuring SSH**
### **Setting Up SSH Keys**
SSH keys offer better security than passwords. Generate an SSH key pair on your local machine:
```bash
ssh-keygen
```
Copy the public key to the server:
```bash
ssh-copy-id username@<your-server-ip>
```
Alternatively, manually upload the key to the server:
```bash
cat ~/.ssh/id_rsa.pub | ssh username@<your-server-ip> "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
```
### **Secure SSH Configuration**
Edit the SSH configuration file to improve security:
```bash
sudo nano /etc/ssh/sshd_config
```
Update the following settings:
- Disable root login:
```none
PermitRootLogin no
```
- Disable password authentication if SSH keys are configured:
```none
PasswordAuthentication no
```
- Allow only specific users (optional):
```none
AllowUsers username
```
Restart the SSH service:
```bash
sudo systemctl restart ssh
```
---
## **Setting Up a Firewall**
Use **UFW** (Uncomplicated Firewall) to secure your server:
1. Install UFW if its not already present:
```bash
sudo apt install ufw
```
2. Allow SSH connections:
```bash
sudo ufw allow OpenSSH
```
3. Enable the firewall:
```bash
sudo ufw enable
```
4. Check the status:
```bash
sudo ufw status
```
Add rules for other services as needed (e.g., HTTP/HTTPS):
```bash
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
```
---
## **Regular Updates and Maintenance**
### **Keep the System Updated**
Update and upgrade the system regularly:
```bash
sudo apt update && sudo apt upgrade -y
```
### **Monitor Disk Usage**
Check disk usage to avoid running out of space:
```bash
df -h
```
### **Check Logs**
Review system logs for unusual activity:
```bash
sudo journalctl -xe
```
### **Install Monitoring Tools**
Install tools like `htop` for performance monitoring:
```bash
sudo apt install htop
htop
```
---
## **Testing the Configuration**
1. Log out of the root account:
```bash
exit
```
2. Log back in using the new user:
```bash
ssh username@<your-server-ip>
```
Verify that:
- You can log in using SSH keys.
- Root login is disabled.
- Password authentication is disabled (if configured).
- Firewall rules allow necessary services.
---
## **Optional Enhancements**
- **Enable Automatic Updates**:
Install and configure `unattended-upgrades` for automatic security updates:
```bash
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
```
- **Install Fail2Ban**:
Protect against brute-force attacks:
```bash
sudo apt install fail2ban
```
---
## **Conclusion**
This guide ensures your Debian-based server is secure, stable, and ready for application deployment. By following these steps, you establish a solid foundation for further customization and management, whether you're running a personal project or a production service.
**Next Steps**:
- Configure and deploy specific applications.
- Set up automated backups.
- Explore monitoring and logging tools.
Happy administering!
---
Return to the [Table of Contents](https://wiki.kitpro.us/table-of-contents) for more guides and tutorials.
@@ -0,0 +1,84 @@
---
tags:
- Server
- Security
---
```
# Command to see if someone is trying to gain access to you server over SSH.
tail -n 10 -f /var/log/auth.log
# Update your system
sudo apt update && sudo apt upgrade -y #Update and Update your system
# Change Root Password - Need to be in the system as root.
sudo su
passwd
#Create New User
sudo useradd -m -s /bin/bash miker && sudo passwd miker #you will be prompted to enter in the password
# -m creates a home account and -s sets the shell you will be using
# Add QEMU agent if on Proxmox
sudo apt install qemu-guest-agent -y
# Add new user to the groups
sudo cat /etc/sudoers to see what the admin and sudo groups are # THey are typically %admin and/or %sudo
sudo usermod -aG sudo,adm,admin,docker (username) #add user to admin or sudo group.
groups (username) # verify your account was added
# Ensure unattend upgrades is installed
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades #set the install to unattended
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades # Edit file to add additional unattended upgrade features
uncomment the -updates line, to recieve all pckage upgrades as well.
# Timezone
Update timezone in Ubuntu servers.
sudo dpkg-reconfigure tzdata
# Set up Secure SSH Keys and Passwords
cd ~/.ssh && ls -a # Go into your ssh directory and ensure that you have a id_rsa.pub on your workstation.
ssh-copy-id <username>@ip_address # Copy your public key to your server
# Use ONLY if you need to create a new keygen
ssh-keygen -t rsa # run in your home directory
#Lock down server access through SSH
sudo nano /etc/ssh/sshd_config # This is your sshd server system-wide configuration file
PasswordAuthentication yes # Change to no, this will disable SSH password authentication.
PermitRootLogin yes # Change to no, this will Disable remote root access, stop users from signing into your server.
AllowUsers (Your username you created)
AddressFamily inet # This will disable IPv6 access
sudo nano /etc/ssh/sshd_config.d/50-cloud-init.conf
PasswordAuthentication yes # Change to no, this will disable SSH password authentication.
clear # Restart your ssh service
Leave your current window open and launch a new terminal window to ensure you can get into the system.
# Enable additional security features
# Set Up UFW Firewall within the server if the VPS provide does not offer one.
sudo ss -tualp # show which ports are open on your server (needed if you plan to use UFW)
sudo apt install ufw # Install the UFW firewall
sudo ufw allow ssh # Add to allow port 22 within your firewall
sudo ufw allow http # add to allow port 80 within your firewall
sudo ufw allow https # Add to allow port 443 within your firewall
# use the same command to add other ports that will be needed.
sudo ufw enable # When complete, use this command to enable the firewall.
# If you need to, use this command to disable "sudo ufw disable" to deactivate the firewall if necessary.
# Install Fail2ban
# This server log application will automatically adjust your firewall to block an attackers IP address if it identifies any signs of an attack.
# Those blocks can stay in place permanently or for a period of your choosing.
sudo apt install fail2ban -y # Use this command to install Fail2ban:
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local # configuration file code:
sudo service fail2ban restart # restart the application to start running
sudo fail2ban-client status sshd
```
+13
View File
@@ -0,0 +1,13 @@
---
tags:
- Desktop
- Configs
---
| Command | Description |
| --- | --- |
| `sudo adduser <user>` | Create a new user |
| `sudo userdel <user>` | Delete a user |
| `sudo usermod -aG <group> <user>` | Add a user to group |
| `sudo deluser <user> <group>` | Remove a user from a group |
+79
View File
@@ -0,0 +1,79 @@
---
tags:
- Desktop
- Configs
---
weszterm.lua
```
- Pull in the wezterm API
local wezterm = require("wezterm")
-- This will hold the configuration.
local config = wezterm.config_builder()
local mux = wezterm.mux
local act = wezterm.action
-- This is where you actually apply your config choices
config.color_scheme = "Tokyo Night Moon"
config.font = wezterm.font("Hack Nerd Font Mono")
config.font_size = 10
--Keep tab bar available
config.enable_tab_bar = true
-- Static window size
config.initial_cols = 120
config.initial_rows = 50
-- Enables titlebar and border. This is default..
config.window_decorations = "TITLE | RESIZE"
config.window_background_opacity = 0.8
config.macos_window_background_blur = 10
-- my coolnight colorscheme:
config.colors = {
foreground = "#CBE0F0",
background = "#011423",
cursor_bg = "#47FF9C",
cursor_border = "#47FF9C",
cursor_fg = "#011423",
selection_bg = "#033259",
selection_fg = "#CBE0F0",
ansi = { "#214969", "#E52E2E", "#44FFB1", "#FFE073", "#0FC5ED", "#a277ff", "#24EAF7", "#24EAF7" },
brights = { "#214969", "#E52E2E", "#44FFB1", "#FFE073", "#A277FF", "#a277ff", "#24EAF7", "#24EAF7" },
}
-- Change background Wallpaper
config.background = {
{
source = {
File = "/home/miker/Documents/wallpapers/backiee-288178-landscape.jpg",
},
-- Optional: adjust how the image is displayed
hsb = { brightness = 0.1 }, -- Dim the image so text is readable
width = "100%",
height = "100%",
},
}
--Configure Hotkeys
config.disable_default_key_bindings = true
config.keys = {
{ key = 'R', mods = 'SHIFT|CTRL', action = act.ReloadConfiguration },
{ key = '+', mods = 'CTRL', action = act.IncreaseFontSize },
{ key = '-', mods = 'CTRL', action = act.DecreaseFontSize },
{ key = '0', mods = 'CTRL', action = act.ResetFontSize },
{ key = 'c', mods = 'CTRL', action = act.CopyTo 'Clipboard' },
{ key = 'N', mods = 'CTRL', action = act.SpawnWindow },
{ key = 'U', mods = 'CTRL', action = act.CharSelect{ copy_on_select = true, copy_to = 'ClipboardAndPrimarySelection' } },
{ key = 'v', mods = 'CTRL', action = act.PasteFrom 'Clipboard' },
{ key = 'f', mods = 'CTRL', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
{ key = 'd', mods = 'CTRL', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
{ key = 't', mods = 'CTRL', action = act.CloseCurrentTab{ confirm = false } },
{ key = 'q', mods = 'CTRL', action = act.CloseCurrentPane{ confirm = false} },
{ key = 'r', mods = 'LEADER', action = act.ActivateKeyTable { name = 'resize_pane', one_shot = false } },
}
-- and finally, return the configuration to wezterm
return config
```
+99
View File
@@ -0,0 +1,99 @@
---
tags:
- Desktop
- Configs
---
Entry
```
[env]
# TERM = "alacritty"
TERM = "xterm-256color"
[window]
decorations = "full" # Window decorations.(Full - Borders and title bar) or (None - Neither borders nor title bar.)
dynamic_padding = false # Spread additional padding evenly around the terminal content.
dynamic_title = false # Allow terminal applications to change Alacritty's window title.
opacity = 0.9 # 0.0 is Complete Transparent .... 1.0 is No Transparencystartup_mode = "Windowed" # Startup mode (Windowed, Maximized, Full>
title = "Miker's Terminal" # Window title.
blur = false # Request compositor to blur content behind transparent windows.
[window.dimensions]
columns = 140 # Set your desired number of columns
lines = 50 # Set your desired number of lines
[window.padding]
x = 0
y = 0
[scrolling]
history = 500 # Maximum number of lines in the scrollback buffer
[font]
builtin_box_drawing = false
size = 10
[bell]
animation = "EaseOutExpo"
color = "#C0C5CE"
command = "None"
duration = 0
[selection]
save_to_clipboard = false
semantic_escape_chars = ",│`|:\"' ()[]{}<>\t"
[cursor]
unfocused_hollow = true
vi_mode_style = "None"
[[keyboard.bindings]]
action = "Paste"
key = "V"
mods = "Control"
[[keyboard.bindings]]
action = "Copy"
key = "C"
mods = "Control"
[[keyboard.bindings]]
action = "ScrollPageUp"
key = "PageUp"
mods = "Shift"
[[keyboard.bindings]]
action = "ScrollPageDown"
key = "PageDown"
mods = "Shift"
[[keyboard.bindings]]
action = "ScrollToTop"
key = "Home"
mods = "Shift"
[[keyboard.bindings]]
action = "ScrollToBottom"
key = "End"
mods = "Shift"
[mouse]
hide_when_typing = true
[debug]
highlight_damage = false
log_level = "Warn"
persistent_logging = false
print_events = false
render_timer = false
[general]
# alacritty.toml
live_config_reload = true # Live config reload (changes require restart)
import = [
"~/.config/alacritty/themes/falcon.toml"
]
```
@@ -0,0 +1,331 @@
---
tags:
- Desktop
- Configs
---
## .bachrc
```
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Load fastfetch
fastfetch
# Check if starship is installed
if ! command -v starship &> /dev/null
then
echo "Starship not found, installing..."
# Install starship (using the recommended installation script)
curl -sS https://starship.rs/install.sh | sh
# You can also specify an installation directory, e.g., if you don't have sudo access:
# curl -sS https://starship.rs/install.sh | sh -s -- -b ~/.local/bin
echo "Starship installed."
fi
# Load starship prompt if starship is installed
if [ -x /usr/bin/starship ]; then
__main() {
local major="${BASH_VERSINFO[0]}"
local minor="${BASH_VERSINFO[1]}"
if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
source <("/usr/bin/starship" init bash --print-full-init)
else
source /dev/stdin <<<"$("/usr/bin/starship" init bash --print-full-init)"
fi
}
__main
unset -f __main
fi
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
ISTSIZE=20000
HISTFILESIZE=10000
# check the window size after each command and, if necessary,
shopt -s checkwinsize
# Combine multiline commands into one in history
shopt -s cmdhist
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
}
# Load Aliases and Finctions, instead of adding them here directly.
if [ -e $HOME/.bash_aliases ]; then
source $HOME/.bash_aliases
fi
if [ -e $HOME/.bash_functions ]; then
source $HOME/.bash_functions
fi
# enable programmable completion features (you don't need to enable this, if it's already enabled in /etc/bash.bashrc >
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Make Nano the default Editor
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='nano'
else
export EDITOR='nano'
fi
### FZF ###
# Enables the following keybindings:
# CTRL-t = fzf select
# CTRL-r = fzf history
# ALT-c = fzf cd
eval "$(fzf --bash)"
# Added by LM Studio CLI (lms)
export PATH="$PATH:/home/miker/.lmstudio/bin"
# End of LM Studio CLI section
# Automatically preform ls when changing directory,
cd() {
builtin cd "$@" && ls -lA
}
# Initialize starship
eval "$(starship init bash)"eval "$(zoxide init bash)"
. "$HOME/.cargo/env"
```
## .bash_aliases
```
# ~/.bashrc: executed by bash(1) for non-login shells.
#EZA
alias ls='eza --all --long --group --group-directories-first --icons --header --time-style long-iso'
alias l='eza -lahF --color=auto --icons --sort=size --group-directories-first'
alias lss='eza -hF --color=auto --icons --sort=size --group-directories-first'
alias la='eza -ahF --color=auto --icons --sort=size --group-directories-first'
alias lst='eza -lahT --color=auto --icons --sort=size --group-directories-first'
alias lt='eza -aT --icons --group-directories-first --color=auto --sort=size'
# FZF
alias finddoc='fzf --style full --preview="bat --color=always {}"'
# Clear the screen
alias c='clear'
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
#Grabs the disk usage in the current directory
alias used='du -sch .[!.]* * 2>/dev/null | sort -h'
#Gets the total disk usage on your machine
alias totalusage='df -hl --total | grep total'
#Shows the individual partition usages without the temporary memory values
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs'
#Gives you what is using the most space. Both directories and files. Varies on current directory
alias most='du -hsx * | sort -rh | head -10'
# View only mounted Drives
alias mnt="mount | awk -F' ' '{ printf \"%s\t%s\n\",\$1,\$3; }' | column -t | egrep ^/dev/ | sort"
# handy short cuts #
alias h='history'
alias j='jobs -l'
alias path='echo -e ${PATH//:/\\n}'
# Set nano as default
alias n=nano
alias sn='sudo nano'
alias edit=nano
# Show open ports - Use netstat command to quickly list all TCP/UDP port on the server:
alias ports='netstat -tulanp'
# reboot / halt / poweroff
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'
## set some other defaults ##
alias df='df -H'
alias du='du -ch'
# Edit the bashrc and re-source it when saved and closed.
alias bashrc="nano ~/.bashrc && source ~/.bashrc"
# ps
alias psa="ps auxf"
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
alias psmem='ps auxf | sort -nr -k 4'
alias pscpu='ps auxf | sort -nr -k 3'
lias addup='git add -u'
alias addall='git add .'
alias branch='git branch'
alias checkout='git checkout'
alias clone='git clone'
alias commit='git commit -m'
alias fetch='git fetch'
alias pull='git pull origin'
alias push='git push origin'
alias stat='git status' # 'status' is protected name so using 'stat' instead
alias tag='git tag'
alias newtag='git tag -a'
# get error messages from journalctl
alias jctl="journalctl -p 3 -xb"
```
## .bash_functions
```
# ~/.bashrc
function git_branch() {
git_branch=$(git branch --no-color 2>/dev/null | grep \* | sed 's/* //')
if [ $git_branch ]
then
white="\001\033[0;37m\002"
yellow="\001\033[0;33m\002"
blue="\001\033[0;34m\002"
red="\001\033[0;31m\002"
git_status=$(git status --porcelain 2>/dev/null)
git_count_t=$(for i in "$git_status"; do echo "$i"; done | grep -v '^?? ' | sed '/^$/d' | wc -l | sed "s/ //g")
git_count_color_t=$(if [ $git_count_t = "0" ]; then echo -e "$blue"; else echo -e "$red"; fi)
git_count_ut=$(for i in "$git_status"; do echo "$i"; done | grep '^?? ' | sed '/^$/d' | wc -l | sed "s/ //g")
git_count_color_ut=$(if [ $git_count_ut = "0" ]; then echo -e "$blue"; else echo -e "$red"; fi)
echo -e "$white:$yellow${git_branch}$white:$git_count_color_t${git_count_t}$white:$git_count_color_ut${git_count_u>
fi
}
function pushall() {
sudo git add .
sudo git commit --all
sudo git push --all
}
short_pwd() {
cwd=$(pwd | sed "s#${HOME}#~#g" | perl -F/ -ane 'print join( "/", map { $i++ < @F - 1 ? substr $_,0,1 : $_ } @F)')
echo -n $cwd
}
set_bash_prompt() {
if [ "$UID" = 0 ]; then
#root
PS1="\[\033[0;31m\]\u\[\033[0;37m\]@\h\[\033[1;37m\] \[\033[0;31m\]\$(short_pwd)\$(git_branch)\[\033[0;36m\]# \[\0>
else
#non-root
PS1="\[\033[0;32m\]\u\[\033[0;37m\]@\h\[\033[1;37m\] \[\033[0;32m\]\$(short_pwd)\$(git_branch)\[\033[0;36m\]$ \[\0>
fi
}
xtract() {
if [ -z ${1} ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: extract <archive> [directory]"
echo "Example: extract presentation.zip."
echo "Valid archive types are:"
echo "tar.bz2, tar.gz, tar.xz, tar, bz2, gz, tbz2,"
echo "tbz, tgz, lzo, rar, zip, 7z, xz, txz, lzma and tlz"
else
case "$1" in
*.tar.bz2|*.tbz2|*.tbz) tar xvjf "$1" ;;
*.tgz) tar zxvf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.tar.xz) tar xvJf "$1" ;;
*.tar) tar xvf "$1" ;;
*.rar) 7z x "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7z x "$1" ;;
*.lzo) lzop -d "$1" ;;
*.gz) gunzip "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.Z) uncompress "$1" ;;
*.xz|*.txz|*.lzma|*.tlz) xz -d "$1" ;;
*) echo "Sorry, '$1' could not be decompressed." ;;
esac
fi
}
# Goes up many dirs as the number passed as argument, if none goes up by 1 by default
up(){
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}
# Creates a directory and immediately changes into it.
mkcd() {
mkdir -p "$1" && cd "$1"
}
# Displays your external IP address
myip() {
curl -s ifconfig.me
}
# Get colors in manual 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 "$@"
}
```
@@ -0,0 +1,342 @@
---
tags:
- Desktop
- Configs
---
.zshrc
```
# If you're using fastfetch with Powerlevel10k's instant prompt feature, it's a known source of incompatibility. fastfetch command in your .zshrc file is placed before the initialization of p10k-instant-prompt
fastfetch
############################# CHECK IF INSTALLED, IF NOT THEN INSTALL ###########################
if [ ! -f "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k/powerlevel10k.zsh-theme" ]; then
echo "Powerlevel10k not found. Installing..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
echo "Powerlevel10k installed."
fi
# Check if Starship is installed, if not, install it
if ! command -v starship &> /dev/null; then
echo "Starship not found, installing..."
sudo apt update
sudo apt install starship -y
fi
# Check if Oh My Zsh is installed
if [ ! -d "$HOME/.oh-my-zsh" ]; then
# Oh My Zsh is not installed, proceed with installation
echo "Oh My Zsh not found. Installing..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
else
# Oh My Zsh is installed, source it
source $HOME/.oh-my-zsh/oh-my-zsh.sh
fi
########################## EXPORT PATHS #########################################################
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
# Added by LM Studio CLI (lms)
export PATH="$PATH:/home/miker/.lmstudio/bin"
######################### HISTORY CONTROLS #######################################################
HISTCONTROL=ignoreboth
HISTSIZE=100000
HISTFILESIZE=100000
HISTFILE=~/.zsh_history
setopt INC_APPEND_HISTORY
setopt hist_ignore_all_dups # remove older duplicate entries from history
setopt hist_reduce_blanks # remove superfluous blanks from history items
setopt inc_append_history # save history entries as soon as they are entered
setopt share_history # share history between different instances of the shell
setopt auto_cd # cd by typing directory name if it's not a command
setopt correct_all # autocorrect commands
setopt auto_list # automatically list choices on ambiguous completion
setopt auto_menu # automatically use menu completion
setopt always_to_end # move cursor to end if word had one match
########################### POWERLEVEL & ZSH & OH-MY-ZSH SETTINGS ################################
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Set the zsh theme to powerlevel10k
ZSH_THEME="powerlevel10k/powerlevel10k"
# update automatically without asking
zstyle ':omz:update' mode auto
# Uncomment the following line to change how often to auto-update (in days).
zstyle ':omz:update' frequency 13
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
zsh-autosuggestions
zsh-bat
ansible
colored-man-pages
terraform
systemadmin
aliases
alias-finder
zoxide
ubuntu
ssh
kate
fzf
zsh-syntax-highlighting
)
# Cache completions aggressively
autoload -Uz compinit
if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)" ]; then
compinit
else
compinit -C
fi
# Load oh my zsh
source $ZSH/oh-my-zsh.sh
source ~/powerlevel10k/powerlevel10k.zsh-theme
################################ SETTING EDITOR ###################################################
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='nano'
else
export EDITOR='nano'
fi
################################## GITHUB EXPORT ###################################################
export GITHUB_USERNAME="mmcferidge1969"
export GITHUB_EMAIL="mmcfetridg@aol.com"
################################## CD INTO DIR AND LIST ############################################
cd() {
builtin cd "$@" && ls -lA
}
################################# GIT GLOBAL SETTINGS ################################################
git config --global user.name "mmcfetridge1969"
git config --global user.email "mmcfetridg@aol.com"
# Git Branch Function
parse_git_branch() {
local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -n "$branch" ]]; then
local dirty=$(git status --porcelain 2>/dev/null | grep -q '^[A-Z]' && echo "*" || true)
echo "[$branch$dirty]"
else
echo ""
fi
}
########################## SOURCE FILES ##########################################################
source ~/.zsh_aliases
source ~/.zsh_functions
################################# INITIALIZE APPS ###################################################
eval "$(starship init zsh)"
# Set up fzf key bindings and fuzzy completion
source <(fzf --zsh)
```
.zsh_aliases
```
#EZA
alias ls='eza --all --long --group --group-directories-first --icons --header --time-style long-iso'
alias l='eza -lahF --color=auto --icons --sort=size --group-directories-first'
alias lss='eza -hF --color=auto --icons --sort=size --group-directories-first'
alias la='eza -ahF --color=auto --icons --sort=size --group-directories-first'
alias lst='eza -lahT --color=auto --icons --sort=size --group-directories-first'
alias lt='eza -aT --icons --group-directories-first --color=auto --sort=size'
# FZF
alias finddoc='fzf --style full --preview="bat --color=always {}"'
# Clear the screen
alias c='clear'
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
#Grabs the disk usage in the current directory
alias used='du -sch .[!.]* * 2>/dev/null | sort -h'
#Gets the total disk usage on your machine
alias totalusage='df -hl --total | grep total'
#Shows the individual partition usages without the temporary memory values
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs'
#Gives you what is using the most space. Both directories and files. Varies on current directory
alias most='du -hsx * | sort -rh | head -10'
# View only mounted Drives
alias mnt="mount | awk -F' ' '{ printf \"%s\t%s\n\",\$1,\$3; }' | column -t | egrep ^/dev/ | sort"
# handy short cuts #
alias h='history'
alias j='jobs -l'
alias path='echo -e ${PATH//:/\\n}'
# Set nano as default
alias n=nano
alias sn='sudo nano'
alias edit=nano
# Show open ports - Use netstat command to quickly list all TCP/UDP port on the server:
alias ports='netstat -tulanp'
# reboot / halt / poweroff
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'
## set some other defaults ##
alias df='df -H'
alias du='du -ch'
# Edit the bashrc and re-source it when saved and closed.
alias bashrc="nano ~/.bashrc && source ~/.bashrc"
# ps
alias psa="ps auxf"
alias psgrep="ps aux | grep -v grep | grep -i -e VSZ -e"
alias psmem='ps auxf | sort -nr -k 4'
alias pscpu='ps auxf | sort -nr -k 3'
# git
alias addup='git add -u'
alias addall='git add .'
alias branch='git branch'
alias checkout='git checkout'
alias clone='git clone'
alias commit='git commit -m'
alias fetch='git fetch'
alias pull='git pull origin'
alias push='git push origin'
alias stat='git status' # 'status' is protected name so using 'stat' instead
alias tag='git tag'
alias newtag='git tag -a'
# get error messages from journalctl
alias jctl="journalctl -p 3 -xb"
```
zsh_functions
```
unction git_branch() {
git_branch=$(git branch --no-color 2>/dev/null | grep \* | sed 's/* //')
if [ $git_branch ]
then
white="\001\033[0;37m\002"
yellow="\001\033[0;33m\002"
blue="\001\033[0;34m\002"
red="\001\033[0;31m\002"
git_status=$(git status --porcelain 2>/dev/null)
git_count_t=$(for i in "$git_status"; do echo "$i"; done | grep -v '^?? ' | sed '/^$/d' | wc -l | sed "s/ //g")
git_count_color_t=$(if [ $git_count_t = "0" ]; then echo -e "$blue"; else echo -e "$red"; fi)
git_count_ut=$(for i in "$git_status"; do echo "$i"; done | grep '^?? ' | sed '/^$/d' | wc -l | sed "s/ //g")
git_count_color_ut=$(if [ $git_count_ut = "0" ]; then echo -e "$blue"; else echo -e "$red"; fi)
echo -e "$white:$yellow${git_branch}$white:$git_count_color_t${git_count_t}$white:$git_count_color_ut${git_count_ut}"
fi
}
function pushall() {
sudo git add .
sudo git commit --all
sudo git push --all
}
short_pwd() {
cwd=$(pwd | sed "s#${HOME}#~#g" | perl -F/ -ane 'print join( "/", map { $i++ < @F - 1 ? substr $_,0,1 : $_ } @F)')
echo -n $cwd
}
set_bash_prompt() {
if [ "$UID" = 0 ]; then
#root
PS1="\[\033[0;31m\]\u\[\033[0;37m\]@\h\[\033[1;37m\] \[\033[0;31m\]\$(short_pwd)\$(git_branch)\[\033[0;36m\]# \[\033[0m\]"
else
#non-root
PS1="\[\033[0;32m\]\u\[\033[0;37m\]@\h\[\033[1;37m\] \[\033[0;32m\]\$(short_pwd)\$(git_branch)\[\033[0;36m\]$ \[\033[0m\]"
fi
}
# Extracts pretty much anything you throw at it granted you have the program for it.
extract() {
if [ -z ${1} ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: extract <archive> [directory]"
echo "Example: extract presentation.zip."
echo "Valid archive types are:"
echo "tar.bz2, tar.gz, tar.xz, tar, bz2, gz, tbz2,"
echo "tbz, tgz, lzo, rar, zip, 7z, xz, txz, lzma and tlz"
else
case "$1" in
*.tar.bz2|*.tbz2|*.tbz) tar xvjf "$1" ;;
*.tgz) tar zxvf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.tar.xz) tar xvJf "$1" ;;
*.tar) tar xvf "$1" ;;
*.rar) 7z x "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7z x "$1" ;;
*.lzo) lzop -d "$1" ;;
*.gz) gunzip "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.Z) uncompress "$1" ;;
*.xz|*.txz|*.lzma|*.tlz) xz -d "$1" ;;
*) echo "Sorry, '$1' could not be decompressed." ;;
esac
fi
}
# Goes up many dirs as the number passed as argument, if none goes up by 1 by default
up(){
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}
# Creates a directory and immediately changes into it.
mkcd() {
mkdir -p "$1" && cd "$1"
}
# Displays your external IP address
myip() {
curl -s ifconfig.me
}
```