Skip to content

Instantly share code, notes, and snippets.

View calbertts's full-sized avatar

Carlos Castaño calbertts

View GitHub Profile
@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
"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 / 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
@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 / 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 / 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 / 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: