Skip to content

Instantly share code, notes, and snippets.

View calbertts's full-sized avatar

Carlos Castaño calbertts

View GitHub Profile
@calbertts
calbertts / nut.yml
Last active January 26, 2017 23:04
syntax_version: "7"
docker_image: calbertts/node-gtk
enable_gui: true
container_working_directory: /app
work_in_project_folder_as: /app
volumes:
main:
host_path: .
container_path: /app
macros:
@calbertts
calbertts / runc.sh
Last active December 8, 2017 12:28
Runs a docker container from an image
runc() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local image=$(docker images --format '{{.Repository}}:{{.Tag}}' | fzf-tmux --reverse --multi)
if [[ $image != '' ]]; then
echo -e "\n \033[1mDocker image:\033[0m" $image
read -e -p $' \e[1mOptions: \e[0m' -i "-it --rm" options
printf " \033[1mChoose the command: \033[0m"
local cmd=$(echo -e "/bin/bash\nsh" | fzf-tmux --reverse --multi)
if [[ $cmd == '' ]]; then
@calbertts
calbertts / runinc.sh
Last active November 4, 2019 14:29
Runs a command in a running docker container
runinc() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
echo -e "\n \033[1mDocker container:\033[0m" $container
read -e -p $' \e[1mOptions: \e[0m' -i "-it" options
if [[ $@ == '' ]]; then
read -e -p $' \e[1mCommand: \e[0m' cmd
else
cmd="$@"
@calbertts
calbertts / stopc.sh
Last active February 13, 2017 14:54
Stops and/or removes a docker container
# Stops and/or removes a docker container
stopc() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
echo -e "\n \033[1mDocker container:\033[0m" $container
printf " \033[1mRemove?: \033[0m"
local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi)
if [[ $cmd != '' ]]; then
if [[ $cmd == 'No' ]]; then
@calbertts
calbertts / showipc.sh
Last active February 24, 2017 14:43
Shows all the docker container's ip addresses
showipc() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$(docker ps -a --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
local network=$(docker inspect $container -f '{{.NetworkSettings.Networks}}' | awk -F 'map\\[|:' '{print $2}')
echo -e "\n \033[1mDocker container:\033[0m" $container
history -s showipc
history -s docker inspect -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" $container
echo -e " \033[1mNetwork:\033[0m" $network
"Figitive color scheme
hi DiffAdd guifg=NONE ctermfg=NONE guibg=#464632 ctermbg=238 gui=NONE cterm=NONE
hi DiffChange guifg=NONE ctermfg=NONE guibg=#335261 ctermbg=239 gui=NONE cterm=NONE
hi DiffDelete guifg=#f43753 ctermfg=203 guibg=#79313c ctermbg=237 gui=NONE cterm=NONE
hi DiffText guifg=NONE ctermfg=NONE guibg=NONE ctermbg=NONE gui=reverse cterm=reverse
"New line without insert mode
nnoremap <C-J> a<CR><Esc>k$
"Enable mouse
@calbertts
calbertts / startc.sh
Last active February 24, 2017 14:44
Starts a stopped docker container
startc() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$((docker ps -a --filter status=exited --format '{{.Names}} => {{.Image}} => EXITED' & docker ps -a --filter status=created --format '{{.Names}} => {{.Image}} => CREATED') | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
echo -e "\n \033[1mDocker container:\033[0m" $container
echo -e "\n Starting $container ...\n"
history -s startc
history -s docker start $container
docker start $container > /dev/null
fi
@calbertts
calbertts / removec.sh
Last active February 24, 2017 14:44
Removes a stopped docker container
removec() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$((docker ps -a --filter status=exited --format '{{.Names}} => {{.Image}} => EXITED' & docker ps -a --filter status=created --format '{{.Names}} => {{.Image}} => CREATED') | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
echo -e "\n \033[1mDocker container:\033[0m" $container
printf " \033[1mAre you sure?: \033[0m"
local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi)
if [[ $cmd != '' ]]; then
if [[ $cmd == 'Yes' ]]; then
echo -e " Removing $container ...\n"
function color_my_prompt {
local __user_and_host="@\u"
local __cur_location="\[\033[01;34m\]\W"
local __git_branch_color="\[\033[32m\]"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\\(.+\)$/\\\\\\1\\ /`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
color_my_prompt
@calbertts
calbertts / init.vim
Last active January 8, 2020 16:43
Neovim config
let g:loaded_youcompleteme = 1
if empty(glob('~/.vim/autoload/plug.vim'))
silent execute "!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
" Kepp selected test when fixing indentation
vnoremap < <gv
vnoremap > >gv