Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/bash -x
# This script will be executed by root user and stored at
# /var/lib/cloud/instance/user-data.txt when invoking ec2.
#
# You can see the log from AWS Management Console in the following way.
# EC2: Actions > Monitor and troubleshoot > Get system log
################################################################################
# variables
@kyagi
kyagi / cn
Created April 22, 2023 21:43
#!/usr/bin/env bash
eval $(egrep ^Host ~/.ssh/config | awk '{ print $2 }' | fzf | xargs -I{} echo "ssh {}")
tell application "Terminal"
do script "ssh SERVER_NAME"
do script "cd deploy-directory" in front window
do script "cap prod deploy" in front window
end tell
@kyagi
kyagi / gist:3900356
Created October 16, 2012 16:25
Apple script to login server
tell application "Terminal"
do script "ssh SERVER_NAME"
do script "cd /tmp" in front window
do script "date" in front window
end tell
@kyagi
kyagi / gist:3900214
Created October 16, 2012 16:01
bookmark.command on mac using wish (tcl/tk)
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@" &
button .b0 -text "github" -command "exec open https://github.com/"
button .b1 -text "bitbucket" -command "exec open https://bitbucket.org/"
button .b2 -text "login - serverA" -command "exec serverA.scpt"
button .b3 -text "iterm" -command "exec open -a /Applications/iTerm.app"
pack .b0 .b1 .b2 .b3 -fill x
@kyagi
kyagi / gist:3899895
Created October 16, 2012 15:17
create-alias-from-ssh-config
#!/bin/bash
paste <(grep ^Host config) <(grep HostName config) <(grep 'User ' config) | awk '{ printf("alias %s=\"ssh -A %s@%s\"\n", $2, $6, $4); }'
@kyagi
kyagi / gist:3899493
Created October 16, 2012 14:10
PS1 Shell Prompt
# Prompt - black
PS1='\[\033[40;1;32m\]\u\[\033[2;32m\]@\[\033[0m\]\[\033[40;32m\]\h \[\033[1;36m\]\w \[\033[0m\]\[\033[40;2;37m\]\d \t\[\033[0m\]\n\\$ '
# Prompt - white
PS1='\[\033[47;0;32m\]\u\[\033[0;32m\]@\[\033[0m\]\[\033[47;0;32m\]\h \[\033[0;36m\]\w \[\033[0m\]\[\033[47;0;37m\]\d \t\[\033[0m\]\n\\$ '
;;; lexical-let ってなに?
(let ((count 0))
(defun get-count ()
(setq count (+ count 1))
count)
; (let ((count 10))
(lexical-let ((count 10))
(print (get-count))
(print (get-count))
(print (get-count))