From 3949f763f41853610d71ce8f62fe3bfec6b2fbe3 Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Thu, 30 Jul 2020 21:12:17 -0400 Subject: [PATCH] tmux fzf and 1password --- alacritty.configlink/alacritty.yml | 2 +- fish.configlink/config.fish | 8 ++-- fish.configlink/fish_variables | 7 ++- fish.configlink/functions/aliases.fish | 6 ++- .../functions/fzf_key_bindings.fish | 1 + fish.configlink/functions/mactools.fish | 7 +++ fish.configlink/functions/pyenv.fish | 10 ++++ homebrew/Caskfile | 3 +- scripts/bootstrap | 47 ++++++++++++++++++- scripts/install_casks | 2 + starship/starship.toml.configlink | 8 +++- tmux/gitmux.conf.symlink | 6 +-- tmux/tmux.conf.symlink | 18 ++++--- 13 files changed, 105 insertions(+), 20 deletions(-) create mode 120000 fish.configlink/functions/fzf_key_bindings.fish create mode 100644 fish.configlink/functions/mactools.fish diff --git a/alacritty.configlink/alacritty.yml b/alacritty.configlink/alacritty.yml index e0aab4a..4f8886f 100644 --- a/alacritty.configlink/alacritty.yml +++ b/alacritty.configlink/alacritty.yml @@ -366,7 +366,7 @@ shell: args: - --login - --init-command - - tmux a -t noah || tmux new -s noah + - tmux a -t noah || eval (security find-generic-password -s 1Password -w | op signin enterprise_console) && tmux new -s noah # Startup directory # diff --git a/fish.configlink/config.fish b/fish.configlink/config.fish index c3acc10..a7a5e09 100644 --- a/fish.configlink/config.fish +++ b/fish.configlink/config.fish @@ -27,13 +27,15 @@ if status --is-interactive # Colors theme_gruvbox - # Aliases - aliases - # Individual features + aliases pyenv notes aws + mactools + + # Fuzzy finder + fzf_key_bindings # Use `starship` prompt starship init fish | source diff --git a/fish.configlink/fish_variables b/fish.configlink/fish_variables index adeb965..929263a 100644 --- a/fish.configlink/fish_variables +++ b/fish.configlink/fish_variables @@ -9,7 +9,9 @@ SETUVAR _fish_abbr_cat:bat SETUVAR _fish_abbr_d:deactivate SETUVAR _fish_abbr_db:docker\x20build\x20\x2e\x20\x2dt SETUVAR _fish_abbr_dc:\x24DOTS/bin/docker_cleanup -SETUVAR _fish_abbr_dr:docker\x20run +SETUVAR _fish_abbr_de:docker\x20exec\x20\x2dit +SETUVAR _fish_abbr_dr:docker\x20run\x20\x2d\x2drm\x20\x2dit +SETUVAR _fish_abbr_ds:docker\x20ps\x20\x2da SETUVAR _fish_abbr_falias:vim\x20\x24HOME/\x2econfig/fish/functions/aliases\x2efish SETUVAR _fish_abbr_fishal:vim\x20\x24HOME/\x2econfig/fish/functions/aliases\x2efish SETUVAR _fish_abbr_fishrc:vim\x20\x24HOME/\x2econfig/fish/config\x2efish @@ -18,6 +20,7 @@ SETUVAR _fish_abbr_g:git SETUVAR _fish_abbr_ga:git\x20add\x20\x2dA SETUVAR _fish_abbr_gc:git\x20commit\x20\x2dm SETUVAR _fish_abbr_gd:git\x20diff +SETUVAR _fish_abbr_get_2D_fingerprint:ssh\x2dkeyscan\x20myhost\x2ecom\x20\x7c\x20ssh\x2dkeygen\x20\x2dlf\x20\x2d SETUVAR _fish_abbr_gp:git\x20push SETUVAR _fish_abbr_gs:git\x20status SETUVAR _fish_abbr_gu:git\x20pull @@ -30,6 +33,7 @@ SETUVAR _fish_abbr_ll:ls\x20\x2dalhF SETUVAR _fish_abbr_misty:cd\x20\x24PROJ/misty SETUVAR _fish_abbr_oldcat:cat SETUVAR _fish_abbr_p:python +SETUVAR _fish_abbr_public_2D_key:ssh\x2dkeygen\x20\x2dy\x20\x2df\x20\x7e/\x2essh/id_rsa\x20\x3e\x20\x7e/\x2essh/id_rsa\x2epub SETUVAR _fish_abbr_py:python SETUVAR _fish_abbr_runbootstrap:\x24DOTS/scripts/bootstrap SETUVAR _fish_abbr_sshc:vim\x20\x7e/\x2essh/config @@ -64,3 +68,4 @@ SETUVAR fish_pager_color_completion:normal SETUVAR fish_pager_color_description:B3A06D\x1eyellow SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_user_paths:/usr/local/opt/fzf/bin diff --git a/fish.configlink/functions/aliases.fish b/fish.configlink/functions/aliases.fish index 1f1608f..bf6212f 100644 --- a/fish.configlink/functions/aliases.fish +++ b/fish.configlink/functions/aliases.fish @@ -49,11 +49,15 @@ function aliases --description 'All aliases' alias proj='cd $PROJ' abbr -a ssl 'openssl req -new -newkey rsa:2048 -nodes' \ '-keyout server.key -out server.csr' + abbr -a get-fingerprint 'ssh-keyscan myhost.com | ssh-keygen -lf -' + abbr -a public-key 'ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub' # Docker abbr -a dc '$DOTS/bin/docker_cleanup' - abbr -a dr 'docker run' + abbr -a dr 'docker run --rm -it' abbr -a db 'docker build . -t' + abbr -a ds 'docker ps -a' + abbr -a de 'docker exec -it' alias connect='docker run --rm -v ~/.aws:/root/.aws -v ~/.ssh:/root/.ssh -it connect-aws' # Terraform diff --git a/fish.configlink/functions/fzf_key_bindings.fish b/fish.configlink/functions/fzf_key_bindings.fish new file mode 120000 index 0000000..a66a998 --- /dev/null +++ b/fish.configlink/functions/fzf_key_bindings.fish @@ -0,0 +1 @@ +/usr/local/opt/fzf/shell/key-bindings.fish \ No newline at end of file diff --git a/fish.configlink/functions/mactools.fish b/fish.configlink/functions/mactools.fish new file mode 100644 index 0000000..9510891 --- /dev/null +++ b/fish.configlink/functions/mactools.fish @@ -0,0 +1,7 @@ +#!/usr/local/bin/fish + +function mactools + function copy --description 'Copy file contents into clipboard' + cat $argv | pbcopy + end +end diff --git a/fish.configlink/functions/pyenv.fish b/fish.configlink/functions/pyenv.fish index 672b375..a7fe359 100644 --- a/fish.configlink/functions/pyenv.fish +++ b/fish.configlink/functions/pyenv.fish @@ -13,6 +13,16 @@ function 'pyenv' --description 'Features for Pyenv virtualenvs' source ~/.pyenv/versions/$argv[1]/bin/activate.fish end + # vers - switch to pyenv virtualenv with fuzzy menu + function 'vers' --description 'Switch to virtualenv' + set pyversion (bash -c "pyenv versions --bare --skip-aliases" | fzf) + if test $status -ne 0 + return 1 + else + source "$PYENV_VERSIONS_DIR/$pyversion/bin/activate.fish" + end + end + function 'ipy' --description 'Borrow iPython interpreter' set STORED_VENV $VIRTUAL_ENV source $PYENV_VERSIONS_DIR/ipython/bin/activate.fish; and \ diff --git a/homebrew/Caskfile b/homebrew/Caskfile index b96744b..f360b6e 100644 --- a/homebrew/Caskfile +++ b/homebrew/Caskfile @@ -6,7 +6,8 @@ cask "google-chrome" # Work Programs cask "slack" cask "zoomus" -cask "onepassword" +cask "1password" +cask "1password-cli" cask "dropbox" # Fonts diff --git a/scripts/bootstrap b/scripts/bootstrap index 9431b72..04e2c10 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -66,6 +66,31 @@ install_brews() { echo "brews installed ✓" } +use_fish_shell() { + if ! (which fish > /dev/null) + then + echo "Install fish before continuing" + echo "You can do: brew install fish" + echo "Or add fish to homebrew/Brewfile and rerun" + exit 1 + fi + FISH_SHELL=$(which fish) + if ! (cat /etc/shells | grep $FISH_SHELL > /dev/null) + then + echo "Modifying /etc/shells" + echo "Requires sudo password" + sudo echo $FISH_SHELL >> /etc/shells + fi + if ! (echo "$SHELL" | grep fish > /dev/null) + then + echo "Changing default shell to fish" + echo "Requires sudo password" + sudo chsh -s $FISH_SHELL + fi + + echo "fish ✓" +} + setup_tmux() { if [[ ! -d ~/.tmux/plugins/tpm ]]; then git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm @@ -74,6 +99,22 @@ setup_tmux() { echo "tmux ✓" } +install_gitmux() { + if ! (which gitmux > /dev/null) + then + printf "gitmux ✕\n\n" + printf "\ninstalling gitmux..." + /bin/bash -c "$(curl -L -o gitmux.tar.gz https://github.com/arl/gitmux/releases/download/v0.6.0/gitmux_0.6.0_macOS_amd64.tar.gz)" + tar -xzf gitmux.tar.gz gitmux + mkdir -p ~/.local/bin + mv gitmux ~/.local/bin/ + rm gitmux.tar.gz + echo "" + fi + + echo "gitmux ✓" +} + install_spacemacs() { emacsdir=~/.emacs.d if ! (git -C "$emacsdir" pull > /dev/null 2>&1) @@ -85,13 +126,15 @@ install_spacemacs() { } printf "\nbootstrapping...\n\n" -check_for_zsh -check_for_ohmyzsh +#check_for_zsh +#check_for_ohmyzsh install_xcode install_homebrew install_brews setup_tmux +install_gitmux install_spacemacs +use_fish_shell ("$DOTS/scripts/setup_symlinks") echo "" diff --git a/scripts/install_casks b/scripts/install_casks index 6fdd1da..4bb6bec 100755 --- a/scripts/install_casks +++ b/scripts/install_casks @@ -1,3 +1,5 @@ +#!/bin/sh + install_casks() { brewfile=$DOTS/homebrew/Caskfile if ! (/usr/local/bin/brew bundle check --file "$brewfile" > /dev/null) diff --git a/starship/starship.toml.configlink b/starship/starship.toml.configlink index e57c9c5..c54bcf2 100644 --- a/starship/starship.toml.configlink +++ b/starship/starship.toml.configlink @@ -1,6 +1,6 @@ # Don't print a new line at the start of the prompt add_newline = false -prompt_order = ["directory", "git_branch", "python", "git_status", "character"] +prompt_order = ["directory", "custom.virtualenv", "character"] # Replace the "❯" symbol in the prompt with "➜" [character] # The name of the module we are configuring is "character" @@ -21,3 +21,9 @@ suffix = "" [python] symbol = "" + +[custom.virtualenv] +command = "echo (basename $VIRTUAL_ENV)" # shows output of command +prefix = "(" +suffix = ") " +when = "true" diff --git a/tmux/gitmux.conf.symlink b/tmux/gitmux.conf.symlink index 249c920..197c4c0 100644 --- a/tmux/gitmux.conf.symlink +++ b/tmux/gitmux.conf.symlink @@ -9,7 +9,7 @@ tmux: modified: '~' untracked: '✚' stashed: '⚑ ' - clean: '✔' + clean: '' styles: state: '#[fg=red,bold]' branch: '#[fg=red,bold]' @@ -19,5 +19,5 @@ tmux: modified: '#[fg=colour239,bold]' untracked: '#[fg=colour239,bold]' stashed: '#[fg=colour239,bold]' - clean: '#[fg=green,bold]' - layout: [remote, ' ', flags, ' '] + clean: '#[fg=colour241,bold]' + layout: [' ', remote, ' ', flags, ' |'] diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink index f296526..42351bb 100644 --- a/tmux/tmux.conf.symlink +++ b/tmux/tmux.conf.symlink @@ -1,8 +1,3 @@ -# Remap prefix to Control + space -#unbind C-b -#set -g prefix C-space -#bind C-space send-prefix - # Keep plenty of history for scrollback set -g history-limit 100000 @@ -37,7 +32,7 @@ bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel set -g mouse on # Status bar -set -g status-interval 10 # Seconds between refreshes +set -g status-interval 60 # Seconds between refreshes set -g renumber-windows on set-option -g base-index 1 # Set 1 for first window (easier to type) set-window-option -g pane-base-index 1 # Set 1 for first pane (easier to type) @@ -88,8 +83,17 @@ set-option -g status-right-style none set-option -g status-right-length "80" set-window-option -g window-status-separator "" +WEATHER='#(curl -s wttr.in/\?format\="%%c%%t")' set-option -g status-left "#[fg=colour248, bg=colour241] #S #[fg=colour241, bg=colour237, nobold, noitalics, nounderscore]" -set-option -g status-right "#[fg=colour239, bg=colour237, nobold, nounderscore, noitalics]#[fg=colour246,bg=colour239] %Y-%m-%d  %H:%M #[fg=colour248, bg=colour239, nobold, noitalics, nounderscore]#[fg=colour237, bg=colour248] #(gitmux -cfg .gitmux.conf '#{pane_current_path}')" +set-option -g status-right "#[fg=colour239, bg=colour237, nobold, nounderscore, noitalics]#[fg=colour246,bg=colour239] %Y-%m-%d  %H:%M #[fg=colour248, bg=colour239, nobold, noitalics, nounderscore]#[fg=colour237, bg=colour248]#(gitmux -cfg .gitmux.conf '#{pane_current_path}') #[fg=colour237, nobold, bg=colour248]$WEATHER #[fg=colour237] " set-window-option -g window-status-current-format "#[fg=colour237, bg=colour214, nobold, noitalics, nounderscore]#[fg=colour239, bg=colour214] #I #[fg=colour239, bg=colour214, bold] #W #[fg=colour214, bg=colour237, nobold, noitalics, nounderscore]" set-window-option -g window-status-format "#[fg=colour237,bg=colour239,noitalics]#[fg=colour223,bg=colour239] #I #[fg=colour223, bg=colour239] #W #[fg=colour239, bg=colour237, noitalics]" + +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'yardnsm/tmux-1password' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' +