Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add stderr redirect in case folder doesn't exist #8

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions bin/.local/bin/tmux-cht.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env bash
selected=`cat ~/.tmux-cht-languages ~/.tmux-cht-command | fzf`
if [[ -z $selected ]]; then
exit 0
fi

read -p "Enter Query: " query

if grep -qs "$selected" ~/.tmux-cht-languages; then
query=`echo $query | tr ' ' '+'`
tmux neww bash -c "curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done"
tmux neww bash -c "echo \"curl cht.sh/$selected/$query/\" & curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done"
else
tmux neww bash -c "curl cht.sh/$selected~$query & while [ : ]; do sleep 1; done"
tmux neww bash -c "curl -s cht.sh/$selected~$query | less"
fi

65 changes: 15 additions & 50 deletions bin/.local/bin/tmux-sessionizer
Original file line number Diff line number Diff line change
@@ -1,63 +1,28 @@
#!/usr/bin/env bash

TMUX_HISTORY_LENGTH=10
TMUX_HISTORY_FILE=$HOME/.tmux-sessionizer

add_new_line() {
tail -n1 $1 | read -r _ || echo >> $1
}

update_history() {
# TODO: Probably change this to .config once i have the proper version of tmux
if [[ ! -e "$TMUX_HISTORY_FILE" ]]; then
touch $TMUX_HISTORY_FILE
fi
tmux_contents=`cat $TMUX_HISTORY_FILE`
printf "$1\n$tmux_contents" > $TMUX_HISTORY_FILE
sed -ni "1,${TMUX_HISTORY_LENGTH}p" $TMUX_HISTORY_FILE
add_new_line $TMUX_HISTORY_FILE
}

clear_history() {
rm $TMUX_HISTORY_FILE
touch $TMUX_HISTORY_FILE
}

if [[ "$1" = "clear" ]]; then
clear_history
exit 0
elif [[ "$1" = "-v" ]]; then
cat $TMUX_HISTORY_FILE
exit 0
elif [[ $# -eq 1 ]]; then
if [[ $# -eq 1 ]]; then
selected=$1
elif [[ $# -eq 2 && "$1" = "restore" ]]; then
history_length=`cat $TMUX_HISTORY_FILE | wc -l`
if [[ $2 -gt $history_length ]]; then
echo "Requested $2 item, but there is only $history_length available."
exit 1
elif [[ $2 -ge $TMUX_HISTORY_LENGTH ]]; then
echo "cannot provide a length greater than $TMUX_HISTORY_LENGTH"
exit 1
fi
selected=`cat $TMUX_HISTORY_FILE | sed -n "$2,${2}p"`
else
items=`find ~/work -maxdepth 1 -mindepth 1 -type d`
items+=`find ~/personal -maxdepth 1 -mindepth 1 -type d`
items+=`find ~ -maxdepth 1 -mindepth 1 -type d`
selected=`echo "$items" | fzf`
selected=$(find ~/ ~/work ~/personal -mindepth 1 -maxdepth 1 -type d 2> /dev/null | fzf)
fi

if [[ -z $selected ]]; then
exit 0
fi

tmux_session_name=`basename $selected | tr . _`
update_history $selected

tmux switch-client -t $tmux_session_name
if [[ $? -eq 0 ]]; then
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
exit 0
fi

tmux new-session -c $selected -d -s $tmux_session_name && tmux switch-client -t $tmux_session_name || tmux new -c $selected -A -s $tmux_session_name
if ! tmux has-session -t $selected_name 2> /dev/null; then
tmux new-session -ds $selected_name -c $selected
fi

if [[ -z $TMUX ]]; then
tmux attach-session -t $selected_name
else
tmux switch-client -t $selected_name
fi
52 changes: 32 additions & 20 deletions i3/.config/i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,40 @@ bindsym $mod+a focus parent
#bindsym $mod+d focus child

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10
#bindsym $mod+1 workspace 1
#bindsym $mod+2 workspace 2
#bindsym $mod+3 workspace 3
#bindsym $mod+4 workspace 4
#bindsym $mod+5 workspace 5
#bindsym $mod+6 workspace 6
#bindsym $mod+7 workspace 7
#bindsym $mod+8 workspace 8
#bindsym $mod+9 workspace 9
#bindsym $mod+0 workspace 10

# switch to workspace
bindsym $mod+Shift+equal workspace 1
bindsym $mod+bracketleft workspace 2
bindsym $mod+Shift+bracketleft workspace 3
bindsym $mod+Shift+9 workspace 4
bindsym $mod+Shift+7 workspace 5
bindsym $mod+equal workspace 6
bindsym $mod+Shift+0 workspace 7
bindsym $mod+Shift+bracketright workspace 8
bindsym $mod+bracketright workspace 9
bindsym $mod+Shift+8 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10
bindsym $mod+1 move container to workspace 1
bindsym $mod+2 move container to workspace 2
bindsym $mod+3 move container to workspace 3
bindsym $mod+4 move container to workspace 4
bindsym $mod+5 move container to workspace 5
bindsym $mod+6 move container to workspace 6
bindsym $mod+7 move container to workspace 7
bindsym $mod+8 move container to workspace 8
bindsym $mod+9 move container to workspace 9
bindsym $mod+0 move container to workspace 10

# reload the configuration file
bindsym $mod+Shift+c reload
Expand Down
10 changes: 9 additions & 1 deletion nvim/.config/nvim/init.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
" hello front end masters
set path+=**

" Nice menu when typing `:find *.py`
Expand Down Expand Up @@ -41,6 +42,7 @@ Plug 'rafamadriz/friendly-snippets'
Plug 'rust-lang/rust.vim'
Plug 'darrikonn/vim-gofmt'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'junegunn/gv.vim'
Plug 'vim-utils/vim-man'
Plug 'mbbill/undotree'
Expand Down Expand Up @@ -101,7 +103,7 @@ imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice'
smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'

nnoremap <silent> Q <nop>
nnoremap <silent> <C-f> :lua require("harpoon.term").sendCommand(1, "tmux-sessionizer\n"); require("harpoon.term").gotoTerminal(1)<CR>
nnoremap <silent> <C-f> :silent !tmux neww tmux-sessionizer<CR>
nnoremap <leader>vwh :h <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>bs /<C-R>=escape(expand("<cWORD>"), "/")<CR><CR>
nnoremap <leader>u :UndotreeShow<CR>
Expand All @@ -119,10 +121,16 @@ nnoremap <leader>dwm :lua require("vim-with-me").disconnect()<CR>
nnoremap <leader>gll :let g:_search_term = expand("%")<CR><bar>:Gclog -- %<CR>:call search(g:_search_term)<CR>
nnoremap <leader>gln :cnext<CR>:call search(_search_term)<CR>
nnoremap <leader>glp :cprev<CR>:call search(_search_term)<CR>
nnoremap <leader>x :!chmod +x %<CR>

vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv

nnoremap Y yg$
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ`z

" greatest remap ever
xnoremap <leader>p "_dP

Expand Down
43 changes: 2 additions & 41 deletions nvim/.config/nvim/lua/theprimeagen/git-worktree.lua
Original file line number Diff line number Diff line change
@@ -1,47 +1,8 @@
local Worktree = require("git-worktree")
local Job = require("plenary.job")
local Path = require("plenary.path")

local function is_nrdp()
return not not (string.find(vim.loop.cwd(), vim.env.NRDP, 1, true))
end

local function is_tvui()
return not not (string.find(vim.loop.cwd(), vim.env.TVUI, 1, true))
end

local function get_nrdp_build_paths(path)
return
Path:new({vim.env.NRDP, path, "configure"}):absolute(),
Path:new({vim.env.NRDP, "build", path}):absolute()
end

Worktree.on_tree_change(function(op, path, upstream)

if op == Worktree.Operations.Switch and is_tvui() then
Job:new({
"./tvui", "install"
}):start()
end

if op == Worktree.Operations.Create and is_nrdp() then
local submodule = Job:new({
"git", "submodule", "update"
})

local configure_path, build_path = get_nrdp_build_paths(path)
local make_build = Job:new({
"mkdir", "-p", build_path
})

local configure = Job:new({
configure_path, "--ninja", "--debug",
cwd = build_path,
})

submodule:and_then_on_success(make_build)
make_build:and_then_on_success(configure)
submodule:start()
if op == Worktree.Operations.Switch then
elseif op == Worktree.Operations.Create then
end
end)

2 changes: 1 addition & 1 deletion tmux/.tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bind -r l select-pane -R

bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/dotfiles/todo.md"

bind-key -r ^ run-shell "~/.local/bin/tmux-sessionizer restore 2"
bind-key -r i run-shell "tmux neww tmux-cht.sh"
bind-key -r G run-shell "~/.local/bin/tmux-sessionizer /home/theprimeagen/work/nrdp"
bind-key -r C run-shell "~/.local/bin/tmux-sessionizer /home/theprimeagen/work/tvui"
bind-key -r R run-shell "~/.local/bin/tmux-sessionizer /home/theprimeagen/work/milo"
Expand Down
2 changes: 0 additions & 2 deletions zsh/.zsh_profile
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,3 @@ eslintify() {
cat $1 > /tmp/file_to_eslint
npx eslint
}

asdf
2 changes: 1 addition & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ZSH_THEME="robbyrussell"
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions)
plugins=(git)

source $ZSH/oh-my-zsh.sh

Expand Down