Drop OSX support; support desktop, laptop, cloudtop
Dropping support for OSX. Moving forward these dotfiles will depend on Linux systems. Furthermore, since I'm support a ~/bin, the machines that consume these dotfiles depend on i386 architectures. Linux and i386 are two dependencies that I'm okay with since the leverage this assumption provides, makes their existence tolerable. There is some Google leakage herein, which includes aliases, functions, and mentions of cloudtop. For now, this is okay. I may break the Google specific code into its own repository, but for now, this is less maintenance. This also introduces a ~/.profile instead of erroneously defining environment variables in my zshrc file, which was unadvised. This is a large commit and also introduces new aliases, variables, functions that I accumulated over the past week or so while migrating away from OSX and onto my new setup. Hopefully in the future I'll be more precise with my commits.
This commit is contained in:
parent
bf33edaa6e
commit
f7b3e0a7a9
77 changed files with 2587 additions and 714 deletions
|
@ -260,6 +260,8 @@ these tasks completed, ligatures should function in Neovim.
|
|||
|
||||
|
||||
## Miscellaneous notes
|
||||
* Install executables or scripts to `~/bin`
|
||||
* should be fine as long as they are shared between computers with i386 architectures
|
||||
* Map `<CAPS_LOCK>` key to `<ESC>`
|
||||
* Increase key-repeat rate
|
||||
* Decrease key-repeat-delay
|
||||
|
|
|
@ -2,10 +2,16 @@
|
|||
|
||||
configs="$DOTFILES/configs"
|
||||
|
||||
if [[ $(uname) == 'Darwin' ]]; then
|
||||
(cd "$configs/os_x" && stow --target="$HOME" *)
|
||||
elif [[ $(uname) == 'Linux' ]]; then
|
||||
(cd "$configs/linux" && stow --target="$HOME" *)
|
||||
fi
|
||||
case $(hostname) in
|
||||
# desktop
|
||||
wpcarro.lon.corp.google.com)
|
||||
(cd "$configs/desktop" && stow --target="$HOME" *);;
|
||||
# laptop
|
||||
wpcarro.roam.googlers.com)
|
||||
(cd "$configs/laptop" && stow --target="$HOME" *);;
|
||||
# cloudtop
|
||||
wpcarro.c.googlers.com)
|
||||
(cd "$configs/cloudtop" && stow --target="$HOME" *);;
|
||||
esac
|
||||
|
||||
(cd "$configs/shared" && stow --target="$HOME" *)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Heavily inspired by this blog post:
|
||||
# https://bl.ocks.org/mijoharas/b9d09daed9654ca8d0d081015209ecd0
|
||||
|
||||
get_focused_window() {
|
||||
i3-msg -t get_tree | jq -r ".. | select(.focused? == true).window_properties.class"
|
||||
}
|
||||
|
||||
perform_close() {
|
||||
if [ "$(get_focused_window)" = "Emacs" ]; then
|
||||
emacsclient -e "(delete-window)"
|
||||
result=$?
|
||||
if [ $result -ne 0 ]; then
|
||||
i3-msg kill
|
||||
fi
|
||||
else
|
||||
i3-msg kill
|
||||
fi
|
||||
}
|
||||
|
||||
perform_move() {
|
||||
if [ "$(get_focused_window)" = "Emacs" ]; then
|
||||
emacsclient -e "(evil-window-$1 1)"
|
||||
result=$?
|
||||
if [ $result -ne 0 ]; then
|
||||
i3-msg focus "$1"
|
||||
fi
|
||||
else
|
||||
i3-msg focus "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
left) ;&
|
||||
right) ;&
|
||||
up) ;&
|
||||
down)
|
||||
perform_move "$1"
|
||||
;;
|
||||
quit)
|
||||
perform_close
|
||||
;;
|
||||
*) echo "command not found" ;;
|
||||
esac
|
|
@ -1,9 +0,0 @@
|
|||
! Load theme from custom themes package
|
||||
#include "/usr/local/google/home/wpcarro/programming/Xresources-themes/base16-monokai-256.Xresources"
|
||||
|
||||
! urxvt settings
|
||||
URxvt.cursorBlink: true
|
||||
URxvt.cursorUnderline: true
|
||||
URxvt.scrollBar: false
|
||||
URxvt.font: xft:source code pro:size=12:antialias=true
|
||||
URxvt.boldFont: xft:source code pro:bold:size=12:antialias=true
|
|
@ -1,123 +0,0 @@
|
|||
// Support flag to branch KBDs depending on presence of Ergodox keyboard.
|
||||
|
||||
// Since the Ergodox has complicated modifier keys like "hyper" and "meh" key,
|
||||
// we should prefer to use these when that keyboard is attached because it
|
||||
// reduces the potential for collisions for Emacs KBDs. This becomes
|
||||
// problematic, however, when the Ergodox is not attached because these keys are
|
||||
// unavailable. Slate KBDs. Under these circumstances, potential collisions
|
||||
// with Emacs KBDs is acceptable.
|
||||
|
||||
var ergodox_attached = true;
|
||||
|
||||
var HYPER = ":alt;shift;cmd;ctrl";
|
||||
var MEH = ":alt;shift;ctrl";
|
||||
|
||||
var modal_key = ergodox_attached ? HYPER : ":ctrl;shift";
|
||||
var resize_key = ergodox_attached ? MEH : ":alt;shift";
|
||||
|
||||
// Configs
|
||||
S.cfga({
|
||||
defaultToCurrentScreen: true,
|
||||
secondsBetweenRepeat: 0.1,
|
||||
checkDefaultsOnLoad: true,
|
||||
focusCheckWidthMax: 3000
|
||||
});
|
||||
|
||||
// window resizing bindings
|
||||
var window_resizing_bindings = {
|
||||
";": {
|
||||
x: "screenSizeX/3*2 + screenOriginX+20",
|
||||
y: "screenOriginY+20",
|
||||
width: "screenSizeX/3 - 40",
|
||||
height: "screenSizeY-100"
|
||||
},
|
||||
g: {
|
||||
x: "screenOriginX+20",
|
||||
y: "screenOriginY+20",
|
||||
width: "screenSizeX/3*2 - 40",
|
||||
height: "screenSizeY-100"
|
||||
},
|
||||
o: {
|
||||
x: "screenSizeX / 2 + screenOriginX + 20",
|
||||
y: "screenOriginY + 20",
|
||||
width: "screenSizeX / 2 - 40",
|
||||
height: "(screenSizeY - 120) / 2"
|
||||
},
|
||||
",": {
|
||||
x: "screenSizeX / 2 + screenOriginX + 20",
|
||||
y: "(screenSizeY - 120) / 2 + 20 + 20",
|
||||
width: "screenSizeX / 2 - 40",
|
||||
height: "(screenSizeY - 120) / 2"
|
||||
},
|
||||
h: {
|
||||
x: "screenOriginX+20",
|
||||
y: "screenOriginY+20",
|
||||
width: "screenSizeX*0.5 - 40",
|
||||
height: "screenSizeY-100"
|
||||
},
|
||||
j: {
|
||||
x: "screenOriginX+screenSizeX/6",
|
||||
y: "screenOriginY+20",
|
||||
width: "2*screenSizeX/3",
|
||||
height: "screenSizeY - 100"
|
||||
},
|
||||
k: {
|
||||
x: "screenOriginX+20",
|
||||
y: "screenOriginY+20",
|
||||
width: "screenSizeX - 40",
|
||||
height: "screenSizeY - 100"
|
||||
},
|
||||
l: {
|
||||
x: "screenSizeX/2 + screenOriginX+20",
|
||||
y: "screenOriginY+20",
|
||||
width: "screenSizeX*0.5 - 40",
|
||||
height: "screenSizeY-100"
|
||||
}
|
||||
};
|
||||
|
||||
var window_resizing_bindings = Object.keys(window_resizing_bindings).reduce(
|
||||
function(acc, kbd) {
|
||||
acc[kbd + resize_key] = S.op("move", window_resizing_bindings[kbd]);
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
S.bnda(window_resizing_bindings);
|
||||
|
||||
// Moves applications across multiple screens
|
||||
var throwLeft = slate.operation("throw", {
|
||||
screen: "0",
|
||||
width: "screenSizeX",
|
||||
height: "screenSizeY"
|
||||
});
|
||||
var throwRight = slate.operation("throw", {
|
||||
screen: "1",
|
||||
width: "screenSizeX",
|
||||
height: "screenSizeY"
|
||||
});
|
||||
|
||||
slate.bind("1:ctrl", throwLeft);
|
||||
slate.bind("2:ctrl", throwRight);
|
||||
|
||||
var focus_apps = {
|
||||
1: "1Password",
|
||||
i: "iTunes",
|
||||
a: "Atom",
|
||||
h: "Dash",
|
||||
e: "Emacs",
|
||||
t: "iTerm2",
|
||||
m: "Messages",
|
||||
s: "Spotify",
|
||||
c: "Google Chrome",
|
||||
l: "LimeChat",
|
||||
k: "Slack",
|
||||
w: "Wireshark",
|
||||
p: "Tomato One",
|
||||
d: "Discord"
|
||||
};
|
||||
|
||||
Object.keys(focus_apps).forEach(function(key) {
|
||||
app = focus_apps[key];
|
||||
S.bind(key + modal_key, S.op("focus", { app: app }));
|
||||
});
|
|
@ -71,6 +71,7 @@
|
|||
"el" (lambda () (interactive) (wpc/find-file-split "~/variables.zsh"))
|
||||
"ex" (lambda () (interactive) (wpc/find-file-split "~/.Xresources"))
|
||||
"ei" (lambda () (interactive) (wpc/find-file-split "~/.config/i3/config"))
|
||||
"em" (lambda () (interactive) (wpc/find-file-split "~/.tmux.conf"))
|
||||
|
||||
"B" #'magit-blame
|
||||
"w" #'save-buffer
|
||||
|
|
|
@ -45,10 +45,10 @@
|
|||
;; create file bookmarks
|
||||
(set-register ?e '(file . "~/.emacs.d/wpc/packages"))
|
||||
(set-register ?n '(file . "~/programming/nixify/configuration.nix"))
|
||||
(set-register ?d '(file . "~/programming/dotfiles"))
|
||||
(set-register ?d '(file . "~/Dropbox/dotfiles"))
|
||||
(set-register ?s '(file . "~/.slate.js"))
|
||||
(set-register ?D '(file . "~/Dropbox"))
|
||||
(set-register ?o '(file . "~/Documents/org/"))
|
||||
(set-register ?o '(file . "~/Dropbox/org/")) ;; TODO: change this to `(getenv "ORG_DIRECTORY")'
|
||||
|
||||
(set-register ?v '(file . "~/.config/nvim/init.vim"))
|
||||
(set-register ?e '(file . "~/.emacs.d/init.el"))
|
||||
|
@ -58,6 +58,7 @@
|
|||
(set-register ?l '(file . "~/variables.zsh"))
|
||||
(set-register ?x '(file . "~/.Xresources"))
|
||||
(set-register ?i '(file . "~/.config/i3/config"))
|
||||
(set-register ?m '(file . "~/.tmux.conf"))
|
||||
|
||||
(set-register ?p `(file . ,wpc/current-project))
|
||||
|
||||
|
|
|
@ -6,29 +6,39 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(getenv "ORG_DIRECTORY")
|
||||
|
||||
;; TODO: figure out how to nest this in (use-package org ...)
|
||||
(setq org-capture-templates
|
||||
(quote (
|
||||
`(
|
||||
|
||||
("w" "work" entry (file+headline "~/Documents/org/work.org" "Tasks")
|
||||
("w" "work" entry (file+headline
|
||||
,(f-join (getenv "ORG_DIRECTORY") "work.org")
|
||||
"Tasks")
|
||||
"* TODO %?")
|
||||
|
||||
("p" "personal" entry (file+headline "~/Documents/org/personal.org" "Tasks")
|
||||
("p" "personal" entry (file+headline
|
||||
,(f-join (getenv "ORG_DIRECTORY") "personal.org")
|
||||
"Tasks")
|
||||
"* TODO %? ")
|
||||
|
||||
)))
|
||||
("i" "ideas" entry (file+headline
|
||||
,(f-join (getenv "ORG_DIRECTORY") "ideas.org")
|
||||
"Tasks")
|
||||
"* %? ")
|
||||
|
||||
))
|
||||
(evil-set-initial-state 'org-mode 'insert)
|
||||
|
||||
(use-package org
|
||||
:preface
|
||||
(defconst wpc-org-directory
|
||||
"~/Documents/org")
|
||||
:config
|
||||
; (general-add-hook org-mode-hook (disable linum-mode))
|
||||
(general-define-key :prefix "C-c"
|
||||
"l" #'org-store-link
|
||||
"a" #'org-agenda
|
||||
"c" #'org-capture)
|
||||
(setq org-todo-keywords
|
||||
'((sequence "TODO" "BLOCKED" "DONE")))
|
||||
(setq org-default-notes-file (wpc/org-file "notes"))
|
||||
(setq org-log-done 'time)
|
||||
(setq org-agenda-files (list (wpc/org-file "work")
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
(setq-default line-spacing 4)
|
||||
|
||||
;; change font
|
||||
(add-to-list 'default-frame-alist '(font . "Source Code Pro-9"))
|
||||
(add-to-list 'default-frame-alist '(font . "Operator Mono Book-9"))
|
||||
|
||||
(defconst wpc/font-size-step 10
|
||||
"The amount (%) by which to increase or decrease a font.")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
set -e
|
||||
|
||||
# Run this script to import all of the information exported by `export.sh`.
|
||||
# Usage: ./export.sh path/to/directory
|
||||
# Usage: ./import.sh path/to/directory
|
||||
|
||||
gpg --import "$1/public.asc"
|
||||
gpg --import "$1/secret.asc"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
set $mod Mod1
|
||||
set $super Mod4
|
||||
|
||||
# Keymapping philosophy:
|
||||
# When I feel it's appropriate, I try to borrow existing KBDs from OSX or
|
||||
|
@ -38,14 +39,14 @@ floating_modifier $mod
|
|||
# spotify = s
|
||||
#
|
||||
# Vertical
|
||||
bindsym $mod+Ctrl+t split v; exec gnome-terminal
|
||||
bindsym $mod+Ctrl+Return split v; exec gnome-terminal
|
||||
bindsym $mod+Ctrl+t split v; exec st
|
||||
bindsym $mod+Ctrl+Return split v; exec st
|
||||
bindsym $mod+Ctrl+e split v; exec emacs
|
||||
bindsym $mod+Ctrl+c split v; exec google-chrome
|
||||
bindsym $mod+Ctrl+s split v; exec spotify
|
||||
# Horizontal
|
||||
bindsym $mod+Ctrl+Shift+t split h; exec gnome-terminal
|
||||
bindsym $mod+Ctrl+Shift+Return split h; exec gnome-terminal
|
||||
bindsym $mod+Ctrl+Shift+t split h; exec st
|
||||
bindsym $mod+Ctrl+Shift+Return split h; exec st
|
||||
bindsym $mod+Ctrl+Shift+e split h; exec emacs
|
||||
bindsym $mod+Ctrl+Shift+c split h; exec google-chrome
|
||||
bindsym $mod+Ctrl+Shift+s split h; exec spotify
|
||||
|
@ -58,6 +59,9 @@ bindsym F12 exec --no-startup-id pactl set-sink-volume @DEFAULT
|
|||
bindsym F11 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% # same Fn keys as MBP
|
||||
bindsym F10 exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # same Fn keys as MBP
|
||||
|
||||
# pass integration
|
||||
bindsym $mod+Ctrl+backslash exec ~/.config/i3/passmenu # mirroring the 1password KBD
|
||||
|
||||
# screen brightness controls
|
||||
bindsym XF86MonBrightnessUp exec light -A 10
|
||||
bindsym XF86MonBrightnessDown exec light -U 10
|
||||
|
@ -66,17 +70,21 @@ bindsym XF86MonBrightnessDown exec light -U 10
|
|||
bindsym $mod+o exec zsh -i -c org_capture
|
||||
for_window [class="GoogleEmacs" instance="org-protocol-capture"] floating enable
|
||||
|
||||
# ensure Spotify windows float
|
||||
for_window [class="Spotify"] floating enable
|
||||
|
||||
# ensure wallpaper
|
||||
exec --no-startup-id feh --bg-scale ~/Pictures/cartoon-outdoors.jpg
|
||||
exec --no-startup-id feh --bg-scale ~/.local/share/wallpaper/cartoon-outdoors.jpg
|
||||
|
||||
# ensure system service that run through XDG start
|
||||
exec dex -ae i3
|
||||
|
||||
# rofi window, workspace settings
|
||||
bindsym Mod4+space exec --no-startup-id i3-dmenu-desktop --dmenu='rofi -i -dmenu -width 40 -lines 8'
|
||||
bindsym $mod+space exec "rofi -show run"
|
||||
bindsym $mod+w exec "rofi -show window"
|
||||
bindsym $mod+b exec "rofi -show Workspace"
|
||||
# dmenu configuration
|
||||
bindsym $mod+space exec --no-startup-id dmenu_run
|
||||
bindsym $mod+t exec --no-startup-id ~/.config/i3/dmenu_timer.sh ~/.local/share/sounds/gong.mp3
|
||||
|
||||
# file manager
|
||||
bindsym $mod+x exec st -e ~/bin/lf # TODO: reconsider hardlink and expose ZSH's PATH to i3
|
||||
|
||||
# music player kbds
|
||||
bindsym F9 exec --no-startup-id playerctl next # same Fn keys as MBP
|
||||
|
@ -84,12 +92,14 @@ bindsym F8 exec --no-startup-id playerctl play-pause # same Fn keys as MBP
|
|||
bindsym F7 exec --no-startup-id playerctl previous # same Fn keys as MBP
|
||||
|
||||
# Screenshot
|
||||
bindsym $mod+s exec zsh -i -c snipit
|
||||
bindsym Ctrl+Print exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
|
||||
# TODO: debug
|
||||
bindsym $mod+Print exec scrot --focused ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
|
||||
bindsym $mod+Shift+3 exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
|
||||
# TODO: debug
|
||||
bindsym $mod+Shift+4 exec scrot --select ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
|
||||
# Integration with Google's screenshot hosting server
|
||||
|
||||
# online documentation
|
||||
bindsym $mod+Shift+slash exec google-chrome https://i3wm.org/docs/userguide.html
|
||||
|
@ -101,7 +111,7 @@ for_window [class="^.*"] border pixel 2
|
|||
focus_follows_mouse no
|
||||
|
||||
# kill focused window
|
||||
bindsym $mod+q exec ~/.config/i3/i3-and-emacs quit
|
||||
bindsym $mod+q kill
|
||||
|
||||
# GTK Themes
|
||||
exec --no-startup-id gnome-settings-daemon
|
||||
|
@ -117,10 +127,10 @@ bindsym $mod+Shift+q exec "/usr/share/goobuntu-desktop-files/xsecurelock.sh"
|
|||
exec --no-startup-id gnome-sound-applet
|
||||
|
||||
# change focus
|
||||
bindsym $mod+h exec ~/.config/i3/i3-and-emacs left
|
||||
bindsym $mod+j exec ~/.config/i3/i3-and-emacs down
|
||||
bindsym $mod+k exec ~/.config/i3/i3-and-emacs up
|
||||
bindsym $mod+l exec ~/.config/i3/i3-and-emacs right
|
||||
bindsym $mod+h focus left
|
||||
bindsym $mod+j focus down
|
||||
bindsym $mod+k focus up
|
||||
bindsym $mod+l focus right
|
||||
|
||||
# move focused window
|
||||
bindsym $mod+Shift+h move left 100
|
||||
|
@ -136,9 +146,9 @@ bindsym $mod+Shift+l move right 100
|
|||
bindsym $mod+z fullscreen toggle
|
||||
|
||||
# change container layout (stacked, tabbed, toggle split)
|
||||
bindsym $mod+s layout stacking
|
||||
bindsym $mod+t layout tabbed
|
||||
bindsym $mod+e layout toggle split
|
||||
bindsym $super+e layout toggle split
|
||||
bindsym $super+s layout stacking
|
||||
bindsym $super+t layout tabbed
|
||||
|
||||
# toggle tiling / floating
|
||||
bindsym $mod+Shift+f floating toggle
|
||||
|
@ -189,8 +199,22 @@ bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8
|
|||
bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9
|
||||
bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10
|
||||
|
||||
# reload the configuration file
|
||||
bindsym $mod+Shift+c reload
|
||||
# move focused container to workspace
|
||||
bindsym $mod+Ctrl+1 move container to workspace $ws1
|
||||
bindsym $mod+Ctrl+2 move container to workspace $ws2
|
||||
bindsym $mod+Ctrl+3 move container to workspace $ws3
|
||||
bindsym $mod+Ctrl+4 move container to workspace $ws4
|
||||
bindsym $mod+Ctrl+5 move container to workspace $ws5
|
||||
bindsym $mod+Ctrl+6 move container to workspace $ws6
|
||||
bindsym $mod+Ctrl+7 move container to workspace $ws7
|
||||
bindsym $mod+Ctrl+8 move container to workspace $ws8
|
||||
bindsym $mod+Ctrl+9 move container to workspace $ws9
|
||||
bindsym $mod+Ctrl+0 move container to workspace $ws10
|
||||
|
||||
# reload, restart i3
|
||||
bindsym $super+r reload
|
||||
bindsym $super+Shift+r restart
|
||||
|
||||
|
||||
# resize window (you can also use the mouse for that)
|
||||
mode "resize" {
|
||||
|
@ -203,11 +227,15 @@ mode "resize" {
|
|||
bindsym $mod+Shift+r mode "default"
|
||||
}
|
||||
bindsym $mod+Shift+r mode "resize"
|
||||
# NOTE: this eclipses the restart kbd, so rebind that to something useful
|
||||
bindsym $mod+r restart
|
||||
|
||||
# passthrough mode to support Emacs, Tmux, Vim KBDs for window and pane management
|
||||
mode "passthrough" {
|
||||
bindsym $mod+Escape mode "default"
|
||||
}
|
||||
bindsym $mod+Escape mode "passthrough"
|
||||
|
||||
# Colors
|
||||
set $foreground #8cffa9
|
||||
set $foreground #61afef
|
||||
set $background #dfdfdf
|
||||
|
||||
# window borders
|
113
configs/shared/misc/.config/i3/dmenu_timer.sh
Executable file
113
configs/shared/misc/.config/i3/dmenu_timer.sh
Executable file
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Select common timer intervals with dmenu and play an alarm sound when
|
||||
# finished. Useful if you bind a KBD in a window manager such as i3. Pass the
|
||||
# path to the alarm mp3 as the only argument.
|
||||
#
|
||||
# Usage: ./dmenu_timer.sh path/to/alarm.mp3
|
||||
|
||||
times=$(cat <<EOF
|
||||
1 minute
|
||||
2 minutes
|
||||
3 minutes
|
||||
4 minutes
|
||||
5 minutes
|
||||
10 minutes
|
||||
15 minutes
|
||||
20 minutes
|
||||
30 minutes
|
||||
45 minutes
|
||||
1 hour
|
||||
2 hours
|
||||
EOF
|
||||
)
|
||||
selection=$(echo "$times" | dmenu)
|
||||
|
||||
case $selection in
|
||||
'1 minute')
|
||||
notify-send 'Timer' 'Set for 1 minute' && \
|
||||
sleep 1m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'2 minutes')
|
||||
notify-send 'Timer' 'Set for 2 minute' && \
|
||||
sleep 2m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'3 minutes')
|
||||
notify-send 'Timer' 'Set for 3 minutes' && \
|
||||
sleep 3m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'4 minutes')
|
||||
notify-send 'Timer' 'Set for 4 minutes' && \
|
||||
sleep 4m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'5 minutes')
|
||||
notify-send 'Timer' 'Set for 5 minutes' && \
|
||||
sleep 5m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'10 minutes')
|
||||
notify-send 'Timer' 'Set for 10 minutes' && \
|
||||
sleep 10m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'15 minutes')
|
||||
notify-send 'Timer' 'Set for 15 minutes' && \
|
||||
sleep 15m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'20 minutes')
|
||||
notify-send 'Timer' 'Set for 20 minutes' && \
|
||||
sleep 20m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'30 minutes')
|
||||
notify-send 'Timer' 'Set for 30 minutes' && \
|
||||
sleep 30m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'45 minutes')
|
||||
notify-send 'Timer' 'Set for 45 minutes' && \
|
||||
sleep 45m && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'1 hour')
|
||||
notify-send 'Timer' 'Set for 1 hour' && \
|
||||
sleep 1h && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
'2 hours')
|
||||
notify-send 'Timer' 'Set for 2 hours' && \
|
||||
sleep 2h && \
|
||||
notify-send 'Timer' 'Finished.' && \
|
||||
mpg123 $1 && \
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
notify-send 'Timer' 'No supported time selected. Exiting...' && exit 1
|
||||
esac
|
25
configs/shared/misc/.config/i3/passmenu
Executable file
25
configs/shared/misc/.config/i3/passmenu
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
shopt -s nullglob globstar
|
||||
|
||||
typeit=0
|
||||
if [[ $1 == "--type" ]]; then
|
||||
typeit=1
|
||||
shift
|
||||
fi
|
||||
|
||||
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
||||
password_files=( "$prefix"/**/*.gpg )
|
||||
password_files=( "${password_files[@]#"$prefix"/}" )
|
||||
password_files=( "${password_files[@]%.gpg}" )
|
||||
|
||||
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
|
||||
|
||||
[[ -n $password ]] || exit
|
||||
|
||||
if [[ $typeit -eq 0 ]]; then
|
||||
pass show -c "$password" 2>/dev/null
|
||||
else
|
||||
pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
|
||||
xdotool type --clearmodifiers --file -
|
||||
fi
|
76
configs/shared/misc/.config/i3/workspace_1.json
Normal file
76
configs/shared/misc/.config/i3/workspace_1.json
Normal file
|
@ -0,0 +1,76 @@
|
|||
// vim:ts=4:sw=4:et
|
||||
{
|
||||
// splitv split container with 2 children
|
||||
"border": "normal",
|
||||
"floating": "auto_off",
|
||||
"layout": "splitv",
|
||||
"percent": 0.5,
|
||||
"type": "con",
|
||||
"nodes": [
|
||||
{
|
||||
"border": "pixel",
|
||||
"current_border_width": 3,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 925,
|
||||
"width": 1072,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"name": "emacs@wpcarro.lon.corp.google.com",
|
||||
"percent": 0.5,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^GoogleEmacs$",
|
||||
"instance": "^emacs$",
|
||||
"title": "^google-emacs$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
},
|
||||
{
|
||||
"border": "pixel",
|
||||
"current_border_width": 3,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 484,
|
||||
"width": 724,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"name": "i3-save-tree",
|
||||
"percent": 0.5,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^st\\-256color$",
|
||||
"instance": "^st\\-256color$",
|
||||
"title": "^st-term$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
"border": "pixel",
|
||||
"current_border_width": 3,
|
||||
"floating": "auto_off",
|
||||
"geometry": {
|
||||
"height": 2125,
|
||||
"width": 1914,
|
||||
"x": 1923,
|
||||
"y": 32
|
||||
},
|
||||
"name": "i3: Layout saving in i3 - Google Chrome",
|
||||
"percent": 0.5,
|
||||
"swallows": [
|
||||
{
|
||||
"class": "^Google\\-chrome$",
|
||||
"instance": "^google\\-chrome$",
|
||||
"title": "Chrome",
|
||||
"window_role": "^browser$"
|
||||
}
|
||||
],
|
||||
"type": "con"
|
||||
}
|
1
configs/shared/misc/.config/lf/lfrc
Normal file
1
configs/shared/misc/.config/lf/lfrc
Normal file
|
@ -0,0 +1 @@
|
|||
map D delete
|
|
@ -375,9 +375,6 @@ let g:airline_theme = 'hybrid'
|
|||
let g:swoopHighlight = ["hi! link SwoopBufferLineHi Warning", "hi! link SwoopPatternHi Error"]
|
||||
|
||||
|
||||
nnoremap <M-q> :q<CR>
|
||||
|
||||
|
||||
" Jump to buffers.
|
||||
nmap <F1> :1b<CR>
|
||||
nmap <F2> :2b<CR>
|
||||
|
@ -525,6 +522,7 @@ nnoremap <silent> <M-h> :TmuxNavigateLeft<CR>
|
|||
nnoremap <silent> <M-j> :TmuxNavigateDown<CR>
|
||||
nnoremap <silent> <M-k> :TmuxNavigateUp<CR>
|
||||
nnoremap <silent> <M-l> :TmuxNavigateRight<CR>
|
||||
nnoremap <silent> <M-q> :q<CR>
|
||||
|
||||
" make Y do what is intuitive given:
|
||||
" D: deletes until EOL
|
||||
|
|
|
@ -19,7 +19,7 @@ chatnets = {
|
|||
channels = (
|
||||
{ name = "#nixos"; chatnet = "Freenode"; autojoin = "Yes"; },
|
||||
{ name = "#i3"; chatnet = "Freenode"; autojoin = "No"; },
|
||||
{ name = "#haskell"; chatnet = "GameSurge"; autojoin = "No"; },
|
||||
{ name = "#pass"; chatnet = "Freenode"; autojoin = "No"; },
|
||||
);
|
||||
|
||||
settings = {
|
1
configs/shared/misc/.local/share/fonts/.uuid
Normal file
1
configs/shared/misc/.local/share/fonts/.uuid
Normal file
|
@ -0,0 +1 @@
|
|||
5c006ff1-cbf7-40ef-b117-5f8c46def8c9
|
BIN
configs/shared/misc/.local/share/sounds/gong.mp3
Normal file
BIN
configs/shared/misc/.local/share/sounds/gong.mp3
Normal file
Binary file not shown.
BIN
configs/shared/misc/.local/share/wallpaper/cartoon-outdoors.jpg
Normal file
BIN
configs/shared/misc/.local/share/wallpaper/cartoon-outdoors.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 502 KiB |
|
@ -1,4 +1,4 @@
|
|||
Host box
|
||||
Host desktop
|
||||
Hostname wpcarro.lon.corp.google.com
|
||||
|
||||
Host cloudtop
|
||||
|
|
7
configs/shared/misc/.unison/cloudtop
Normal file
7
configs/shared/misc/.unison/cloudtop
Normal file
|
@ -0,0 +1,7 @@
|
|||
root = /usr/local/google/home/wpcarro/cloud
|
||||
root = ssh://cloudtop//usr/local/google/home/wpcarro/cloud
|
||||
auto = true
|
||||
batch = true
|
||||
backuploc = local
|
||||
backupsuffix = ~~
|
||||
ignore = Name *~
|
1596
configs/shared/misc/bin/dropbox.py
Executable file
1596
configs/shared/misc/bin/dropbox.py
Executable file
File diff suppressed because one or more lines are too long
BIN
configs/shared/misc/bin/lf
Executable file
BIN
configs/shared/misc/bin/lf
Executable file
Binary file not shown.
22
configs/shared/shell/.profile
Normal file
22
configs/shared/shell/.profile
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Some programs read from ~/.profile for values. It's best to set environment
|
||||
# variables here instead of in ~/.zshrc or similar files, which are sourced
|
||||
# everytime a new shell is created. The ~/.profile, on the other hand, is
|
||||
# typically sourced only once at login.
|
||||
|
||||
PATH="$PATH:$HOME/bin"
|
||||
|
||||
# Application preferences
|
||||
export BROWSER=google-chrome
|
||||
export TERMINAL=st
|
||||
export EDITOR=emacsclient
|
||||
export ALTERNATE_EDITOR=nvim
|
||||
|
||||
# Application configuration
|
||||
export FZF_DEFAULT_COMMAND='fd --hidden --follow --exclude ".git"'
|
||||
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||
|
||||
export DOTFILES="$HOME/Dropbox/dotfiles"
|
||||
export ORG_DIRECTORY="$HOME/Dropbox/org"
|
||||
|
||||
# Set environment variables for Nix
|
||||
source ~/.nix-profile/etc/profile.d/nix.sh
|
|
@ -18,7 +18,6 @@ set -g @copycat_next 'p'
|
|||
set -g @copycat_prev 'n'
|
||||
set -g @plugin 'arcticicestudio/nord-tmux'
|
||||
|
||||
# set -g @plugin 'tmux-plugins/tmux-yank'
|
||||
|
||||
################################################################################
|
||||
# Context Helpers
|
||||
|
@ -39,8 +38,8 @@ is_vim_or_emacs="ps -o state= -o comm= -t '#{pane_tty}' \
|
|||
|
||||
# change tmux leader
|
||||
unbind C-b
|
||||
set -g prefix C-q
|
||||
bind C-q send-prefix
|
||||
set -g prefix C-y
|
||||
bind C-y send-prefix
|
||||
|
||||
|
||||
################################################################################
|
||||
|
@ -48,17 +47,14 @@ bind C-q send-prefix
|
|||
################################################################################
|
||||
|
||||
# COLORS!
|
||||
set -g default-terminal "screen-256color"
|
||||
set-option -sa terminal-overrides ",xterm*:Tc"
|
||||
set -g default-terminal "tmux"
|
||||
set-option -sa terminal-overrides ",*256col*:Tc"
|
||||
|
||||
|
||||
################################################################################
|
||||
# Copy Paste
|
||||
################################################################################
|
||||
|
||||
# Copy-paste integration
|
||||
set-option -g default-command "reattach-to-user-namespace -l zsh"
|
||||
|
||||
# copy text like it's Vim
|
||||
bind -n Escape if-shell "${is_vim_or_emacs}" "send-keys Escape" copy-mode
|
||||
|
||||
|
@ -67,17 +63,10 @@ setw -g mode-keys vi
|
|||
|
||||
# Setup 'v' to begin selection as in Vim
|
||||
bind -Tcopy-mode-vi v send -X begin-selection
|
||||
bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
|
||||
bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel "xclip -selection clipboard -i"
|
||||
bind -Tcopy-mode-vi Escape send -X cancel
|
||||
bind -Tcopy-mode-vi V send -X rectangle-toggle
|
||||
|
||||
# Update default binding of `Enter` to also use copy-pipe
|
||||
unbind -Tcopy-mode Enter
|
||||
bind -Tcopy-mode Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# Bind ']' to use pbpaste
|
||||
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
|
||||
|
||||
|
||||
################################################################################
|
||||
# Windows
|
||||
|
|
2
configs/shared/x_server/.Xresources
Normal file
2
configs/shared/x_server/.Xresources
Normal file
|
@ -0,0 +1,2 @@
|
|||
! value for laptop
|
||||
Xft.dpi: 200
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
source ~/.profile
|
||||
|
||||
export DESKTOP_SESSION=cinnamon # gnome for trusty.
|
||||
|
||||
# NOTE: This may break your compose key.
|
|
@ -5,8 +5,6 @@ antigen use oh-my-zsh
|
|||
|
||||
# Bundles from robbyrussell's oh-my-zsh repo.
|
||||
antigen bundle git
|
||||
antigen bundle alias-tips # friendly reminders to prefer an alias if exists
|
||||
# antigen bundle common-aliases # be careful with the load order here. Can easily eclipse aliases undesirably
|
||||
antigen bundle extract # extracts archives polymorphically
|
||||
antigen bundle zsh-completions # extracts archives polymorphically
|
||||
|
||||
|
@ -16,19 +14,20 @@ antigen bundle zsh-users/zsh-syntax-highlighting
|
|||
# Theming
|
||||
# This supports different ZSH themes for each machine
|
||||
case "$(hostname)" in
|
||||
wpcarro.c.googlers.com) antigen theme cloud;;
|
||||
wpcarro.lon.corp.google.com) antigen theme frisk;;
|
||||
*) antigen theme refined;;
|
||||
# desktop
|
||||
wpcarro.lon.corp.google.com)
|
||||
antigen theme frisk;;
|
||||
# cloudtop
|
||||
wpcarro.c.googlers.com)
|
||||
antigen theme cloud;;
|
||||
# laptop
|
||||
wpcarro.roam.googlers.com)
|
||||
antigen theme refined;;
|
||||
esac
|
||||
|
||||
# Leave this last
|
||||
antigen apply
|
||||
|
||||
# Personal Configuration
|
||||
|
||||
# Set environment variables for Nix
|
||||
source ~/.nix-profile/etc/profile.d/nix.sh
|
||||
|
||||
# Configure fzf
|
||||
source "$(fzf-share)/key-bindings.zsh"
|
||||
|
||||
|
@ -45,9 +44,7 @@ fi
|
|||
# Directories.
|
||||
zstyle ':completion:*' users root $USER
|
||||
|
||||
# use full path instead of $DOTFILES, since DOTFILES is set herein
|
||||
DOTFILES="$HOME/programming/dotfiles"
|
||||
source "$DOTFILES/configs/shared/zsh/variables.zsh"
|
||||
source "$DOTFILES/configs/shared/zsh/aliases.zsh"
|
||||
source "$DOTFILES/configs/shared/zsh/functions.zsh"
|
||||
source "$DOTFILES/configs/shared/zsh/dumping_grounds.zsh"
|
||||
source "$DOTFILES/configs/shared/zsh/zle.zsh"
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
# Applications
|
||||
# dired: di
|
||||
# docker: dk
|
||||
#
|
||||
# Supported qualifiers:
|
||||
# hidden: h
|
||||
# ignore-case: i
|
||||
#
|
||||
# Supported verbs:
|
||||
# source: s
|
||||
# install: i
|
||||
# test: t
|
||||
# build: b
|
||||
# list: ls
|
||||
|
||||
# Misc
|
||||
alias c="xclip -selection clipboard -i"
|
||||
alias p="xclip -selection clipboard -o"
|
||||
alias md="mkdir_cd"
|
||||
alias mdd="mkdir_cd"
|
||||
alias mdp='mkdir --parents'
|
||||
alias ls="exa"
|
||||
alias ll="exa -l"
|
||||
alias la="exa -la"
|
||||
|
@ -21,14 +31,21 @@ alias btctl=bluetoothctl
|
|||
alias rg='rg --ignore-case'
|
||||
alias rgh='rg --hidden' # By default, rg skips hidden files
|
||||
alias fdh='fd --hidden' # By default, rg skips hidden files
|
||||
alias define=sdcv # uses stardict to lookup a word
|
||||
|
||||
# Gnome
|
||||
alias na=nautilus # Gnome's graphical file browser. Useful to click and dragging files into emails
|
||||
|
||||
# Tmux
|
||||
alias tls='tmux list-sessions'
|
||||
|
||||
# Chrome
|
||||
alias cssh='chrome --app-id=pnhechapfaindjhompbnflcldabbghjo' # Secure Shell
|
||||
alias crd='chrome --app-id=gbchcmhmhahfdphkhkmpfmihenigjmpp' # Chrome Remote Desktop
|
||||
|
||||
# Dropbox
|
||||
alias drst='dropbox.py status'
|
||||
|
||||
# Docker
|
||||
alias dk="docker"
|
||||
alias dkps="docker ps"
|
||||
|
@ -90,7 +107,7 @@ alias hgco='hg update'
|
|||
alias sb="stack build"
|
||||
alias se="stack exec --"
|
||||
alias sc="stack clean"
|
||||
alias st="stack test"
|
||||
# alias st="stack test" # blocks suckless-terminal
|
||||
alias haddocks='open "$(stack path --local-doc-root)/index.html"'
|
||||
|
||||
# Kubernetes
|
||||
|
@ -107,6 +124,12 @@ alias nq="nix_introspect"
|
|||
alias nsh="nix-shell"
|
||||
alias nshp="nix-shell --pure"
|
||||
alias nr="nix repl"
|
||||
alias ni='nix-env --install'
|
||||
alias nrm='nix-env --uninstall'
|
||||
alias nls='nix-env --query'
|
||||
|
||||
# Aptitude (apt)
|
||||
alias apti='sudo apt-get install'
|
||||
|
||||
# couple the e* aliases to the <leader>e* kbds in vim
|
||||
alias ev='e ~/.config/nvim/init.vim'
|
||||
|
@ -117,6 +140,7 @@ alias ef='e ~/functions.zsh'
|
|||
alias el='e ~/variables.zsh'
|
||||
alias ex='e ~/.Xresources'
|
||||
alias ei='e ~/.config/i3/config'
|
||||
alias em='e ~/.tmux.conf'
|
||||
|
||||
# couple the s* aliases to the <leader>s* kbds in vim
|
||||
alias sz='source ~/.zshrc'
|
||||
|
@ -125,6 +149,7 @@ alias sf='source ~/functions.zsh'
|
|||
alias sl='source ~/variables.zsh'
|
||||
alias sx='xrdb ~/.Xresources'
|
||||
alias si='i3-msg restart'
|
||||
alias sm='tmux source-file ~/.tmux.conf'
|
||||
|
||||
# Google aliases
|
||||
# blaze: bz
|
||||
|
@ -138,5 +163,6 @@ alias br='borgcfg'
|
|||
alias pils='p4 listclients'
|
||||
alias pirm='p4 citc -d'
|
||||
alias pb=/google/src/head/depot/eng/tools/pastebin
|
||||
alias pbc='p | pb --private --title $(date +${DATE_FMT})| tee >(c && chrome $(p))' # create a private gPaste from your clipboard's content; open the result in a browser
|
||||
alias pbc='pb --private --title $(date +${date_fmt})| tee >(c && chrome $(p))' # create a private gPaste from your clipboard's content; open the result in a browser
|
||||
alias pbcp='p | pb --private --title $(date +${date_fmt})| tee >(c && chrome $(p))' # create a private gPaste from your clipboard's content; open the result in a browser
|
||||
alias pbls='$BROWSER https://paste.googleplex.com/$(whoami)'
|
||||
|
|
|
@ -1,433 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# Docker
|
||||
dsh() {
|
||||
# Drop into a Docker shell. Shell defaults to /bin/bash.
|
||||
container=$1
|
||||
cmd=${2-/bin/bash}
|
||||
|
||||
docker exec -it "${container}" "${cmd}"
|
||||
}
|
||||
|
||||
# Emacs
|
||||
dired() {
|
||||
# Opens either the `$(pwd)` or `$1` in Emacs's `dired`.
|
||||
# Uses i3 to focus Emacs.
|
||||
directory=${1:-$(pwd)}
|
||||
echo $directory
|
||||
emacsclient --eval "(dired \"$directory\")" && focus Emacs
|
||||
}
|
||||
|
||||
org_capture() {
|
||||
# Spawns an Emacs frame running org-capture.
|
||||
echo called
|
||||
emacsclient --create-frame \
|
||||
--frame-parameters '(quote (name . "org-protocol-capture"))' \
|
||||
--eval '(org-capture)'
|
||||
}
|
||||
|
||||
# Git
|
||||
conflicts() {
|
||||
# Edit git conflicts one-by-one in your favorite editor.
|
||||
${EDITOR} "$(git status --porcelain | awk '/^UU/ { print $2 }')"
|
||||
}
|
||||
|
||||
# GPG
|
||||
gpg_encrypt() {
|
||||
# Convenience function around encryping files and directories.
|
||||
# Appends a .gpg extension and deletes the unencrypted source.
|
||||
local file=${1}
|
||||
|
||||
echo "Encrypting..."
|
||||
|
||||
if [ -f "${file}" ]; then
|
||||
gpg --symmetric "${file}" && \
|
||||
rm "${file}"
|
||||
|
||||
elif [ -d "${file}" ]; then
|
||||
tar -cz "${file}" | gpg --symmetric --output "${file}.tar.gz.gpg"
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
gpg_decrypt() {
|
||||
# Convenience function around decrypting .gpg files and directories.
|
||||
# Deletes the original encrypted file with the .gpg extension.
|
||||
local file=$1
|
||||
|
||||
echo "Decrypting..."
|
||||
|
||||
if [ -f "${file}" ]; then
|
||||
gpg --decrypt "${file}" >"${file%.gpg}" && \
|
||||
rm "${file}"
|
||||
|
||||
elif [ -d "${file}" ]; then
|
||||
local outdir="${dirname%.tar.gz.gpg}"
|
||||
|
||||
if [ -d "${outdir}" ]; then
|
||||
echo "Output directory, ${outdir}, already exists and will be overwritten by this command. Aborting..."
|
||||
return 1
|
||||
else
|
||||
gpg --decrypt "${dirname}" | tar -xv
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
# Python
|
||||
python_sandbox() {
|
||||
# Creates a nix-shell with the specified arguments as Python packages
|
||||
nix-shell -p "python36.withPackages(p: with p; [$@])"
|
||||
}
|
||||
|
||||
# Haskell
|
||||
cabal_unhell() {
|
||||
# Run this function to save yourself from Cabal hell.
|
||||
# Note: this will require that you reinstall packages for your projects again.
|
||||
find ~/.ghc -maxdepth 1 -type d -exec rm -rf {} \;
|
||||
rm -rf ~/.cabal/{lib,packages,share}
|
||||
}
|
||||
|
||||
haskell_sandbox() {
|
||||
# Creates a nix-shell with the specified arguments as Haskell packages
|
||||
nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [$@])"
|
||||
}
|
||||
|
||||
_haskell_test_watch_path() {
|
||||
# Runs and watches the tests for a provided file path.
|
||||
ghcid -c "stack ghci grid:lib grid:grid-test --ghci-options=-fobject-code" \
|
||||
--height="$(tput lines)" --width="$(tput cols)" --warnings --test "$1"
|
||||
}
|
||||
|
||||
_haskell_test_watch_pattern() {
|
||||
# Runs and watches the tests that match a provided pattern.
|
||||
stack test --file-watch grid:grid-test --ta "-p \"${1}\""
|
||||
}
|
||||
|
||||
haskell_test_watch() {
|
||||
# Accepts either a filepath or a pattern and runs a test-watcher for either.
|
||||
if [ -f "$1" ]; then
|
||||
_haskell_test_watch_path "$1"
|
||||
else
|
||||
_haskell_test_watch_pattern "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Kubernetes
|
||||
kush() {
|
||||
# Drop into a shell via Kubernetes. Shell defaults to /bin/bash.
|
||||
local name=$1
|
||||
local cmd=${2-/bin/bash}
|
||||
|
||||
kubectl exec -it "${name}" -- "${cmd}"
|
||||
}
|
||||
|
||||
# Misc
|
||||
all_users() {
|
||||
# Lists all of the known users in the Linux system
|
||||
# Useful because when you type `~art` in a prompt and tab-complete, ZSH looks
|
||||
# up all users whose names start with "art". It's also just interesting to
|
||||
# have access to this information.
|
||||
#
|
||||
# NOTE: this is not as simple as `cat /etc/passwd` for reasons of which I'm
|
||||
# not entirely sure.
|
||||
getent passwd
|
||||
}
|
||||
|
||||
test_true_color() {
|
||||
# Run this to test if your terminal emulator supports True Color
|
||||
curl --silent https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash
|
||||
}
|
||||
|
||||
path() {
|
||||
# Pretty-print the $PATH variable
|
||||
echo "$PATH" | tr : '\n'
|
||||
}
|
||||
|
||||
nix_installed() {
|
||||
# Lists the packages installed with `nix-env`
|
||||
nix-env -q
|
||||
}
|
||||
|
||||
nix_store() {
|
||||
# Print the packages in /nix/store without the preceding hash
|
||||
ls /nix/store | sed 's/[a-z0-9]*-//'
|
||||
}
|
||||
|
||||
browse() {
|
||||
# Open a URL in $BROWSER. Friendly for terminal input and output.
|
||||
nohup "$BROWSER" $@ &
|
||||
}
|
||||
|
||||
lh() {
|
||||
# Opens http://localhost:<port> in your $BROWSER.
|
||||
# Usage: `lh 8080`
|
||||
# Here, in case it wasn't obvious, `lh` stands for "localhost".
|
||||
browse "http://localhost:$1"
|
||||
}
|
||||
|
||||
essids() {
|
||||
# Returns a list of all ESSIDs the network card detects
|
||||
local interface=${1-wlp4s0}
|
||||
sudo iwlist "${interface}" scan | awk -F \" '{print $2}' | sed '/^\s*$/d'
|
||||
}
|
||||
|
||||
mkdir_cd() {
|
||||
# Make and cd into a directory or path
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
swap() {
|
||||
# Swaps the names of files and directories.
|
||||
local file_a="${1}"
|
||||
local file_b="${2}"
|
||||
|
||||
if [ -d "${file_a}" ] && [ -d "${file_b}" ]; then
|
||||
local backup=$(mktemp -d backup.XXX)
|
||||
|
||||
mv "${file_a}" "${backup}"
|
||||
mv "${file_b}" "${file_a}"
|
||||
mv "${backup}/${file_a}" "${file_b}"
|
||||
rm -rf "${backup}"
|
||||
elif [ -f "${file_a}" ] && [ -f "${file_b}" ]; then
|
||||
local backup=$(mktemp backup.XXX)
|
||||
|
||||
mv "${file_a}" "${backup}"
|
||||
mv "${file_b}" "${file_a}"
|
||||
mv "${backup}" "${file_b}"
|
||||
rm "${backup}"
|
||||
fi
|
||||
|
||||
echo "Swapped: ${file_a} <-> ${file_b}"
|
||||
}
|
||||
|
||||
bak() {
|
||||
# Backup a file or a directory by appending a .bak extension to it.
|
||||
mv "$1" "$1.bak"
|
||||
}
|
||||
|
||||
unbak() {
|
||||
# Restore a file by removing the .bak extension from it.
|
||||
mv "$1.bak" "$1"
|
||||
}
|
||||
|
||||
is_online() {
|
||||
# Pings google.com and echos "Online" or "Offline" and returns the appropriate
|
||||
# exit code. Could be useful in the ${PS1} variable.
|
||||
wget -q --spider "http://google.com"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Online"
|
||||
return 0
|
||||
else
|
||||
echo "Offline"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
du_it_live() {
|
||||
# Outputs and refreshes the size of a directory's content.
|
||||
# Useful for watching a directory as large amounts of data are
|
||||
# downloaded into it.
|
||||
local directory="${1}"
|
||||
|
||||
while true; do
|
||||
du -hc "${directory}" | tail -n 1 | tr -d '\n' && echo -n ' ' && sleep 0.5
|
||||
|
||||
# elipsis
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
|
||||
# clear the three-dots
|
||||
echo -n '\b\b\b' && echo -n ' ' && echo -n '\r'
|
||||
done
|
||||
}
|
||||
|
||||
router() {
|
||||
# Returns the IP address of the network's router.
|
||||
# Useful in a call like `ping $(router)` to diagnose an internet problem.
|
||||
netstat -nr | grep default | head -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
monitor_dimensions() {
|
||||
# Outputs the dimensions of your computer monitor
|
||||
xdpyinfo | awk '/dimensions/{ print $2 }'
|
||||
}
|
||||
|
||||
list_sinks() {
|
||||
# Lists the available output sources (speakers?)
|
||||
pacmd list-sinks | grep -e 'name:' -e 'index:'
|
||||
}
|
||||
|
||||
list_sources() {
|
||||
# List available input sources (microphones?)
|
||||
pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
|
||||
}
|
||||
|
||||
lt() {
|
||||
# Convenience wrapper around `exa --tree`.
|
||||
# Optionally accepts a number for the max-depth and a directory to list.
|
||||
# $ lt 2 ./scripts
|
||||
|
||||
# lt
|
||||
if [ -z ${1} ]; then
|
||||
exa --tree --all
|
||||
|
||||
# lt 2
|
||||
elif [[ "${1}" =~ '^[0-9]+$' ]] && [ -z ${2} ]; then
|
||||
local depth="${1}"
|
||||
|
||||
exa --tree -all --level "${depth}"
|
||||
|
||||
# lt ./scripts
|
||||
elif [ -z ${2} ]; then
|
||||
local directory="${1}"
|
||||
|
||||
exa --tree --all "${directory}"
|
||||
|
||||
# lt 2 ./scripts
|
||||
else
|
||||
local depth=${1}
|
||||
local directory="${2}"
|
||||
|
||||
exa --tree --all --level ${depth} "${directory}"
|
||||
fi
|
||||
}
|
||||
|
||||
gql() {
|
||||
# Convenience wrapper around `http POST` that allows you write GQL queries in
|
||||
# Vim before posting them to the server.
|
||||
local endpoint="${1}"
|
||||
local query="/tmp/http-query.gql"
|
||||
|
||||
vim "${query}" && \
|
||||
echo "{\"query\":\"$(cat ${query})\"}" | \
|
||||
http --body POST "${endpoint}"
|
||||
}
|
||||
|
||||
# Nix
|
||||
nix_introspect() {
|
||||
# Greps through my local nixpkgs repo for
|
||||
rg --after-context 5 "\\b$1\\b\\s*=" "$(nix-instantiate --find-file nixpkgs)"
|
||||
}
|
||||
|
||||
# Tmux
|
||||
t() {
|
||||
# Find or create a Tmux session.
|
||||
local session_name="${1}"
|
||||
if ! tmux has-session -t "${session_name}" 2> /dev/null; then
|
||||
local oldTMUX="${TMUX}"
|
||||
unset TMUX
|
||||
tmux new -d -s "${session_name}" -n "${session_name}"
|
||||
export TMUX="${oldTMUX}"
|
||||
unset oldTMUX
|
||||
|
||||
if command -v j >/dev/null; then
|
||||
tmux send-keys -t "${session_name}" "j ${session_name}; clear" "C-m"
|
||||
else
|
||||
tmux send-keys -t "${session_name}"
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${TMUX}" ]]; then
|
||||
tmux switch-client -t "${session_name}"
|
||||
else
|
||||
tmux attach -t "${session_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
tk() {
|
||||
# `tk`: "tmux kill". Kills a tmux session by name.
|
||||
# If no arguments are provided, kills the current session after jumping to the previous session.
|
||||
session_name="${1}"
|
||||
if [ ! -z "${session_name}" ]; then
|
||||
tmux kill-session -t "${session_name}"
|
||||
else
|
||||
session_name=tmux ls -f '#{?session_attached,#{session_name},}' | xargs
|
||||
tmux switch-client -l
|
||||
tmux kill-session -t "${session_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
tmux_is_running() {
|
||||
# Returns zero if tmux is running
|
||||
# Although this is a simple function body, it's useful to encode esoteric
|
||||
# knowledge that I will easily forget.
|
||||
test -n "$TMUX"
|
||||
}
|
||||
|
||||
tmux_focused_pane() {
|
||||
# Returns the ID of the focused tmux pane.
|
||||
# WIP
|
||||
# tmux list-panes -F '#{pane_active} #{pane_tty}' | awk /1/{ print $1 }
|
||||
echo 'Not implemented'
|
||||
}
|
||||
|
||||
# Google3
|
||||
g3_root() {
|
||||
# Outputs the root of the CitC client in g3
|
||||
# NOTE: there is probably a function already supported by g4 to cd to the
|
||||
# root, so support for this function may be dropped shortly.
|
||||
echo "${PWD%%/google3/*}/google3"
|
||||
}
|
||||
|
||||
# i3
|
||||
focus() {
|
||||
# Focuses an i3 window by application name.
|
||||
i3-msg "[class=\"$1\"] focus" >/dev/null
|
||||
}
|
||||
|
||||
# zsh
|
||||
fns() {
|
||||
# Outputs all available functions.
|
||||
# `fns` was chosen instead of `functions`, since `functions` was already
|
||||
# taken.
|
||||
compgen -A function
|
||||
}
|
||||
|
||||
aliases() {
|
||||
# Outputs all available aliases.
|
||||
compgen -a
|
||||
}
|
||||
|
||||
keywords() {
|
||||
# Outputs all of the shell's reserved keywords.
|
||||
compgen -k
|
||||
}
|
||||
|
||||
builtins() {
|
||||
# Outputs all of the shell's builtin commands.
|
||||
compgen -b
|
||||
}
|
||||
|
||||
zle_insert_subshell() {
|
||||
LBUFFER+='$(' ; RBUFFER=")$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_subshell
|
||||
bindkey '^j' zle_insert_subshell
|
||||
|
||||
zle_insert_variable() {
|
||||
LBUFFER+='${' ; RBUFFER="}$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_variable
|
||||
bindkey '^v' zle_insert_variable
|
||||
|
||||
zle_insert_2x_dash() {
|
||||
LBUFFER+=' --'
|
||||
}
|
||||
zle -N zle_insert_2x_dash
|
||||
bindkey '^[^f' zle_insert_2x_dash
|
||||
|
||||
zle_insert_2x_quote() {
|
||||
LBUFFER+=' "' ; RBUFFER="\"$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_2x_quote
|
||||
bindkey '^["' zle_insert_2x_quote
|
||||
|
||||
zle_insert_quote() {
|
||||
LBUFFER+=" '" ; RBUFFER="'$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_quote
|
||||
bindkey "^['" zle_insert_quote
|
|
@ -1,14 +1,3 @@
|
|||
# From Google's ZSH Hacks
|
||||
# NOTE: this file has since been modified by me.
|
||||
|
||||
# Improvement to fasd's existing `zz` alias
|
||||
unalias zz
|
||||
zz() {
|
||||
# TODO: Add documentation
|
||||
local dir
|
||||
dir="$(fasd -Rdl "$1" | fzf --query="$1" -1 -0 --no-sort +m)" && cd "${dir}" || return 1
|
||||
}
|
||||
|
||||
fv() {
|
||||
# Usage: fv file pattern
|
||||
# This is useful when you know the fuzzy name of the file you want to edit
|
||||
|
@ -35,3 +24,540 @@ tj() {
|
|||
cd "${PWD/\/google3\/java//google3/javatests}"
|
||||
fi
|
||||
}
|
||||
|
||||
snipit() {
|
||||
# Take a screenshot and host it at https://screenshot.googleplex.com
|
||||
# Adapted from SnipIt to fit my workflow.
|
||||
server="https://screenshot.googleplex.com/upload"
|
||||
file="${TEMP:-/tmp}/snipit_temp_$$.png"
|
||||
|
||||
# Capture
|
||||
echo "SnipIt - Click a window, or drag to snip a region (Ctrl+C to cancel):" && \
|
||||
import "$file" && \
|
||||
echo "Sending image to server..." && \
|
||||
uri=$(curl -sF "imagedata=@$file" $server) && \
|
||||
c <<<"$uri" && \
|
||||
echo "Copied \"$uri\" to your clipboard."
|
||||
}
|
||||
|
||||
# Aptitude
|
||||
apts() {
|
||||
# Searches aptitude package repository for $1, surrounding it in ^$ to ensure
|
||||
# fewer results.
|
||||
apt search "^$1$"
|
||||
}
|
||||
|
||||
# Docker
|
||||
dsh() {
|
||||
# Drop into a Docker shell. Shell defaults to /bin/bash.
|
||||
container=$1
|
||||
cmd=${2-/bin/bash}
|
||||
|
||||
docker exec -it "${container}" "${cmd}"
|
||||
}
|
||||
|
||||
# Emacs
|
||||
dired() {
|
||||
# Opens either the `$(pwd)` or `$1` in Emacs's `dired`.
|
||||
# Uses i3 to focus Emacs.
|
||||
directory=${1:-$(pwd)}
|
||||
echo $directory
|
||||
emacsclient --eval "(dired \"$directory\")" && focus Emacs
|
||||
}
|
||||
|
||||
org_capture() {
|
||||
# Spawns an Emacs frame running org-capture.
|
||||
echo called
|
||||
emacsclient --create-frame \
|
||||
--frame-parameters '(quote (name . "org-protocol-capture"))' \
|
||||
--eval '(org-capture)'
|
||||
}
|
||||
|
||||
# Git
|
||||
conflicts() {
|
||||
# Edit git conflicts one-by-one in your favorite editor.
|
||||
${EDITOR} "$(git status --porcelain | awk '/^UU/ { print $2 }')"
|
||||
}
|
||||
|
||||
# GPG
|
||||
gpg_encrypt() {
|
||||
# Convenience function around encryping files and directories.
|
||||
# Appends a .gpg extension and deletes the unencrypted source.
|
||||
local file=${1}
|
||||
|
||||
echo "Encrypting..."
|
||||
|
||||
if [ -f "${file}" ]; then
|
||||
gpg --symmetric "${file}" && \
|
||||
rm "${file}"
|
||||
|
||||
elif [ -d "${file}" ]; then
|
||||
tar -cz "${file}" | gpg --symmetric --output "${file}.tar.gz.gpg"
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
gpg_decrypt() {
|
||||
# Convenience function around decrypting .gpg files and directories.
|
||||
# Deletes the original encrypted file with the .gpg extension.
|
||||
local file=$1
|
||||
|
||||
echo "Decrypting..."
|
||||
|
||||
if [ -f "${file}" ]; then
|
||||
gpg --decrypt "${file}" >"${file%.gpg}" && \
|
||||
rm "${file}"
|
||||
|
||||
elif [ -d "${file}" ]; then
|
||||
local outdir="${dirname%.tar.gz.gpg}"
|
||||
|
||||
if [ -d "${outdir}" ]; then
|
||||
echo "Output directory, ${outdir}, already exists and will be overwritten by this command. Aborting..."
|
||||
return 1
|
||||
else
|
||||
gpg --decrypt "${dirname}" | tar -xv
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
# Python
|
||||
python_sandbox() {
|
||||
# Creates a nix-shell with the specified arguments as Python packages
|
||||
nix-shell -p "python36.withPackages(p: with p; [$@])"
|
||||
}
|
||||
|
||||
# Haskell
|
||||
cabal_unhell() {
|
||||
# Run this function to save yourself from Cabal hell.
|
||||
# Note: this will require that you reinstall packages for your projects again.
|
||||
find ~/.ghc -maxdepth 1 -type d -exec rm -rf {} \;
|
||||
rm -rf ~/.cabal/{lib,packages,share}
|
||||
}
|
||||
|
||||
haskell_sandbox() {
|
||||
# Creates a nix-shell with the specified arguments as Haskell packages
|
||||
nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [$@])"
|
||||
}
|
||||
|
||||
_haskell_test_watch_path() {
|
||||
# Runs and watches the tests for a provided file path.
|
||||
ghcid -c "stack ghci grid:lib grid:grid-test --ghci-options=-fobject-code" \
|
||||
--height="$(tput lines)" --width="$(tput cols)" --warnings --test "$1"
|
||||
}
|
||||
|
||||
_haskell_test_watch_pattern() {
|
||||
# Runs and watches the tests that match a provided pattern.
|
||||
stack test --file-watch grid:grid-test --ta "-p \"${1}\""
|
||||
}
|
||||
|
||||
haskell_test_watch() {
|
||||
# Accepts either a filepath or a pattern and runs a test-watcher for either.
|
||||
if [ -f "$1" ]; then
|
||||
_haskell_test_watch_path "$1"
|
||||
else
|
||||
_haskell_test_watch_pattern "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Kubernetes
|
||||
kush() {
|
||||
# Drop into a shell via Kubernetes. Shell defaults to /bin/bash.
|
||||
local name=$1
|
||||
local cmd=${2-/bin/bash}
|
||||
|
||||
kubectl exec -it "${name}" -- "${cmd}"
|
||||
}
|
||||
|
||||
# Misc
|
||||
tldr_docs() {
|
||||
# Helper function for submitting a new page to `tldr`.
|
||||
# Usage: tldr_docs <cmd-name>
|
||||
pushd ~/programming/tldr && \
|
||||
gcb "$1" && \
|
||||
"$EDITOR" . && \
|
||||
echo "Next steps:" && \
|
||||
echo "- commit changes" && \
|
||||
echo "- push changes" && \
|
||||
echo "- submit a pull-request to tldr" && \
|
||||
popd # return to the original directory
|
||||
}
|
||||
|
||||
ord_to_char() {
|
||||
# Converts the ordinal, ASCII value of a character into its encoded
|
||||
# representation.
|
||||
#
|
||||
# Usage:
|
||||
# $ ord_to_char 65
|
||||
# A
|
||||
[ "$1" -lt 256 ] || return 1
|
||||
printf "\\$(printf '%03o' "$1")\n"
|
||||
}
|
||||
|
||||
char_to_ord() {
|
||||
# Converts the ASCII representation of a character to its ordinal value.
|
||||
#
|
||||
# Usage:
|
||||
# $ char_to_ord A
|
||||
# 65
|
||||
LC_CTYPE=C printf '%d\n' "'$1"
|
||||
}
|
||||
|
||||
all_users() {
|
||||
# Lists all of the known users in the Linux system
|
||||
# Useful because when you type `~art` in a prompt and tab-complete, ZSH looks
|
||||
# up all users whose names start with "art". It's also just interesting to
|
||||
# have access to this information.
|
||||
#
|
||||
# NOTE: this is not as simple as `cat /etc/passwd` for reasons of which I'm
|
||||
# not entirely sure.
|
||||
getent passwd
|
||||
}
|
||||
|
||||
escape_sequences() {
|
||||
# Outputs a table of terminal escape sequences and their meaning.
|
||||
echo -E '\a Bell (alert)'
|
||||
echo -E '\b Backspace'
|
||||
echo -E '\f Formfeed'
|
||||
echo -E '\n New line'
|
||||
echo -E '\r Carriage return'
|
||||
echo -E '\t Horizontal tab'
|
||||
echo -E '\v Vertical tab'
|
||||
echo -E "\' Single quotation mark"
|
||||
echo -E '\" Double quotation mark'
|
||||
echo -E '\\ Backslash'
|
||||
echo -E '\? Literal question mark'
|
||||
echo -E '\uhhhh Unicode character'
|
||||
echo -E '\Uhhhhhhhh Unicode character'
|
||||
echo -E '\xhh ASCII character in hexadecimal notation'
|
||||
echo -E '\xhhhh Unicode character in hexadecimal notation if this escape sequence is used in a wide-character constant or a Unicode string literal.'
|
||||
}
|
||||
|
||||
test_true_color() {
|
||||
# Run this to test if your terminal emulator supports True Color
|
||||
curl --silent https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash
|
||||
}
|
||||
|
||||
test_16_colors() {
|
||||
# Useful for testing your terminal's theme.
|
||||
echo -e "Normal: ${black}black${red}red${green}green${yellow}yellow${blue}blue${magenta}magenta${cyan}cyan${white}white"
|
||||
echo -e "Bright: ${bright_black}black${bright_red}red${bright_green}green${bright_yellow}yellow${bright_blue}blue${bright_magenta}magenta${bright_cyan}cyan${bright_white}white"
|
||||
}
|
||||
|
||||
test_text_formatting() {
|
||||
# Useful when appraising a Tmux. Things can get strange with true colors and
|
||||
# font rendering.
|
||||
echo -e "\e[1mbold\e[0m"
|
||||
echo -e "\e[3mitalic\e[0m"
|
||||
echo -e "\e[4munderline\e[0m"
|
||||
echo -e "\e[9mstrikethrough\e[0m"
|
||||
}
|
||||
|
||||
test_unicode() {
|
||||
# Run this to test if your terminal supports unicode character rendering.
|
||||
echo -e '\u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u260A'
|
||||
echo -e '\u260B \u260C \u260D \u260E \u260F \u2610 \u2611 \u2612 \u2613 \u2614 \u2615'
|
||||
echo -e '\u2616 \u2617 \u2618 \u2619 \u261A \u261B \u261C \u261D \u261E \u261F \u2620'
|
||||
echo -e '\u2621 \u2622 \u2623 \u2624 \u2625 \u2626 \u2627 \u2628 \u2629 \u262A \u262B'
|
||||
echo -e '\u262C \u262D \u262E \u262F \u2630 \u2631 \u2632 \u2633 \u2634 \u2635 \u2636'
|
||||
echo -e '\u2637 \u2638 \u2639 \u263A \u263B \u263C \u263D \u263E \u263F \u2640 \u2641'
|
||||
echo -e '\u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649 \u264A \u264B \u264C'
|
||||
echo -e '\u264D \u264E \u264F \u2650 \u2651 \u2652 \u2653 \u2654 \u2655 \u2656 \u2657'
|
||||
echo -e '\u2658 \u2659 \u265A \u265B \u265C \u265D \u265E \u265F \u2660 \u2661 \u2662'
|
||||
echo -e '\u2663 \u2664 \u2665 \u2666 \u2667 \u2668 \u2669 \u266A \u266B \u266C \u266D'
|
||||
echo -e '\u266E \u266F \u2670 \u2671 \u2672 \u2673 \u2674 \u2675 \u2676 \u2677 \u2678'
|
||||
echo -e '\u2679 \u267A \u267B \u267C \u267D \u267E \u267F \u2680 \u2681 \u2682 \u2683'
|
||||
echo -e '\u2684 \u2685 \u2686 \u2687 \u2688 \u2689 \u268A \u268B \u268C \u268D \u268E'
|
||||
echo -e '\u268F \u2690 \u2691 \u2692 \u2693 \u2694 \u2695 \u2696 \u2697 \u2698 \u2699'
|
||||
echo -e '\u269A \u269B \u269C \u269D \u269E \u269F \u26A0 \u26A1 \u26A2 \u26A3 \u26A4'
|
||||
echo -e '\u26A5 \u26A6 \u26A7 \u26A8 \u26A9 \u26AA \u26AB \u26AC \u26AD \u26AE \u26AF'
|
||||
echo -e '\u26B0 \u26B1 \u26B2 \u26B3 \u26B4 \u26B5 \u26B6 \u26B7 \u26B8 \u26B9 \u26BA'
|
||||
echo -e '\u26BB \u26BC \u26BD \u26BE \u26BF \u26C0 \u26C1 \u26C2 \u26C3 \u26C4 \u26C5'
|
||||
echo -e '\u26C6 \u26C7 \u26C8 \u26C9 \u26CA \u26CB \u26CC \u26CD \u26CE \u26CF \u26D0'
|
||||
echo -e '\u26D1 \u26D2 \u26D3 \u26D4 \u26D5 \u26D6 \u26D7 \u26D8 \u26D9 \u26DA \u26DB'
|
||||
echo -e '\u26DC \u26DD \u26DE \u26DF \u26E0 \u26E1 \u26E2 \u26E3 \u26E4 \u26E5 \u26E6'
|
||||
echo -e '\u26E7 \u26E8 \u26E9 \u26EA \u26EB \u26EC \u26ED \u26EE \u26EF \u26F0 \u26F1'
|
||||
echo -e '\u26F2 \u26F3 \u26F4 \u26F5 \u26F6 \u26F7 \u26F8 \u26F9 \u26FA \u26FB \u26FC'
|
||||
echo -e '\u26FD \u26FE \u26FF'
|
||||
}
|
||||
|
||||
path() {
|
||||
# Pretty-print the $PATH variable
|
||||
echo "$PATH" | tr : '\n'
|
||||
}
|
||||
|
||||
nix_installed() {
|
||||
# Lists the packages installed with `nix-env`
|
||||
nix-env -q
|
||||
}
|
||||
|
||||
nix_store() {
|
||||
# Print the packages in /nix/store without the preceding hash
|
||||
ls /nix/store | sed 's/[a-z0-9]*-//'
|
||||
}
|
||||
|
||||
browse() {
|
||||
# Open a URL in $BROWSER. Friendly for terminal input and output.
|
||||
nohup "$BROWSER" $@ &
|
||||
}
|
||||
|
||||
lh() {
|
||||
# Opens http://localhost:<port> in your $BROWSER.
|
||||
# Usage: `lh 8080`
|
||||
# Here, in case it wasn't obvious, `lh` stands for "localhost".
|
||||
browse "http://localhost:$1"
|
||||
}
|
||||
|
||||
essids() {
|
||||
# Returns a list of all ESSIDs the network card detects
|
||||
local interface=${1-wlp4s0}
|
||||
sudo iwlist "${interface}" scan | awk -F \" '{print $2}' | sed '/^\s*$/d'
|
||||
}
|
||||
|
||||
mkdir_cd() {
|
||||
# Make and cd into a directory or path
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
swap() {
|
||||
# Swaps the names of files and directories.
|
||||
local file_a="${1}"
|
||||
local file_b="${2}"
|
||||
|
||||
if [ -d "${file_a}" ] && [ -d "${file_b}" ]; then
|
||||
local backup=$(mktemp -d backup.XXX)
|
||||
|
||||
mv "${file_a}" "${backup}"
|
||||
mv "${file_b}" "${file_a}"
|
||||
mv "${backup}/${file_a}" "${file_b}"
|
||||
rm -rf "${backup}"
|
||||
elif [ -f "${file_a}" ] && [ -f "${file_b}" ]; then
|
||||
local backup=$(mktemp backup.XXX)
|
||||
|
||||
mv "${file_a}" "${backup}"
|
||||
mv "${file_b}" "${file_a}"
|
||||
mv "${backup}" "${file_b}"
|
||||
rm "${backup}"
|
||||
fi
|
||||
|
||||
echo "Swapped: ${file_a} <-> ${file_b}"
|
||||
}
|
||||
|
||||
bak() {
|
||||
# Backup a file or a directory by appending a .bak extension to it.
|
||||
mv "$1" "$1.bak"
|
||||
}
|
||||
|
||||
unbak() {
|
||||
# Restore a file by removing the .bak extension from it.
|
||||
mv "$1.bak" "$1"
|
||||
}
|
||||
|
||||
is_online() {
|
||||
# Pings google.com and echos "Online" or "Offline" and returns the appropriate
|
||||
# exit code. Could be useful in the ${PS1} variable.
|
||||
wget -q --spider "http://google.com"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Online"
|
||||
return 0
|
||||
else
|
||||
echo "Offline"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
du_it_live() {
|
||||
# Outputs and refreshes the size of a directory's content.
|
||||
# Useful for watching a directory as large amounts of data are
|
||||
# downloaded into it.
|
||||
local directory="${1}"
|
||||
|
||||
while true; do
|
||||
du -hc "${directory}" | tail -n 1 | tr -d '\n' && echo -n ' ' && sleep 0.5
|
||||
|
||||
# elipsis
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
echo -n '.' && sleep 0.5 &&
|
||||
|
||||
# clear the three-dots
|
||||
echo -n '\b\b\b' && echo -n ' ' && echo -n '\r'
|
||||
done
|
||||
}
|
||||
|
||||
router() {
|
||||
# Returns the IP address of the network's router.
|
||||
# Useful in a call like `ping $(router)` to diagnose an internet problem.
|
||||
netstat -nr | grep default | head -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
monitor_dimensions() {
|
||||
# Outputs the dimensions of your computer monitor
|
||||
xdpyinfo | awk '/dimensions/{ print $2 }'
|
||||
}
|
||||
|
||||
list_sinks() {
|
||||
# Lists the available output sources (speakers?)
|
||||
pacmd list-sinks | grep -e 'name:' -e 'index:'
|
||||
}
|
||||
|
||||
list_sources() {
|
||||
# List available input sources (microphones?)
|
||||
pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
|
||||
}
|
||||
|
||||
lt() {
|
||||
# Convenience wrapper around `exa --tree`.
|
||||
# Optionally accepts a number for the max-depth and a directory to list.
|
||||
# $ lt 2 ./scripts
|
||||
|
||||
# lt
|
||||
if [ -z ${1} ]; then
|
||||
exa --tree --all
|
||||
|
||||
# lt 2
|
||||
elif [[ "${1}" =~ '^[0-9]+$' ]] && [ -z ${2} ]; then
|
||||
local depth="${1}"
|
||||
|
||||
exa --tree -all --level "${depth}"
|
||||
|
||||
# lt ./scripts
|
||||
elif [ -z ${2} ]; then
|
||||
local directory="${1}"
|
||||
|
||||
exa --tree --all "${directory}"
|
||||
|
||||
# lt 2 ./scripts
|
||||
else
|
||||
local depth=${1}
|
||||
local directory="${2}"
|
||||
|
||||
exa --tree --all --level ${depth} "${directory}"
|
||||
fi
|
||||
}
|
||||
|
||||
gql() {
|
||||
# Convenience wrapper around `http POST` that allows you write GQL queries in
|
||||
# Vim before posting them to the server.
|
||||
local endpoint="${1}"
|
||||
local query="/tmp/http-query.gql"
|
||||
|
||||
vim "${query}" && \
|
||||
echo "{\"query\":\"$(cat ${query})\"}" | \
|
||||
http --body POST "${endpoint}"
|
||||
}
|
||||
|
||||
# Nix
|
||||
nix_introspect() {
|
||||
# Greps through my local nixpkgs repo for
|
||||
rg --after-context 5 "\\b$1\\b\\s*=" "$(nix-instantiate --find-file nixpkgs)"
|
||||
}
|
||||
|
||||
# Tmux
|
||||
t() {
|
||||
# Find or create a Tmux session.
|
||||
local session_name="${1}"
|
||||
if ! tmux has-session -t "${session_name}" 2> /dev/null; then
|
||||
local oldTMUX="${TMUX}"
|
||||
unset TMUX
|
||||
tmux new -d -s "${session_name}" -n "${session_name}"
|
||||
export TMUX="${oldTMUX}"
|
||||
unset oldTMUX
|
||||
|
||||
if command -v j >/dev/null; then
|
||||
tmux send-keys -t "${session_name}" "j ${session_name}; clear" "C-m"
|
||||
else
|
||||
tmux send-keys -t "${session_name}"
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${TMUX}" ]]; then
|
||||
tmux switch-client -t "${session_name}"
|
||||
else
|
||||
tmux attach -t "${session_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
tk() {
|
||||
# `tk`: "tmux kill". Kills a tmux session by name.
|
||||
# If no arguments are provided, kills the current session after jumping to the previous session.
|
||||
session_name="${1}"
|
||||
if [ ! -z "${session_name}" ]; then
|
||||
tmux kill-session -t "${session_name}"
|
||||
else
|
||||
session_name=tmux ls -f '#{?session_attached,#{session_name},}' | xargs
|
||||
tmux switch-client -l
|
||||
tmux kill-session -t "${session_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
tmux_is_running() {
|
||||
# Returns zero if tmux is running
|
||||
# Although this is a simple function body, it's useful to encode esoteric
|
||||
# knowledge that I will easily forget.
|
||||
test -n "$TMUX"
|
||||
}
|
||||
|
||||
tmux_focused_pane() {
|
||||
# Returns the ID of the focused tmux pane.
|
||||
# WIP
|
||||
# tmux list-panes -F '#{pane_active} #{pane_tty}' | awk /1/{ print $1 }
|
||||
echo 'Not implemented'
|
||||
}
|
||||
|
||||
# Google3
|
||||
g3_root() {
|
||||
# Outputs the root of the CitC client in g3
|
||||
# NOTE: there is probably a function already supported by g4 to cd to the
|
||||
# root, so support for this function may be dropped shortly.
|
||||
echo "${PWD%%/google3/*}/google3"
|
||||
}
|
||||
|
||||
citc_workspace() {
|
||||
# Returns the name of your current CitC workspace
|
||||
pwd | grep -o -P "$(whoami)\/[^\/]+"
|
||||
}
|
||||
|
||||
codesearch() {
|
||||
# Attempts to open the current directory in Google's Code Search.
|
||||
local slug="$(pwd | grep -P -o 'google3\/.+$')"
|
||||
browse "https://cs.corp.google.com/piper///depot/$slug"
|
||||
}
|
||||
|
||||
cider() {
|
||||
# Opens the current workspace and current directory in Google's Cider
|
||||
# Not very useful at the moment because it cannot jump to the current file or
|
||||
# line number. Should also support an Emacs integration at some point.
|
||||
browse "https://cider.corp.google.com/?ws=$(citc_workspace)"
|
||||
}
|
||||
|
||||
# i3
|
||||
focus() {
|
||||
# Focuses an i3 window by application name.
|
||||
i3-msg "[class=\"$1\"] focus" >/dev/null
|
||||
}
|
||||
|
||||
# zsh
|
||||
fns() {
|
||||
# Outputs all available functions.
|
||||
# `fns` was chosen instead of `functions`, since `functions` was already
|
||||
# taken.
|
||||
compgen -A function
|
||||
}
|
||||
|
||||
aliases() {
|
||||
# Outputs all available aliases.
|
||||
compgen -a
|
||||
}
|
||||
|
||||
keywords() {
|
||||
# Outputs all of the shell's reserved keywords.
|
||||
compgen -k
|
||||
}
|
||||
|
||||
builtins() {
|
||||
# Outputs all of the shell's builtin commands.
|
||||
compgen -b
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
export TERMINAL=urxvtc
|
||||
export EDITOR=emacsclient
|
||||
export ALTERNATE_EDITOR=nvim
|
||||
export GPG_TTY=$(tty) # "It is important that this environment variable always reflects the output of the tty command". Source: https://gnupg.org/documentation/manuals/gnupg-devel/Invoking-GPG_002dAGENT.html
|
||||
|
||||
BROWSER=google-chrome
|
||||
NIXIFY="$HOME/programming/nixify"
|
||||
DATE_FMT=%b-%d-%Y_%T # my preferred date formatting string used for generated filename
|
||||
date_fmt=%b-%d-%Y_%T # my preferred date formatting string used for generated filename
|
||||
|
||||
# ZSH's static named directories
|
||||
hash -d pro=~/programming
|
||||
hash -d dot=~/programming/dotfiles
|
||||
hash -d dot="$DOTFILES"
|
||||
hash -d citc=/google/src/cloud/$USER
|
||||
hash -d doc=~/Documents
|
||||
hash -d d=~/Downloads
|
||||
hash -d ss=~/Pictures/screenshots
|
||||
hash -d org=~/Documents/org
|
||||
hash -d fonts="$DOTFILES/configs/linux/misc/.local/share/fonts"
|
||||
hash -d sounds="$DOTFILES/configs/linux/misc/.local/share/sounds"
|
||||
hash -d wallpaper="$DOTFILES/configs/linux/misc/.local/share/wallpaper"
|
||||
hash -d org="$ORG_DIRECTORY"
|
||||
hash -d x20=/google/data/rw/users/wp/wpcarro # remember: to access x20, you need to run `prodaccess`
|
||||
# named directories for commonly used projects
|
||||
hash -d korvus_framework=./java/com/google/corp/sales
|
||||
hash -d korvus_services=./corp/sales/casesautomation
|
||||
|
@ -23,6 +22,24 @@ hash -d ultra=./ads/doubleclick/systems/crm
|
|||
hash -d incentives_fe=./experimental/adservices/jarvis/jarvis_extension/jarvis_staging/js
|
||||
hash -d incentives_be=./experimental/adservices/tesseract/handlers/incentives
|
||||
|
||||
# 8-bit colors
|
||||
black='\u001b[30m'
|
||||
red='\u001b[31m'
|
||||
green='\u001b[32m'
|
||||
yellow='\u001b[33m'
|
||||
blue='\u001b[34m'
|
||||
magenta='\u001b[35m'
|
||||
cyan='\u001b[36m'
|
||||
white='\u001b[37m'
|
||||
bright_black='\u001b[30;1m'
|
||||
bright_red='\u001b[31;1m'
|
||||
bright_green='\u001b[32;1m'
|
||||
bright_yellow='\u001b[33;1m'
|
||||
bright_blue='\u001b[34;1m'
|
||||
bright_magenta='\u001b[35;1m'
|
||||
bright_cyan='\u001b[36;1m'
|
||||
bright_white='\u001b[37;1m'
|
||||
|
||||
# commonly used config files
|
||||
v="$HOME/.config/nvim/init.vim"
|
||||
e="$HOME/.emacs.d/init.el"
|
||||
|
|
31
configs/shared/zsh/zle.zsh
Normal file
31
configs/shared/zsh/zle.zsh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
zle_insert_subshell() {
|
||||
LBUFFER+='$(' ; RBUFFER=")$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_subshell
|
||||
bindkey '^j' zle_insert_subshell
|
||||
|
||||
zle_insert_variable() {
|
||||
LBUFFER+='${' ; RBUFFER="}$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_variable
|
||||
bindkey '^v' zle_insert_variable
|
||||
|
||||
zle_insert_2x_dash() {
|
||||
LBUFFER+=' --'
|
||||
}
|
||||
zle -N zle_insert_2x_dash
|
||||
bindkey '^[^f' zle_insert_2x_dash
|
||||
|
||||
zle_insert_2x_quote() {
|
||||
LBUFFER+=' "' ; RBUFFER="\"$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_2x_quote
|
||||
bindkey '^["' zle_insert_2x_quote
|
||||
|
||||
zle_insert_quote() {
|
||||
LBUFFER+=" '" ; RBUFFER="'$RBUFFER"
|
||||
}
|
||||
zle -N zle_insert_quote
|
||||
bindkey "^['" zle_insert_quote
|
16
configs/uninstall
Normal file → Executable file
16
configs/uninstall
Normal file → Executable file
|
@ -2,10 +2,16 @@
|
|||
|
||||
configs="$DOTFILES/configs"
|
||||
|
||||
if [[ $(uname) == 'Darwin' ]]; then
|
||||
(cd "$configs/os_x" && stow --delete --target="$HOME" *)
|
||||
elif [[ $(uname) == 'Linux' ]]; then
|
||||
(cd "$configs/linux" && stow --delete --target="$HOME" *)
|
||||
fi
|
||||
case $(hostname) in
|
||||
# desktop
|
||||
wpcarro.lon.corp.google.com)
|
||||
(cd "$configs/desktop" && stow --delete --target="$HOME" *);;
|
||||
# laptop
|
||||
wpcarro.roam.googlers.com)
|
||||
(cd "$configs/laptop" && stow --delete --target="$HOME" *);;
|
||||
# cloudtop
|
||||
wpcarro.c.googlers.com)
|
||||
(cd "$configs/cloudtop" && stow --delete --target="$HOME" *);;
|
||||
esac
|
||||
|
||||
(cd "$configs/shared" && stow --delete --target="$HOME" *)
|
||||
|
|
Loading…
Reference in a new issue