super_prompt 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89c869eccf3a0043d9cc1ec30a7e76f81bfc7a97
4
+ data.tar.gz: 8e05998ca0180cb6cf0888ee1cc09c1d750b38ad
5
+ SHA512:
6
+ metadata.gz: 87e1d1b96899d5e6e0219f762910542b373b5ce4faf6276d4478de216e1839254d8215a84b44d8d002267c8e7111bbdaba456a6ba5f01984c79676ae7eb75075
7
+ data.tar.gz: 356bec91a0a1054804fa9c818d869ae50a5d88705aae54d1b484d6d2d66b3752b60df731a5bc8c22d01e879867bf313eff6ac863a0941fbc885658d4374fa39f
data/bin/super_prompt ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils.rb'
4
+
5
+ `sed -i 's/\s*source \.super_prompt\s*//g' ~/.bash_profile`
6
+ `sed -i 's/\s*source \.super_prompt\s*//g' ~/.bashrc`
7
+
8
+ `printf '\nsource .super_prompt\n' >> ~/.bash_profile`
9
+ `printf '\nsource .super_prompt\n' >> ~/.bashrc`
10
+
11
+ dest_path = `echo $HOME`.strip + '/.super_prompt'
12
+ source_path = File.expand_path(File.dirname(__FILE__)).chomp('bin') + 'lib/.super_prompt'
13
+
14
+
15
+ FileUtils.cp(source_path, dest_path)
data/lib/.super_prompt ADDED
@@ -0,0 +1,104 @@
1
+ # customize prompt
2
+
3
+ # function to generate git branch name
4
+ parse_git_branch() {
5
+ git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1:/'
6
+ }
7
+
8
+ firstPrompt='true'
9
+ PROMPT_COMMAND=super_prompt
10
+
11
+ function super_prompt() {
12
+ local lastCommandStatus=$? # capture status of last command
13
+
14
+ # variables to make modification easier
15
+
16
+
17
+ local bell='' # '\a' for bell or '' for no bell
18
+ local containerColor='0;33' # color of the container for the information header
19
+ local containerStartSymbol='[' # symbol used at the start of the container for the information header
20
+ local containerEndSymbol=']\n' # symbol used at the end of the container for the information header
21
+ local containerDivisionSymbol='|' # symbol used as dividers between sections of the container
22
+ local dateColor='1;33' # date color
23
+ local dateFormat='\d, $(date +'%Y')' # date format
24
+ local timeColor='1;35' # time color
25
+ local timeFormat='\@' # time format
26
+ local bashColor='1;36' # Bash version color
27
+ local bashFormat='Bash v\V' # Bash version format
28
+ local userColor='1;34' # color for user and host
29
+ local userFormat='\u@\H' # user format
30
+ local commandColor='1;35' # command index color
31
+ local commandFormat='C\#' # command index format
32
+ local historyColor='1;36' # history index color
33
+ local historyFormat='H\!' # history index format
34
+ local pathColor='1;34' # color for path
35
+ local pathFormat='$PWD' # format for path
36
+ local successSymbol='✔' # symbol to display when last command succeeds
37
+ local successColor='1;32' # color for success symbol
38
+ local failureSymbol='✗' # symbol to display when last command fails
39
+ local failureColor='1;31' # color for failure symbol
40
+ local warningColor='1;31' # warning color
41
+ local warningSymbol='☢' # warning symbol
42
+ local allClearColor='1;32' # all clear color
43
+ local allClearSymbol='☀' # all clear symbol
44
+ local gitColor='1;31' # color for git branch
45
+
46
+ # end modification variables
47
+
48
+ # container definition
49
+ containerStart='\e['$containerColor'm'$containerStartSymbol'\e[m' # start of container
50
+ containerEnd='\e['$containerColor'm'$containerEndSymbol'\e[m' # end of container
51
+ containerDivision='\e['$containerColor'm'$containerDivisionSymbol'\e[m' # dividers between sections of container
52
+
53
+ local primaryPrompt='' # initialize primary prompt
54
+ local seconaryPrompt='' # intialize secondary prompt
55
+
56
+ # an information header defined and written to environment variable PS1 when the terminal is first opened, the user changes, or this file is sourced.
57
+
58
+ if [ $firstPrompt == 'true' ]
59
+
60
+ then
61
+
62
+ primaryPrompt+=$containerStart'\e['$dateColor'm'$dateFormat'\e[m'$containerDivision'\e['$timeColor'm'$timeFormat'\e[m'$containerDivision'\e['$bashColor'm'$bashFormat'\e[m'$containerDivision'\e['$userColor'm'$userFormat'\e[m'$containerEnd
63
+
64
+ firstPrompt='false'
65
+
66
+ fi
67
+
68
+ # write a header to PS1 consisting of command and history numbers and path
69
+ primaryPrompt+=$containerStart$bell'\e['$commandColor'm'$commandFormat'\e[m'$containerDivision'\e['$historyColor'm'$historyFormat'\e[m'$containerDivision'\e['$gitColor'm'$(parse_git_branch)'\e[m\e['$pathColor'm'$pathFormat'\e[m'$containerEnd
70
+
71
+ if [ $lastCommandStatus == 0 ] # if last command succeded, use success color and symbol
72
+
73
+ then
74
+
75
+ primaryPrompt+='\e['$successColor'm'$successSymbol' \e[m'
76
+ secondaryPrompt+='\e['$successColor'm'$successSymbol' \e[m'
77
+
78
+ else # otherwise, use failure color and symbol
79
+
80
+ primaryPrompt+='\e['$failureColor'm'$failureSymbol' \e[m'
81
+ secondaryPrompt+='\e['$failureColor'm'$failureSymbol' \e[m'
82
+
83
+ fi
84
+
85
+
86
+ if [ $(id -u) == 0 ] # if userid is superuser, warn the user by using warning color and symbol
87
+
88
+ then
89
+
90
+ primaryPrompt+='\e['$warningColor'm'$warningSymbol' > \e[m'
91
+ secondaryPrompt+='\e['$warningColor'm'$warningSymbol' > \e[m'
92
+
93
+
94
+ else # otherwise, use all clear color and symbol
95
+
96
+ primaryPrompt+='\e['$allClearColor'm'$allClearSymbol' > \e[m'
97
+ secondaryPrompt+='\e['$allClearColor'm'$allClearSymbol' > \e[m'
98
+
99
+ fi
100
+
101
+ PS1=$primaryPrompt # write constructed primary prompt to environment variable PS1
102
+ PS2=$secondaryPrompt # write constructed secondary prompt to environment variable PS2
103
+
104
+ }
File without changes
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: super_prompt
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Lair
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem installs Super Prompt. Super Prompt is a customizable Bash
14
+ prompt that provides the user with a wealth of information at a glance including
15
+ git branch, present working directory (pwd), whether the last command succeeded,
16
+ warns the user if the user is root, date, time, user, host name, command number
17
+ and history number.
18
+ email: lair002@gmail.com
19
+ executables:
20
+ - super_prompt
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - bin/super_prompt
25
+ - lib/.super_prompt
26
+ - lib/super_prompt.rb
27
+ homepage: https://github.com/lair001/super-prompt
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.95'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.5.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: 'Super Prompt: Customizable Bash prompt that provides the user with a wealth
51
+ of information at a glance.'
52
+ test_files: []