diff --git a/jivkok.Shell/jivkok.Shell.nuspec b/jivkok.Shell/jivkok.Shell.nuspec index 241fe90..9b3482b 100644 --- a/jivkok.Shell/jivkok.Shell.nuspec +++ b/jivkok.Shell/jivkok.Shell.nuspec @@ -3,11 +3,11 @@ jivkok.Shell Jivkok - Shell - 1.0.0.12 + 1.1.0.0 Various Jivko Kolev Multi-tabbed console with Windows shell, Powershell, and Bash. - Multi-tabbed console with Windows shell, Powershell, and Bash. Windows shell supports custom start commands via %USERPROFILE%\cmd_profile.cmd + Multi-tabbed console with Windows shell, Powershell, and Bash. Windows shell supports custom start-up commands DOS ( %USERPROFILE%\profile.cmd ) and Powershell ( $Home\profile.ps1 ). http://github.com/jivkok/Chocolatey-Packages/ jivkok shell cmd powershell bash git diff --git a/jivkok.Shell/tools/Bash.aliases b/jivkok.Shell/tools/Bash.aliases deleted file mode 100644 index 0b94c6a..0000000 --- a/jivkok.Shell/tools/Bash.aliases +++ /dev/null @@ -1,64 +0,0 @@ -# Easier navigation -alias ..="cd .." -alias ...="cd ../.." -alias ....="cd ../../.." -alias -- -="cd -" - -# Directories -alias md="mkdir" -alias rd="rm -rf" -alias du='du -h $* | sort -h -r' -alias tree2='tree -A -C -L 2 --dirsfirst' -alias tree2a='tree -a -A -C -L 2 --dirsfirst' - -# Shortcuts -alias g="git" -alias h="history" -alias j="jobs" -alias s="subl" -alias a="atom" -alias v="vim" -alias em='emacs -nw' # No X11 windows -alias eqq='emacs -nw -Q' # No config and no X11 -alias x='exit' - -# ls dirs flag -if ls ~ --group-directories-first > /dev/null 2>&1; then - dirsflag=" --group-directories-first" -else - dirsflag="" -fi -# ls color flag -if ls --color ~ > /dev/null 2>&1; then - # GNU - colorflag="--color=auto" -elif ls -G ~ > /dev/null 2>&1; then - # OSX - colorflag="-G" -else - colorflag="" -fi - -# Listing -alias l="ls -AF $dirsflag $colorflag" -alias ll="ls -AlF $dirsflag $colorflag" -alias recent='ls -Alt | head' # Most recent files - -# Top processes -alias top10='ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10' - -# Get week number -alias week='date +%V' - -# Stopwatch -alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' - -# IP addresses -alias ip="dig +short myip.opendns.com @resolver1.opendns.com" -alias localip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'" - -# URL-encode strings -alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"' - -# Reload the shell (i.e. invoke as a login shell) -alias reload="exec $SHELL -l" diff --git a/jivkok.Shell/tools/Bash.bash_profile b/jivkok.Shell/tools/Bash.bash_profile deleted file mode 100644 index 6f13d94..0000000 --- a/jivkok.Shell/tools/Bash.bash_profile +++ /dev/null @@ -1,11 +0,0 @@ -export PATH=$PATH -export PATH=/usr/bin:$PATH -export PATH=/usr/local/bin:$PATH -export PATH=/usr/local/sbin:$PATH -export PATH=$HOME/bin:$PATH - -# Load the shell dotfiles (~/.path can be used to extend `$PATH`) -for file in ~/.{bashrc,exports,path}; do - [ -r "$file" ] && [ -f "$file" ] && source "$file"; -done; -unset file; diff --git a/jivkok.Shell/tools/Bash.bash_prompt b/jivkok.Shell/tools/Bash.bash_prompt deleted file mode 100644 index 35a65e1..0000000 --- a/jivkok.Shell/tools/Bash.bash_prompt +++ /dev/null @@ -1,47 +0,0 @@ -if [ -f ~/git-prompt.sh ]; then - source ~/git-prompt.sh - GIT_PS1_SHOWDIRTYSTATE=1 - GIT_PS1_SHOWUNTRACKEDFILES=1 - GIT_PS1_SHOWUPSTREAM="auto" -else - function __git_ps1 { - return - } -fi - -# Colors -COLOR_RESET='\[\e[0m\]' -NO_COLOUR="\[\033[0m\]" -BLACK="\[\033[0;30m\]" -RED="\[\033[0;31m\]" -RED_BOLD="\[\033[01;31m\]" -GREEN="\[\033[0;32m\]" -GREEN_BOLD="\[\033[01;32m\]" -YELLOW="\[\033[0;33m\]" -YELLOW_BOLD="\[\033[01;33m\]" -BLUE="\[\033[0;34m\]" -BLUE_BOLD="\[\033[01;34m\]" -PURPLE='\[\e[0;35m\]' -PURPLE_BOLD='\[\e[01;35m\]' -CYAN='\[\e[0;36m\]' -CYAN_BOLD='\[\e[01;36m\]' -WHITE='\[\e[0;37m\]' -WHITE_BOLD='\[\e[01;37m\]' - -function precmd { - local separator=' : ' - local user=${LOGNAME} || ${USER} || ${USERNAME} - user="${user} @ ${HOSTNAME}" - if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then - user="$user (local)" - fi - local location="${PWD}" - - local prefix="\n${YELLOW_BOLD}${user}${COLOR_RESET}${separator}${GREEN_BOLD}${location}${COLOR_RESET}${BLUE_BOLD}$(__git_ps1 " (%s)")${COLOR_RESET}" - - local title="${user}${separator}${location}$(__git_ps1 " (%s)")" - echo -ne "\033]0;${title}\007" - export PS1="${prefix}\n\$ " -} - -export PROMPT_COMMAND=precmd diff --git a/jivkok.Shell/tools/Bash.bashrc b/jivkok.Shell/tools/Bash.bashrc deleted file mode 100644 index 2ea5f43..0000000 --- a/jivkok.Shell/tools/Bash.bashrc +++ /dev/null @@ -1,96 +0,0 @@ -# OS -export OS="$(uname -s)" - -# Shell -if test -n "$ZSH_VERSION"; then - export PROFILE_SHELL='zsh' -elif test -n "$BASH_VERSION"; then - export PROFILE_SHELL='bash' -elif test -n "$KSH_VERSION"; then - export PROFILE_SHELL='ksh' -elif test -n "$FCEDIT"; then - export PROFILE_SHELL='ksh' -elif test -n "$PS3"; then - export PROFILE_SHELL='unknown' -else - export PROFILE_SHELL='sh' -fi - -# Load the shell dotfiles, (~/.bash_extra can be used for any local settings you don’t want to commit) -for file in ~/.{bash_prompt,aliases,functions,bash_extra}; do - [ -r "$file" ] && [ -f "$file" ] && source "$file"; -done; -unset file; - -## set options -set -o vi # vi keys -set -o noclobber # prevent overwriting files with cat - -# Shell options -shopt -s cdspell # Autocorrect typos in path names when using `cd` -shopt -s checkwinsize # Make sure terminals wrap lines correctly after resizing them -shopt -s dotglob # files beginning with . to be returned in the results of path-name expansion. -shopt -s histappend # Append to history (http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html) -shopt -s nocaseglob # Case-insensitive globbing (used in pathname expansion) -# Enable some Bash 4 features when possible -shopt -s autocd 2> /dev/null # * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` -shopt -s globstar 2> /dev/null # * Recursive globbing, e.g. `echo **/*.txt` - -# Enable tab completion for `g` by marking it as an alias for `git` -if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then - complete -o default -o nospace -F _git g; -fi; - -# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards -[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh; - -# node.js and nvm (http://nodejs.org/api/repl.html#repl_repl) -alias node="env NODE_NO_READLINE=1 rlwrap node" -alias node_repl="node -e \"require('repl').start({ignoreUndefined: true})\"" -export NODE_DISABLE_COLORS=1 -if [ -s ~/.nvm/nvm.sh ]; then - NVM_DIR=~/.nvm - source ~/.nvm/nvm.sh - nvm use v0.10.12 &> /dev/null # silence nvm use; needed for rsync -fi - -if [ "$OS" = "Linux" ]; then - - # Set up umask permissions (http://en.wikipedia.org/wiki/Umask) - # umask 002 allows only you to write (but the group to read) any new files that you create. - # umask 022 allows both you and the group to write to any new files which you make. - # In general we want umask 022 on the server and umask 002 on local machines. - # The command 'id' gives the info we need to distinguish these cases. - # $ id -gn #gives group name - # $ id -un #gives user name - # $ id -u #gives user ID - # So: if the group name is the same as the username OR the user id is not greater than 99 - # (i.e. not root or a privileged user), then we are on a local machine, so we set umask 002. - if [ "`id -gn`" == "`id -un`" -a `id -u` -gt 99 ]; then - umask 002 - else - umask 022 - fi - - # Add tab completion for many Bash commands - if [ -f /etc/bash_completion ]; then - source /etc/bash_completion; - fi; - -elif [ "$OS" = "Darwin" ]; then - - # Add tab completion for many Bash commands - if which brew > /dev/null && [ -f "$(brew --prefix)/etc/bash_completion" ]; then - source "$(brew --prefix)/etc/bash_completion"; - elif [ -f /etc/bash_completion ]; then - source /etc/bash_completion; - fi; - - # Add tab completion for `defaults read|write NSGlobalDomain` - # You could just use `-g` instead, but I like being explicit - complete -W "NSGlobalDomain" defaults; - - # Add `killall` tab completion for common apps - complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall; - -fi diff --git a/jivkok.Shell/tools/Bash.exports b/jivkok.Shell/tools/Bash.exports deleted file mode 100644 index b9d3129..0000000 --- a/jivkok.Shell/tools/Bash.exports +++ /dev/null @@ -1,23 +0,0 @@ -# Make vim the default editor -export EDITOR="vim"; -export VISUAL='vim' - -# Larger bash history (allow 32³ entries; default is 500) -export HISTSIZE=32768; -export HISTFILESIZE=$HISTSIZE; -export HISTCONTROL=ignoredups; -# Make some commands not show up in history -export HISTIGNORE="ls:ll:cd:cd -:pwd:exit:clear:date:* --help"; - -# Prefer US English and use UTF-8 -export LANG="en_US.UTF-8"; -export LC_ALL="en_US.UTF-8"; - -# Highlight section titles in manual pages -export LESS_TERMCAP_md="${yellow}"; - -# Enable colored `grep` output -if echo zzz | grep --color=auto zzz > /dev/null 2>&1; then - export GREP_OPTIONS="--color=auto"; - export GREP_COLOR='1;31' # matches -fi diff --git a/jivkok.Shell/tools/Bash.functions b/jivkok.Shell/tools/Bash.functions deleted file mode 100644 index ed61bdd..0000000 --- a/jivkok.Shell/tools/Bash.functions +++ /dev/null @@ -1,253 +0,0 @@ -function lsd() { - dir="$1" - if [ "$dir" == "" ]; then - dir=. - fi - find "$dir" -mindepth 1 -maxdepth 1 -type d -} - -function ff() { - if [ "$1" == "" ]; then - echo "Find Files (or directories)" - echo "Usage: ff file_pattern [directory]" - return - fi - - file_pattern="$1" - directory="$2" - if [ "$directory" == "" ]; then - directory='.' - fi - - find "$directory" -iname "$file_pattern" -} - -function fs() { - if [ "$1" == "" ]; then - echo "Find Strings in files" - echo "Usage: fs string_pattern [file_pattern] [directory]" - return - fi - - string_pattern="$1" - file_pattern="$2" - directory="$3" - if [ "$file_pattern" == "" ]; then - file_pattern='*' - fi - if [ "$directory" == "" ]; then - directory='.' - fi - - find "$directory" -type f -iname "$file_pattern" -exec grep -I -l -i "$string_pattern" {} \; -exec grep -I -n -i "$string_pattern" {} \; -} - -# lazy man extract - example: ex tarball.tar -function ex() { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xjfv $1 ;; - *.tar.gz) tar xzfv $1 ;; - *.tar.xz) tar xJfv $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) rar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xfv $1 ;; - *.tbz2) tar xjfv $1 ;; - *.tgz) tar xzfv $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via extract()" ;; - esac - else - echo "'$1' is not a valid file" - fi -} - -# Simple calculator -function calc() { - local result=""; - result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"; - # └─ default (when `--mathlib` is used) is 20 - # - if [[ "$result" == *.* ]]; then - # improve the output for decimal numbers - printf "$result" | - sed -e 's/^\./0./' \ # add "0" for cases like ".5" - -e 's/^-\./-0./' \ # add "0" for cases like "-.5" - -e 's/0*$//;s/\.$//'; # remove trailing zeros - else - printf "$result"; - fi; - printf "\n"; -} - -# Create a new directory and enter it -function mkd() { - mkdir -p "$@" && cd "$_"; -} - -# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression -function targz() { - local tmpFile="${@%/}.tar"; - tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1; - - size=$( - stat -f"%z" "${tmpFile}" 2> /dev/null; # OS X `stat` - stat -c"%s" "${tmpFile}" 2> /dev/null # GNU `stat` - ); - - local cmd=""; - if (( size < 52428800 )) && hash zopfli 2> /dev/null; then - # the .tar file is smaller than 50 MB and Zopfli is available; use it - cmd="zopfli"; - else - if hash pigz 2> /dev/null; then - cmd="pigz"; - else - cmd="gzip"; - fi; - fi; - - echo "Compressing .tar using \`${cmd}\`…"; - "${cmd}" -v "${tmpFile}" || return 1; - [ -f "${tmpFile}" ] && rm "${tmpFile}"; - echo "${tmpFile}.gz created successfully."; -} - -# Create a data URL from a file -function dataurl() { - local mimeType=$(file -b --mime-type "$1"); - if [[ $mimeType == text/* ]]; then - mimeType="${mimeType};charset=utf-8"; - fi - echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"; -} - -# Create a git.io short URL -function gitio() { - if [ -z "${1}" -o -z "${2}" ]; then - echo "Usage: \`gitio slug url\`"; - return 1; - fi; - curl -i http://git.io/ -F "url=${2}" -F "code=${1}"; -} - -# Start an HTTP server from a directory, optionally specifying the port -function server() { - local port="${1:-8000}"; - sleep 1 && open "http://localhost:${port}/" & - # Set the default Content-Type to `text/plain` instead of `application/octet-stream` - # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) - python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"; -} - -# Start a PHP server from a directory, optionally specifying the port -# (Requires PHP 5.4.0+.) -function phpserver() { - local port="${1:-4000}"; - local ip=$(ipconfig getifaddr en1); - sleep 1 && open "http://${ip}:${port}/" & - php -S "${ip}:${port}"; -} - -# Syntax-highlight JSON strings or files -# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json` -function json() { - if [ -t 0 ]; then # argument - python -mjson.tool <<< "$*" | pygmentize -l javascript; - else # pipe - python -mjson.tool | pygmentize -l javascript; - fi; -} - -# UTF-8-encode a string of Unicode symbols -function escape() { - printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u); - # print a newline unless we’re piping the output to another program - if [ -t 1 ]; then - echo ""; # newline - fi; -} - -# Decode \x{ABCD}-style Unicode escape sequences -function unidecode() { - perl -e "binmode(STDOUT, ':utf8'); print \"$@\""; - # print a newline unless we’re piping the output to another program - if [ -t 1 ]; then - echo ""; # newline - fi; -} - -# Get a character’s Unicode code point -function codepoint() { - perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"; - # print a newline unless we’re piping the output to another program - if [ -t 1 ]; then - echo ""; # newline - fi; -} - -# Show all the names (CNs and SANs) listed in the SSL certificate -# for a given domain -function getcertnames() { - if [ -z "${1}" ]; then - echo "ERROR: No domain specified."; - return 1; - fi; - - local domain="${1}"; - echo "Testing ${domain}…"; - echo ""; # newline - - local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \ - | openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1); - - if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then - local certText=$(echo "${tmp}" \ - | openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \ - no_serial, no_sigdump, no_signame, no_validity, no_version"); - echo "Common Name:"; - echo ""; # newline - echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//"; - echo ""; # newline - echo "Subject Alternative Name(s):"; - echo ""; # newline - echo "${certText}" | grep -A 1 "Subject Alternative Name:" \ - | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2; - return 0; - else - echo "ERROR: Certificate not found."; - return 1; - fi; -} - -# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring -# the `.git` directory, listing directories first. The output gets piped into -# `less` with options to preserve color and line numbers, unless the output is -# small enough for one screen. -function tre() { - tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; -} - -os=$(uname -s) - -if [ "$os" = "Linux" ]; then - - # View HTTP traffic - alias sniff="sudo ngrep -d 'eth0' -t '^(GET|POST) ' 'tcp and port 80'" - alias httpdump="sudo tcpdump -i eth0 -n -s 0 -w -" - -elif [ "$os" = "Darwin" ]; then - - # `o` with no arguments opens the current directory, otherwise opens the given location - function o() { - if [ $# -eq 0 ]; then - open .; - else - open "$@"; - fi; - } - -fi diff --git a/jivkok.Shell/tools/BoxStarter.psm1 b/jivkok.Shell/tools/BoxStarter.psm1 deleted file mode 100644 index 3c9f8f1..0000000 --- a/jivkok.Shell/tools/BoxStarter.psm1 +++ /dev/null @@ -1,115 +0,0 @@ -function Is64Bit{ [IntPtr]::Size -eq 8 } - -function Disable-InternetExplorerESC { - Write-Output "Disabling IE Enhanced Security Configuration (ESC) ..." - - $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" - if (-not (Test-Path $AdminKey)) { - New-Item -Path $AdminKey - } - Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 - - $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" - if (-not (Test-Path $UserKey)) { - New-Item -Path $UserKey - } - Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 - - Write-Output "IE Enhanced Security Configuration (ESC) has been disabled." -} - -function Disable-ShutdownTracker -{ - Write-Output "Disabling Windows shutdown event tracker ..." - - $key = 'HKLM:\Software\Policies\Microsoft\Windows NT\Reliability' - if (-not (Test-Path $key)) { - New-Item -Path $key - } - Set-ItemProperty -Path $key -Name ShutdownReasonOn -Value 0 - Set-ItemProperty -Path $key -Name ShutdownReasonUI -Value 0 - - Write-Output "Disabling Windows shutdown event tracker done." - Write-Output "" -} - -function Disable-UAC { - Write-Output "Disabling UAC ..." - - $key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' - if (-not (Test-Path $key)) { - New-Item -Path $key - } - Set-ItemProperty -Path $key -Name EnableLUA -Value 0 - - Write-Output "Disabling UAC done." - Write-Output "" -} - -function Enable-RemoteDesktop -{ - Write-Output "Enabling Remote Desktop ..." - $obj = Get-WmiObject -Class "Win32_TerminalServiceSetting" -Namespace root\cimv2\terminalservices - if ($obj -eq $null) { - Write-Output "Unable to locate TerminalServices namespace. Remote Desktop is not enabled" - return - } - $obj.SetAllowTsConnections(1,1) | out-null - - Write-Output "Enabling Remote Desktop done." - Write-Output "" -} - -function Restart-Explorer { - if (Get-Process -Name Explorer -ea 0) { - Write-Output "Stopping Explorer process ..." - Stop-Process -Name Explorer -Force - Start-Sleep -s 2 - } - - if (-not (Get-Process -Name Explorer -ea 0)) { - Write-Output "Starting Explorer process ..." - Start-Process Explorer - } -} - -function Set-ExplorerOptions([switch]$showHidenFilesFoldersDrives, [switch]$showProtectedOSFiles, [switch]$showFileExtensions) -{ - Write-Output "Setting Explorer options ..." - - $key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' - if (-not (Test-Path $key)) { - New-Item -Path $key - } - - if($showHidenFilesFoldersDrives) { - Write-Output "Show Hidden Files" - Set-ItemProperty $key Hidden 1 - } - if($showFileExtensions) { - Write-Output "Show File Extensions" - Set-ItemProperty $key HideFileExt 0 - } - if($showProtectedOSFiles) { - Write-Output "Show Protected OS Files" - Set-ItemProperty $key ShowSuperHidden 1 - } - - Write-Output "Setting Explorer options done." -} - -function Set-TaskbarSmall -{ - Write-Output "Setting Taskbar to Small Icons ..." - - $key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' - if (-not (Test-Path $key)) { - New-Item -Path $key - } - Set-ItemProperty $key TaskbarSmallIcons 1 - Set-ItemProperty $key TaskbarGlomLevel 2 - - Write-Output "Setting Taskbar to Small Icons done." -} - -Export-ModuleMember Disable-InternetExplorerESC, Disable-ShutdownTracker, Disable-UAC, Enable-RemoteDesktop, Restart-Explorer, Set-ExplorerOptions, Set-TaskbarSmall diff --git a/jivkok.Shell/tools/SetEnv.cmd b/jivkok.Shell/tools/SetEnv.cmd deleted file mode 100644 index ec23e09..0000000 --- a/jivkok.Shell/tools/SetEnv.cmd +++ /dev/null @@ -1,41 +0,0 @@ -@echo off - -set COPYCMD=/y - -set prompt=$_%USERNAME% @ %COMPUTERNAME% : $P$_$G$S - -DOSKEY cd=cd $*$Tdir -DOSKEY ..=pushd .. -DOSKEY ...=pushd ..\.. -DOSKEY l=dir /a /ogn /w $* -DOSKEY ll=dir /a /ogn $* -DOSKEY n=notepad.exe $* -DOSKEY ds=dir /s/b $* -DOSKEY fs=findstr /spin $1 $2 -DOSKEY b=msbuild $* - -rem Apps -if exist "%ProgramW6432%\Sublime Text 3\sublime_text.exe" ( - DOSKEY nn=start "" /B "%ProgramW6432%\Sublime Text 3\sublime_text.exe" $* -) -if exist "%ProgramFiles(x86)%\Git\bin\git.exe" ( - DOSKEY git="%ProgramFiles(x86)%\Git\bin\git.exe" $* -) - -rem VS -if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" ( - echo Setting VS 2015 ... - call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" -) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" ( - echo Setting VS 2013 ... - call "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" -) else if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" ( - echo Setting VS 2012 ... - call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" -) - -cd /d %USERPROFILE% - -if exist "%USERPROFILE%\profile.cmd" ( - call "%USERPROFILE%\profile.cmd" -) diff --git a/jivkok.Shell/tools/SetPosh.ps1 b/jivkok.Shell/tools/SetPosh.ps1 deleted file mode 100644 index 2b41862..0000000 --- a/jivkok.Shell/tools/SetPosh.ps1 +++ /dev/null @@ -1,101 +0,0 @@ -$env:PLINK_PROTOCOL = "ssh" -$env:TERM = "msys" -$env:HOME = resolve-path (join-path ([environment]::getfolderpath("mydocuments")) "..\") -$env:TMP = $env:TEMP = [system.io.path]::gettemppath() -$env:EDITOR = "Notepad" - -# Setup PATH -$GitPath = "${env:ProgramFiles}\Git" -$msBuildPath = "$env:SystemRoot\Microsoft.NET\Framework\v4.0.30319" -$env:Path = "$env:Path;$msbuildPath;$GitPath\cmd;$GitPath\bin" - -# Aliases -function .. { Push-Location .. } -function ... { Push-Location ..\.. } -function l { Get-ChildItem -Name $args } -function ll { Get-ChildItem -Force $args } -function n { notepad $args } -function nn { &"${Env:ProgramW6432}\Sublime Text 3\sublime_text.exe" $args } -function qg { start http://www.google.com/#q=$args } -function fs -{ - if (!$args) { - echo 'Usage: fs ' - return; - } - $pattern = $args[0] - $path = Split-Path -Path $args[0] -Parent - if ($args.length -gt 1) { - $path = $args[1] - } else { - $path = '.\*.*' - } - Get-ChildItem -Path $path -Recurse | Select-String -pattern $pattern -} -function ds -{ - if (!$args) { - Get-ChildItem -Recurse | Select Fullname - return; - } - $path = Split-Path -Path $args[0] -Parent - if ($path.length -eq 0) { - $path = '.' - } - $filter = Split-Path -Path $args[0] -Leaf - if ($filter.length -eq 0) { - $filter = '*.*' - } - Get-ChildItem -Path $path -Filter $filter -Recurse | Select Fullname -} - -# Prompt -function ShortenPath([string] $path) { - $loc = $path.Replace($HOME, '~') - return $loc -} -function prompt { - $originalLASTEXITCODE = $LASTEXITCODE - - $colorDelimiter = [ConsoleColor]::Gray - $colorNames = [ConsoleColor]::DarkYellow - $colorLocation = [ConsoleColor]::DarkGreen - - # Window Title - $host.UI.RawUI.WindowTitle = "$env:USERNAME @ $env:COMPUTERNAME : $(Get-Location)" - - # Core text - Write-Host "$env:USERNAME" -NoNewline -ForegroundColor $colorNames - Write-Host " @ " -NoNewline -ForegroundColor $colorDelimiter - Write-Host ([net.dns]::GetHostName()) -NoNewline -ForegroundColor $colorNames - Write-Host " : " -NoNewline -ForegroundColor $colorDelimiter - # Show provider name if it is not the file system - if ($pwd.Provider.Name -ne "FileSystem") { - Write-Host "[" -NoNewline -ForegroundColor $colorDelimiter - Write-Host (Get-Location).Provider.Name -NoNewline -ForegroundColor $colorDelimiter - Write-Host "] " -NoNewline -ForegroundColor $colorDelimiter - } - Write-Host (ShortenPath (Get-Location).Path) -NoNewline -ForegroundColor $colorLocation - - # poshgit - if (Test-Path Function:\Write-VcsStatus) { - Write-VcsStatus - $global:LASTEXITCODE = $originalLASTEXITCODE - } - - Write-Host -f $colorDelimiter - - # Check for elevated prompt - $wid=[System.Security.Principal.WindowsIdentity]::GetCurrent() - $prp=new-object System.Security.Principal.WindowsPrincipal($wid) - $adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator - $IsAdmin=$prp.IsInRole($adm) - if ($IsAdmin) { - Write-Host "#" -NoNewline -ForegroundColor $colorDelimiter - } - else { - Write-Host ">" -NoNewline -ForegroundColor $colorDelimiter - } - - return ' ' -} diff --git a/jivkok.Shell/tools/chocolateyInstall.ps1 b/jivkok.Shell/tools/chocolateyInstall.ps1 index 77d5dfd..070da4b 100644 --- a/jivkok.Shell/tools/chocolateyInstall.ps1 +++ b/jivkok.Shell/tools/chocolateyInstall.ps1 @@ -1,65 +1,21 @@ $package = 'jivkok.Shell' -function Get-CurrentDirectory -{ - $thisName = $MyInvocation.MyCommand.Name - [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) -} - -function New-Shortcut($ShortcutPath, $TargetPath, $Arguments, $IconLocation) -{ - $WshShell = New-Object -comObject WScript.Shell - $Shortcut = $WshShell.CreateShortcut($ShortcutPath) - $Shortcut.TargetPath = $TargetPath - $Shortcut.Arguments = $Arguments - $Shortcut.IconLocation = $IconLocation - $Shortcut.Save() -} - try { - $currentPath = Get-CurrentDirectory - - $destPath = "$Home\.shell" - if (!(Test-Path $destPath)) - { - New-Item $destPath -Type Directory | Out-Null - } - - # Copy files - 'Console.xml', - 'SetEnv.cmd', - 'SetPosh.ps1' | - % { - $params = @{ - Path = Join-Path $currentPath $_; - Destination = Join-Path $destPath $_; - Force = $true - } - Copy-Item @params + # dotfiles repo + if (Test-Path "$Home\dotfiles\.git") { + . "${Env:ProgramFiles(x86)}\Git\bin\git.exe" -C "$Home\dotfiles" pull --prune --recurse-submodules + . "${Env:ProgramFiles(x86)}\Git\bin\git.exe" -C "$Home\dotfiles" submodule init + . "${Env:ProgramFiles(x86)}\Git\bin\git.exe" -C "$Home\dotfiles" submodule update --remote --recursive + } else { + if (Test-Path "$Home\dotfiles") { + if (Test-Path "$Home\dotfiles.BACKUP") { Remove-Item "$Home\dotfiles.BACKUP" -Recurse -Force } + Rename-Item "$Home\dotfiles" "$Home\dotfiles.BACKUP" -Force } + . "${Env:ProgramFiles(x86)}\Git\bin\git.exe" clone --recursive https://github.com/jivkok/dotfiles.git "$Home\dotfiles" + } - New-Shortcut "$Home\Desktop\Console.lnk" "$Env:ChocolateyInstall\bin\Console.exe" "-c $Home\.shell\console.xml" "cmd.exe,0" - - # Bash files - $destPath = "$Home" - copy (Join-Path $currentPath Bash.aliases) (Join-Path $destPath .aliases) - copy (Join-Path $currentPath Bash.bashrc) (Join-Path $destPath .bashrc) - copy (Join-Path $currentPath Bash.bash_profile) (Join-Path $destPath .bash_profile) - copy (Join-Path $currentPath Bash.bash_prompt) (Join-Path $destPath .bash_prompt) - copy (Join-Path $currentPath Bash.exports) (Join-Path $destPath .exports) - copy (Join-Path $currentPath Bash.functions) (Join-Path $destPath .functions) - - # BoxStarter - Import-Module (Join-Path $currentPath BoxStarter.psm1) - Disable-ShutdownTracker - Disable-InternetExplorerESC - Set-ExplorerOptions -showHidenFilesFoldersDrives $true -showProtectedOSFiles $true -showFileExtensions $true - Enable-RemoteDesktop - # Set-TaskbarSmall - # Restart-Explorer - - [Environment]::SetEnvironmentVariable("_NT_SYMBOL_PATH", "srv*C:\Symbols*http://referencesource.microsoft.com/symbols*http://srv.symbolsource.org/pdb/Public*http://msdl.microsoft.com/download/symbols", "User") + . "$Home\dotfiles\setup_windows.ps1" } catch { - Write-ChocolateyFailure $package "$($_.Exception.Message)" + Write-ChocolateyFailure $package "$_" throw } diff --git a/jivkok.Shell/tools/chocolateyUninstall.ps1 b/jivkok.Shell/tools/chocolateyUninstall.ps1 index b6dc966..feb29a4 100644 --- a/jivkok.Shell/tools/chocolateyUninstall.ps1 +++ b/jivkok.Shell/tools/chocolateyUninstall.ps1 @@ -1,9 +1,40 @@ $package = 'jivkok.Shell' try { - Remove-Item "$Home\.shell" -recurse -force - Remove-Item "$Home\Desktop\JConsole.lnk" -force + echo "Deleting desktop shortcut (and taskbar pin): $Home\Desktop\Shell.lnk" + if (Test-Path "$Home\Desktop\Shell.lnk") { + $shellApp = New-Object -c Shell.Application + $folderItem = $shellApp.Namespace("$Home\Desktop").ParseName('Shell.lnk') + $folderItem.InvokeVerb('taskbarunpin') + + Remove-Item "$Home\Desktop\Shell.lnk" -Force + } + + echo 'Deleting directory symlinks' + '.vim' | + % { + if (Test-Path "$Home\$_.BACKUP") { cmd /c "rd $Home\$_.BACKUP" } + Rename-Item "$Home\$_" "$Home\$_.BACKUP" -Force + } + + echo 'Deleting file symlinks' + '.aliases', + '.bash_profile', + '.bash_prompt', + '.bashrc', + '.curlrc', + '.exports', + '.functions', + '.tmux.conf', + '.vimrc', + '.wgetrc' | + % { + if (Test-Path "$Home\$_.BACKUP") { Remove-Item "$Home\$_.BACKUP" -Force } + Rename-Item "$Home\$_" "$Home\$_.BACKUP" -Force + } + + echo 'NOTE: repo is left in-place' } catch { - Write-ChocolateyFailure $package "$($_.Exception.Message)" - throw + Write-ChocolateyFailure $package "$_" + throw } diff --git a/jivkok.Shell/tools/console.xml b/jivkok.Shell/tools/console.xml deleted file mode 100644 index c1d84c4..0000000 --- a/jivkok.Shell/tools/console.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -